123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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 ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnEntry", e.m_Player.ToString() );
- }
- #endif
-
- if (!GetGame().IsMultiplayer())
- {
- GameInventory.LocationSyncMoveEntity(m_Src, m_Dst);
- m_Player.OnItemInHandsChanged();
- }
- else
- {
- if (!GetGame().IsDedicatedServer())
- {
- m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
- m_Player.GetHumanInventory().PostDeferredEventTakeToDst(InventoryMode.JUNCTURE, m_Src, m_Dst);
- }
- else
- {
- GetGame().ClearJunctureEx(e.m_Player, m_Dst.GetItem());
- }
- }
- }
- 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();
-
- 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 ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnAbort", e.m_Player.ToString() );
- }
- #endif
- if (m_Dst)
- {
- m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
- if ( GetGame().IsServer() )
- GetGame().ClearJunctureEx(e.m_Player, m_Dst.GetItem());
- }
- m_Dst = null;
- super.OnAbort(e);
- }
- override void OnExit(HandEventBase e)
- {
- m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
- m_Dst = null;
- super.OnExit(e);
- }
- };
|