modify some code of channel act

This commit is contained in:
Tran Hai Nam
2026-05-05 17:47:39 +07:00
parent c52b3f445f
commit a5d162f398
3 changed files with 33 additions and 18 deletions
@@ -4058,7 +4058,7 @@ namespace BrewMonster
public bool IsForceStopPrevious;
public bool IsLoop;
public CECAttackEvent AttackEvent;
public byte Channel;
public int Rank;
public PlayActionEvent(string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false)
{
this.ChannelAct = null;
@@ -4067,9 +4067,9 @@ namespace BrewMonster
IsForceStopPrevious = isForceStopPrevious;
AttackEvent = attackEvent;
IsLoop = isLoop;
Channel = 0;
Rank = 0;
}
public PlayActionEvent(ref ChannelAct channelAct, string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false, byte channel = 0)
public PlayActionEvent(ref ChannelAct channelAct, string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false, int rank = 0)
{
this.ChannelAct = channelAct;
this.AnimationName = animationName;
@@ -4077,7 +4077,7 @@ namespace BrewMonster
IsForceStopPrevious = isForceStopPrevious;
AttackEvent = attackEvent;
IsLoop = isLoop;
Channel = channel;
Rank = rank;
}
}
public struct PLAYER_ACTION
@@ -4095,7 +4095,7 @@ namespace BrewMonster
public bool IsHitAnim;
public bool IsForceStopPrevious;
public bool IsLoop;
public byte Channel;
public int Rank;
public QueueActionEvent(string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
CECAttackEvent attackEvent, int iTransTime, bool isForceStopPrevious = false, bool isLoop = false)
{
@@ -4107,10 +4107,10 @@ namespace BrewMonster
ITransTime = iTransTime;
IsForceStopPrevious = isForceStopPrevious;
IsLoop = isLoop;
Channel = 0;
Rank = 0;
}
public QueueActionEvent(ref ChannelAct channelAct, string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
CECAttackEvent attackEvent, int iTransTime, bool isForceStopPrevious = false, bool isLoop = false, byte channel = 0)
CECAttackEvent attackEvent, int iTransTime, bool isForceStopPrevious = false, bool isLoop = false, int rank = 0)
{
this.ChannelAct = channelAct;
this.AnimationName = animationName;
@@ -4120,7 +4120,7 @@ namespace BrewMonster
ITransTime = iTransTime;
IsForceStopPrevious = isForceStopPrevious;
IsLoop = isLoop;
Channel = channel;
Rank = rank;
}
public void SetData(string shapeName, string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
+14 -4
View File
@@ -55,9 +55,10 @@ public enum ActionChannel
public class A3DCombActDynData
{
public A3DCombinedAction combinedAction;
public float fTime;
public int nChannel;
public int m_dwUserData;
public bool IsAllActionFinished => m_EventNames.Count == 0;
public List<string> m_EventNames = new List<string>();
public void SetUserData(int dwUserData) { m_dwUserData = dwUserData; }
public int GetUserData() { return m_dwUserData; }
}
@@ -790,17 +791,24 @@ public class CECModel
node = new ChannelActNode { m_Rank = 0 };
m_ChannelActs[nChannel].m_RankNodes.Add(node);
}
node.m_pActive = new A3DCombActDynData
var actData = new A3DCombActDynData
{
combinedAction = combinedAction,
nChannel = nChannel,
m_dwUserData = (int)dwUserData
};
EventBus.PublishChannel(m_nId, new PlayActionEvent(ref m_ChannelActs[nChannel], actionInfos[0].m_strName, nTransTime, bForceStop, attackEvent, isLoop, node.m_Rank));
actData.m_EventNames.Add(actionInfos[0].m_strName);
for(int i = 1; i < actionInfos.Count; i++)
{
EventBus.PublishChannelClass(m_nId, new QueueActionEvent(ref m_ChannelActs[nChannel], actionInfos[i].m_strName, null, false, attackEvent, nTransTime, false, isLoop, node.m_Rank));
actData.m_EventNames.Add(actionInfos[i].m_strName);
}
node.m_pActive = actData;
//Todo: should move those event logic to channel act because their control the animation life span.
var eventInfoList = combinedAction.m_EventInfoLst;
if(eventInfoList != null && eventInfoList.Count > 0)
{
@@ -848,7 +856,7 @@ public class CECModel
var isLoop = combinedAction.m_nLoops == 1;
var node = new ChannelActNode { m_Rank = (byte)m_ChannelActs[nChannel].m_RankNodes.Count};
m_ChannelActs[nChannel].m_RankNodes.Add(node);
node.m_pActive = new A3DCombActDynData
var actData = new A3DCombActDynData
{
// combinedAction = combinedAction, // not needed now
nChannel = nChannel,
@@ -857,9 +865,11 @@ public class CECModel
EventBus.PublishChannelClass(m_nId, new QueueActionEvent(ref m_ChannelActs[nChannel], actionInfos[0].m_strName, null, false, attackEvent, nTransTime, bForceStopPrevAct, isLoop, node.m_Rank));
for(int i = 1; i < actionInfos.Count; i++)
{
EventBus.PublishChannelClass(m_nId, new QueueActionEvent(ref m_ChannelActs[nChannel], actionInfos[i].m_strName, null, false, attackEvent, nTransTime, false, isLoop, node.m_Rank));
actData.m_EventNames.Add(actionInfos[i].m_strName);
}
node.m_pActive = actData;
//todo: should add sfx and gfx logic to channel act. currently we dont have logic for queue action. only available for play action.
return true;
}
public bool ClearComActFlagAllRankNodes(bool bSignalCurrent)
+11 -6
View File
@@ -15,7 +15,7 @@ namespace BrewMonster
public CECAttackEvent AttackEvent;
public bool IsLoop;
public ChannelAct ChannelAct;
public byte Channel;
public int Rank;
}
public class PlayerVisual : MonoBehaviour
{
@@ -52,14 +52,14 @@ namespace BrewMonster
IsForceStopPrevious = @event.IsForceStopPrevious,
AttackEvent = @event.AttackEvent,
ChannelAct = @event.ChannelAct,
Channel = @event.Channel
Rank = @event.Rank
});
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
return;
}
previousAnimationName = @event.AnimationName;
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode, @event.IsLoop);
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Channel);
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank);
}
public void InitPlayerEventDoneHandler()
{
@@ -162,7 +162,7 @@ namespace BrewMonster
AttackEvent = @event.AttackEvent,
IsLoop = @event.IsLoop,
ChannelAct = @event.ChannelAct,
Channel = @event.Channel
Rank = @event.Rank
});
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
if (!isHit)
@@ -228,16 +228,21 @@ namespace BrewMonster
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
previousAnimationName = animationQueue.AnimationName;
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode, animationQueue.IsLoop);
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Channel);
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank);
}
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, byte channel)
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank)
{
if (_currentState == null) return;
_currentState.Events.OnEnd = () =>
{
if (attackEvent != null)
attackEvent.m_bSignaled = true;
channelAct.GetNodeByRank((byte)rank).m_pActive.m_EventNames.Remove(_currentAnimationName);
if(channelAct.GetNodeByRank((byte)rank).m_pActive.IsAllActionFinished)
{
//channelAct.RemoveNodeByRank((byte)rank);
}
};
}
void ApplyDamage()