fix pose action

This commit is contained in:
NguyenVanDat
2025-12-17 17:16:55 +07:00
parent 220d1792a3
commit 1bc54fa74a
6 changed files with 73 additions and 60 deletions
@@ -1,24 +1,29 @@
using System.Collections;
using System.Dynamic;
using CSNetwork.GPDataType;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace BrewMonster.Scripts
{
public class CECHPWorkStand : CECHPWork
{
protected bool m_bMeetSlide; // true, meet slide
protected int m_iPoseAction; // pose action
protected bool m_bSession; // doing session pose
protected bool m_bWaterStop; // stop moving down in water
protected bool m_bMoving; // moving flag
protected bool m_bStopSlide; // stop sliding flag
protected int m_iCurAction; // current playing action
protected bool m_bMeetSlide; // true, meet slide
protected int m_iPoseAction; // pose action
protected bool m_bSession; // doing session pose
protected bool m_bWaterStop; // stop moving down in water
protected bool m_bMoving; // moving flag
protected bool m_bStopSlide; // stop sliding flag
protected int m_iCurAction; // current playing action
//protected int m_oldAction; // cache old played action
public CECHPWorkStand(CECHPWorkMan pWorkMan) : base(Host_work_ID.WORK_STAND, pWorkMan)
{
m_dwMask = Work_mask.MASK_STAND;
m_dwTransMask = Work_mask.MASK_MOVETOPOS | Work_mask.MASK_FLYOFF | Work_mask.MASK_FREEFALL | Work_mask.MASK_TRACEOBJECT |
Work_mask.MASK_SIT | Work_mask.MASK_SPELLOBJECT | Work_mask.MASK_FOLLOW | Work_mask.MASK_CONCENTRATE | Work_mask.MASK_USEITEM;
m_dwTransMask = Work_mask.MASK_MOVETOPOS | Work_mask.MASK_FLYOFF | Work_mask.MASK_FREEFALL |
Work_mask.MASK_TRACEOBJECT |
Work_mask.MASK_SIT | Work_mask.MASK_SPELLOBJECT | Work_mask.MASK_FOLLOW |
Work_mask.MASK_CONCENTRATE | Work_mask.MASK_USEITEM;
Reset();
}
@@ -55,18 +60,21 @@ namespace BrewMonster.Scripts
return true;
}
public void SetPoseAction(int iAction, bool bSession)
public async void SetPoseAction(int iAction, bool bSession)
{
m_iPoseAction = iAction;
m_bSession = bSession;
// m_pHost.PlayAction(m_iPoseAction, false, 300);
m_pHost.PlayAction(m_iPoseAction, true);
m_pHost.ClearAnimation();
m_pHost.PlayAction(m_iPoseAction, false);
if (!bSession && iAction != (int)PLAYER_ACTION_TYPE.ACT_EXP_KISS)
m_pHost.PlayAction(m_pHost.GetMoveStandAction(false, false), true, 300, true);
{
await UniTask.Delay(3000);
m_iPoseAction = 0;
// m_pHost.PlayAction(m_pHost.GetMoveStandAction(false, false), true, 300, true);
}
}
// On first tick
protected override void OnFirstTick()
{
m_pHost.m_iMoveMode = (int)Move_Mode.MOVE_STAND;
@@ -150,8 +158,10 @@ namespace BrewMonster.Scripts
{
// ASSERT(0);
}
return true;
}
// Play appropriate actions
if (m_iPoseAction == (int)PLAYER_ACTION_TYPE.ACT_STAND)
{
@@ -165,21 +175,15 @@ namespace BrewMonster.Scripts
{
if (m_pHost.m_iMoveEnv == CECPlayer.Move_environment.MOVEENV_GROUND)
Tick_Walk(fDeltaTime);
/* else // AIR or WATER
Tick_FlySwim(fDeltaTime);*/
/* else // AIR or WATER
Tick_FlySwim(fDeltaTime);*/
}
if (m_iPoseAction == (int)PLAYER_ACTION_TYPE.ACT_STAND)
{
// Chariot war special case omitted for now
m_pHost.PlayAction(m_iCurAction, false, 300);
//m_oldAction = m_iCurAction;
}
else
{
// Debug.LogError($"m_iPoseAction == {(PLAYER_ACTION_TYPE)m_iPoseAction}");
m_pHost.PlayAction(m_iPoseAction, false, 300);
}
// Force to update object's direction and up
// m_pHost.m_vecGroundNormal = m_pHost.m_vecGroundNormalSet;
@@ -211,18 +215,21 @@ namespace BrewMonster.Scripts
{
m_bStopSlide = true;
m_bMoving = false;
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), (int)GPMoveMode.GP_MOVE_SLIDE);
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(),
(int)GPMoveMode.GP_MOVE_SLIDE);
}
else
{
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, GPDataTypeHelper.g_vOrigin, cdr.vAbsVelocity, (int)GPMoveMode.GP_MOVE_SLIDE);
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, GPDataTypeHelper.g_vOrigin, cdr.vAbsVelocity,
(int)GPMoveMode.GP_MOVE_SLIDE);
}
}
else if (m_bMeetSlide)
{
m_bMeetSlide = false;
m_bMoving = false;
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), (int)GPMoveMode.GP_MOVE_SLIDE);
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(),
(int)GPMoveMode.GP_MOVE_SLIDE);
}
return true;
@@ -250,8 +257,9 @@ namespace BrewMonster.Scripts
}*/
// Get stop sliding flag
public bool GetStopSlideFlag() { return m_bStopSlide; }
public bool GetStopSlideFlag()
{
return m_bStopSlide;
}
}
}
}
+15 -10
View File
@@ -171,7 +171,7 @@ namespace BrewMonster
m_PlayerActions = _default_actions;
m_iShape = 0;
m_aEquips = new int[(int)IndexOfIteminEquipmentInventory.SIZE_ALL_EQUIPIVTR];
queueActionEvent = new QueueActionEvent("", null, false, null);
queueActionEvent = new QueueActionEvent("", null, false, null,200);
}
/// <summary>This function will get the coressponding model player for the player based on the profession and gender </summary>
@@ -420,9 +420,8 @@ namespace BrewMonster
{
m_iCurAction = iAction;
PLAYER_ACTION action = actionConfig;
var szAct = EC_Utility.BuildActionName(action, 0);
EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct));
EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct, iTransTime));
return true;
}
@@ -589,9 +588,10 @@ namespace BrewMonster
// “起? 动作(挥起)
szAct = EC_Utility.BuildActionName(action, weapon_type, "起");
EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct));
int iTransTime = 200;
EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct,iTransTime));
szAct = EC_Utility.BuildActionName(action, weapon_type, "落");
queueActionEvent.SetData(szAct, SetApplyDamage, true, attackEvent);
queueActionEvent.SetData(szAct, SetApplyDamage, true, attackEvent,iTransTime);
EventBus.PublishChannelClass(m_PlayerInfo.cid, queueActionEvent);
//PlayNonSkillActionWithName(iAction, szAct, true, 200, true, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);gagága
/*
@@ -651,7 +651,8 @@ namespace BrewMonster
// ==============================
PLAYER_ACTION stand_action = m_PlayerActions[(int)PLAYER_ACTION_TYPE.ACT_FIGHTSTAND];
szAct = EC_Utility.BuildActionName(stand_action, 0);
queueActionEvent.SetData(szAct, SetApplyDamage, false, attackEvent);
int iTranstime = 200;
queueActionEvent.SetData(szAct, SetApplyDamage, false, attackEvent,iTranstime);
EventBus.PublishChannelClass(m_PlayerInfo.cid, queueActionEvent);
/* QueueNonSkillActionWithName(ACT_FIGHTSTAND, szAct, 300, false, bHideFX, true);
@@ -1532,10 +1533,11 @@ namespace BrewMonster
public struct PlayActionEvent
{
public string AnimationName;
public PlayActionEvent(string animationName)
public int ITransTime;
public PlayActionEvent(string animationName, int iTransTime)
{
this.AnimationName = animationName;
ITransTime = iTransTime;
}
}
public struct PLAYER_ACTION
@@ -1546,26 +1548,29 @@ namespace BrewMonster
public class QueueActionEvent
{
public string AnimationName;
public int ITransTime;
public Action<bool, CECAttackEvent> SetFlag;
public CECAttackEvent AttackEvent;
public bool IsHitAnim;
public QueueActionEvent(string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
CECAttackEvent attackEvent)
CECAttackEvent attackEvent,int iTransTime)
{
this.AnimationName = animationName;
SetFlag = setFlag;
IsHitAnim = isHitAnim;
AttackEvent = attackEvent;
ITransTime = iTransTime;
}
public void SetData(string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
CECAttackEvent attackEvent)
CECAttackEvent attackEvent,int iTransTime)
{
this.AnimationName = animationName;
SetFlag = setFlag;
IsHitAnim = isHitAnim;
AttackEvent = attackEvent;
ITransTime = iTransTime;
}
}
public enum PLAYER_ACTION_TYPE
@@ -245,7 +245,8 @@ namespace BrewMonster
{
return false;
}
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName));
int iTransTime = 0;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
return true;
}
@@ -268,7 +269,8 @@ namespace BrewMonster
return false;
}
m_isCastingSkill = true;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName));
int iTransTime = 0;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
return true;
}
@@ -283,7 +285,8 @@ namespace BrewMonster
return false;
}
m_isCastingSkill = true;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName));
int iTransTime = 0;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
return true;
}
@@ -298,7 +301,9 @@ namespace BrewMonster
{
return false;
}
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName));
int iTransTime = 0;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
return true;
}
-1
View File
@@ -44,7 +44,6 @@ public partial class CECGameRun
private static Dictionary<int, CECInstance> m_InstTab = new Dictionary<int, CECInstance>();
public void Init()
{
BMLogger.LogError("CECGameRun Init");
Application.targetFrameRate = 60;
instance = this;
// _gameRunConfig = Resources.Load<GameRunConfig>("GameRunConfig");
+7 -12
View File
@@ -156,10 +156,10 @@ namespace BrewMonster
public EC_Inventory PackInventory => m_packInventory;
public EC_Inventory EquipInventory => m_equipInventory;
public EC_Inventory TaskInventory => m_taskInventory;
private void OnApplicationQuit()
{
if(m_pTaskInterface!=null)
if (m_pTaskInterface != null)
m_pTaskInterface.Despose();
}
@@ -1113,7 +1113,6 @@ namespace BrewMonster
int iLimit = (int)(pCmd.iMaxHP * 0.3f);
if (pCmd.iHP < m_BasicProps.iCurHP && m_BasicProps.iCurHP >= iLimit && pCmd.iHP < iLimit)
{
/*if (CECUIHelper::GetGameUIMan().IsShowLowHP()) {
// ѪÁ¿µÍÓÚÁÙ½çÖµÔò²¥·ÅÌØÐ§
const int GfxLastTime = 10000; // ³ÖÐøÊ±¼ä10Ãë
@@ -1760,7 +1759,6 @@ namespace BrewMonster
// TODO: Handle other pickup item commands if necessary
}
}
@@ -2590,6 +2588,11 @@ namespace BrewMonster
return iRet;
}
public void ClearAnimation()
{
EventBus.PublishChannel(GetCharacterID(), new ClearComActFlagAllRankNodesEvent(true));
}
public CECActionSwitcherBase GetActionSwitcher()
{
return m_pActionSwitcher;
@@ -3134,7 +3137,6 @@ namespace BrewMonster
if (!bTraceOK) return false;
// }
//}
}
}
@@ -3265,9 +3267,7 @@ namespace BrewMonster
//// Clear deal pack
//m_pDealPack.RemoveAllItems();
break;
}
}
}
@@ -3546,7 +3546,6 @@ namespace BrewMonster
UnityGameSession.c2s_CmdCastPosSkill(m_pPrepSkill.GetSkillID(), EC_Utility.ToVector3(vMovePos),
byPVPMask, 1, idTarget);
bSuccess = true;
}
m_pPrepSkill = null;
@@ -4163,11 +4162,9 @@ namespace BrewMonster
if (m_iMoveEnv == Move_environment.MOVEENV_AIR)
{
}
else if (m_iMoveEnv == Move_environment.MOVEENV_WATER)
{
}
else
{
@@ -4234,7 +4231,6 @@ namespace BrewMonster
public bool glb_GetForceAttackFlag(uint pdwParam)
{
/*bool bForceAttack = false;
CECInputCtrl* pInputCtrl = g_pGame.GetGameRun().GetInputCtrl();
@@ -4959,7 +4955,6 @@ namespace BrewMonster
// ÏòÏ Trace µØÐκͽ¨Öþ£¬²¢·µ»ØµÚÒ»¸öÅöײµãµÄÇé¿ö
bool VertRayTrace(Vector3 vPos, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal, float DeltaY)
{
Vector3 vTerrainPos = Vector3.zero;
Vector3 vTerrainNormal = Vector3.zero;
Vector3 vBuildingPos = Vector3.zero;
+5 -4
View File
@@ -20,7 +20,7 @@ namespace BrewMonster
[SerializeField] private int id;
private const float FadeTime = 0.1f;
private const FadeMode FadeMode = Animancer.FadeMode.FixedDuration;
private const FadeMode FadeMode = Animancer.FadeMode.NormalizedDuration;
QueueActionEvent queueActionEvent;
private void PlayActionEventHandler(PlayActionEvent @event)
@@ -31,7 +31,7 @@ namespace BrewMonster
_animationList = _animationQueue.ToList();
return;
}
InternalPlayAnimation(@event.AnimationName);
InternalPlayAnimation(@event.AnimationName, @event.ITransTime);
}
public void InitPlayerEventDoneHandler()
{
@@ -130,7 +130,8 @@ namespace BrewMonster
}
string animName = _animationQueue.Dequeue();
_animationList = _animationQueue.ToList();
InternalPlayAnimation(animName);
//TODO: default fadetime = 200 remake later
InternalPlayAnimation(animName,200);
}
void ApplyDamage()
{
@@ -160,7 +161,7 @@ namespace BrewMonster
/// <param name="fadeMode"></param>
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode)
{
_currentState = namedAnimancer.TryPlay(animationName, duration, fadeMode);
_currentState = namedAnimancer.TryPlay(animationName, duration / 1000, fadeMode);
_currentAnimationName = animationName;
if (_currentState == null)
{