File size: 3,706 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
class HandTakingAnimated_Hide extends HandStartAction
{ };
class HandTakingAnimated_Show extends HandStartAction
{
ref InventoryLocation m_Src;
ref InventoryLocation m_Dst;
void HandTakingAnimated_Show(Man player = null, HandStateBase parent = null, WeaponActions action = WeaponActions.NONE, int actionType = -1)
{
m_Src = null;
m_Dst = null;
}
override void OnEntry(HandEventBase e)
{
super.OnEntry(e);
if (m_Src)
{
if (m_Src.IsValid())
{
#ifdef DEVELOPER
if ( LogManager.IsInventoryHFSMLogEnable() )
{
Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnEntry", e.m_Player.ToString() );
}
#endif
//if (GameInventory.LocationCanMoveEntity(m_Src, m_Dst))
//{
GameInventory.LocationSyncMoveEntity(m_Src, m_Dst);
e.m_Player.OnItemInHandsChanged();
//}
//else
//{
// if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandTakingAnimated_Show - not allowed");
//}
}
else
{
Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandTakingAnimated_Show m_Src=invalid, item not in bubble?");
}
}
else
Error("[hndfsm] HandTakingAnimated_Show, error - m_Src not configured");
}
override void OnAbort(HandEventBase e)
{
m_Src = null;
m_Dst = null;
super.OnAbort(e);
}
override void OnExit(HandEventBase e)
{
m_Src = null;
m_Dst = null;
super.OnExit(e);
}
override bool IsWaitingForActionFinish() { return true; }
};
class HandAnimatedTakingFromAtt extends HandStateBase
{
ref HandTakingAnimated_Hide m_Hide;
ref HandTakingAnimated_Show m_Show;
ref InventoryLocation m_Dst;
void HandAnimatedTakingFromAtt(Man player = null, HandStateBase parent = null)
{
// setup nested state machine
m_Hide = new HandTakingAnimated_Hide(player, this, WeaponActions.HIDE, -1);
m_Show = new HandTakingAnimated_Show(player, this, WeaponActions.SHOW, -1);
// events:
HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
HandEventBase _AEh_ = new HandAnimEventChanged;
HandEventBase __Xd_ = new HandEventDestroyed;
m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
m_FSM.AddTransition(new HandTransition( m_Hide, _AEh_, m_Show ));
m_FSM.AddTransition(new HandTransition( m_Hide, __Xd_, null ));
m_FSM.AddTransition(new HandTransition( m_Show, _fin_, null ));
m_FSM.AddTransition(new HandTransition( m_Show, __Xd_, null ));
m_FSM.SetInitialState(m_Hide);
}
override void OnEntry(HandEventBase e)
{
m_Dst = e.GetDst();
m_Show.m_Src = e.GetSrc();
m_Show.m_Dst = e.GetDst();
m_Hide.m_ActionType = e.GetAnimationID();
m_Show.m_ActionType = e.GetAnimationID();
e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst.GetItem(), m_Dst, GameInventory.c_InventoryReservationTimeoutShortMS);
super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
}
override void OnAbort(HandEventBase e)
{
#ifdef DEVELOPER
if ( LogManager.IsInventoryHFSMLogEnable() )
{
Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnAbort", e.m_Player.ToString() );
}
#endif
if (m_Dst)
{
e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
if ( GetGame().IsServer() )
GetGame().ClearJuncture(e.m_Player, m_Dst.GetItem());
}
m_Dst = null;
super.OnAbort(e);
}
override void OnExit(HandEventBase e)
{
e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
m_Dst = null;
super.OnExit(e);
}
};
|