fix gfx hit not sych with animation. Fix wrong animation timing with long weapon. Add animation scaling speed
This commit is contained in:
@@ -359,7 +359,7 @@ public class A3DCombActDynData
|
||||
// if (!m_bNoFx)
|
||||
// TriggerSFxFromEventList();
|
||||
Resume();
|
||||
UpdateAct(0);
|
||||
UpdateAct(0, m_pECModel.GetPlaySpeed());
|
||||
if(true /*!m_bNoFx*/)
|
||||
{
|
||||
LoadFXFromEventList();
|
||||
@@ -499,6 +499,13 @@ public class A3DCombActDynData
|
||||
public void Stop(bool bStopAct, bool bForceStopFx = false )
|
||||
{
|
||||
RemoveAllActiveFx();
|
||||
if (ActiveAttackEvent != null)
|
||||
{
|
||||
Debug.Log($"[Nam Debug]Stop: ActiveAttackEvent.m_bSignaled = true, Action name: {m_pAct.m_strName}");
|
||||
ActiveAttackEvent.m_bSignaled = true;
|
||||
}
|
||||
|
||||
|
||||
// FlushDamageInfo();
|
||||
|
||||
// ClearParentInfo();
|
||||
@@ -530,11 +537,9 @@ public class A3DCombActDynData
|
||||
// if (pChannel)
|
||||
// pChannel->StopAction(m_pAct->GetRank(m_nChannel));
|
||||
}
|
||||
public void UpdateAct(uint dwDeltaTime)
|
||||
public void UpdateAct(uint dwDeltaTime, float fPlaySpeed = 1f)
|
||||
{
|
||||
m_dwTimeSpan += (int)dwDeltaTime;
|
||||
if (m_pECModel.IsActionStopped())
|
||||
return;
|
||||
|
||||
if(true/*!m_bNoFx*/)
|
||||
UpdateEvent((uint)m_dwTimeSpan, 0);
|
||||
@@ -581,7 +586,7 @@ public class A3DCombActDynData
|
||||
{
|
||||
m_nCurActLoop = 0;
|
||||
m_nCurActIndex++;
|
||||
EventBus.PublishChannel(m_pECModel.GetId(), new PlayActionEvent( pNext.m_strName, m_nTransTime, false, ActiveAttackEvent, pNext.CalcLoopNum()==-1 && pNext.GetTimeSpan() > 10));
|
||||
EventBus.PublishChannel(m_pECModel.GetId(), new PlayActionEvent( pNext.m_strName, m_nTransTime, false, null, pNext.CalcLoopNum()==-1 && pNext.GetTimeSpan() > 10, fPlaySpeed));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,19 +634,7 @@ public class A3DCombActDynData
|
||||
}
|
||||
public bool IsActionStopped()
|
||||
{
|
||||
if(m_pAct.IsLooping())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(m_nCurLoop >= m_pAct.m_nLoops)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(m_pAct.m_ActLst.Count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return m_pAct.m_ActLst.Count == 0 || (m_pAct.m_nLoops != -1 && m_nCurLoop >= m_pAct.m_nLoops);
|
||||
}
|
||||
void LoopCurAct(ACTION_INFO pCur, uint dwDeltaTime)
|
||||
{
|
||||
@@ -650,7 +643,6 @@ public class A3DCombActDynData
|
||||
void LoopNext(uint dwDeltaTime)
|
||||
{
|
||||
m_nCurLoop++;
|
||||
|
||||
if (!IsActionStopped())
|
||||
{
|
||||
RemoveAllActiveFx();
|
||||
@@ -1118,6 +1110,7 @@ public class CECModel
|
||||
private Transform m_transform;
|
||||
private bool m_bAbsTrack = false;
|
||||
private bool m_bFirstActPlayed = false;
|
||||
private float m_fPlaySpeed = 1.0f;
|
||||
public bool InheritParentId() => m_bInheritParentId;
|
||||
public void SetId(int nId) => m_nId = nId;
|
||||
public int GetId() => m_nId;
|
||||
@@ -1507,13 +1500,34 @@ public class CECModel
|
||||
return m_pMapModel.m_ActionMap.TryGetValue(szActName, out A3DCombinedAction combinedAction) ? combinedAction : null;
|
||||
}
|
||||
//Final trigger function
|
||||
public int GetComActTimeSpanByName(string szActName)
|
||||
{
|
||||
A3DCombinedAction combinedAction = GetComActByName(szActName);
|
||||
if (combinedAction == null || combinedAction.m_ActLst == null || combinedAction.m_ActLst.Count == 0)
|
||||
return 0;
|
||||
|
||||
int totalMs = 0;
|
||||
foreach (var actInfo in combinedAction.m_ActLst)
|
||||
{
|
||||
if (actInfo == null || string.IsNullOrEmpty(actInfo.m_strName))
|
||||
continue;
|
||||
AnimationClip clip = GetAnimationClip(actInfo.m_strName);
|
||||
if (clip != null)
|
||||
totalMs += Mathf.Max(1, Mathf.RoundToInt(clip.length * 1000f));
|
||||
}
|
||||
return totalMs;
|
||||
}
|
||||
public void SetPlaySpeed(float vScale)
|
||||
{
|
||||
m_fPlaySpeed = vScale;
|
||||
}
|
||||
public float GetPlaySpeed() => m_fPlaySpeed;
|
||||
public bool QueueAction(int nChannel, string szActName, int nTransTime, uint dwUserData, bool bForceStopPrevAct, bool bCheckTailDup, bool bNoFx, bool bResetSpeed, bool bResetActFlag, CECAttackEvent attackEvent=null, uint dwNewFlagMode=0){
|
||||
if(szActName == null || szActName == string.Empty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
A3DCombinedAction pComAct = GetComActByName(szActName);
|
||||
|
||||
if (pComAct == null)
|
||||
return false;
|
||||
|
||||
@@ -1586,7 +1600,7 @@ public class CECModel
|
||||
}
|
||||
public bool Tick(uint dwDeltaTime)
|
||||
{
|
||||
UpdateChannelActs(dwDeltaTime);
|
||||
UpdateChannelActs((uint)(dwDeltaTime * m_fPlaySpeed));
|
||||
return true;
|
||||
}
|
||||
void UpdateChannelActs(uint dwUpdateTime)
|
||||
@@ -1606,13 +1620,11 @@ public class CECModel
|
||||
bActFinished = node.m_pActive.IsActionStopped();
|
||||
else
|
||||
bActFinished = node.m_pActive.IsActionStopped();
|
||||
|
||||
if (bActFinished)
|
||||
{
|
||||
if (node.m_dwFlagMode != COMACT_FLAG_MODE_NONE && node.m_pActFlag)
|
||||
{
|
||||
node.m_pActFlag = true;
|
||||
|
||||
if (node.m_dwFlagMode != COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX)
|
||||
node.m_dwFlagMode = (int)COMACT_FLAG_MODE_NONE;
|
||||
|
||||
@@ -1621,14 +1633,15 @@ public class CECModel
|
||||
if (node.m_QueuedActs.Count > 0)
|
||||
{
|
||||
A3DCombActDynData pNext = node.m_QueuedActs[0];
|
||||
|
||||
if (pNext.GetStopPrevAct())
|
||||
{
|
||||
node.m_pActive.Stop(true);
|
||||
//StopChildrenAct();
|
||||
}
|
||||
else
|
||||
{
|
||||
node.m_pActive.Stop(false);
|
||||
}
|
||||
|
||||
// script
|
||||
//m_pMapModel->OnScriptPlayAction(this, i, pNext->GetComAct()->GetName());
|
||||
@@ -1641,7 +1654,7 @@ public class CECModel
|
||||
node.m_pActive = null;
|
||||
node.m_pActive = pNext;
|
||||
node.m_pActive.Play(i, 1f, node.m_pActive.GetTransTime(), 0/**m_EventMasks[i]*/, true, m_bAbsTrack, pNext.GetNoFxFlag());
|
||||
//pNext.UpdateAct(dwUpdateTime);
|
||||
pNext.UpdateAct(dwUpdateTime, m_fPlaySpeed);
|
||||
node.m_QueuedActs.RemoveAt(0);
|
||||
m_bAbsTrack = false;
|
||||
}
|
||||
@@ -1653,7 +1666,7 @@ public class CECModel
|
||||
}
|
||||
else
|
||||
{
|
||||
node.m_pActive.UpdateAct(dwUpdateTime);
|
||||
node.m_pActive.UpdateAct(dwUpdateTime, m_fPlaySpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user