123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- // When editing this, take a look at HandAnimatedMoveToDst_W4T_Basic as well
- // They can not be inherited from each other because of different inheritance
- class HandAnimatedMoveToDst_W4T_Basic extends HandStateBase
- {
- ref InventoryLocation m_Dst;
- override void OnEntry(HandEventBase e)
- {
- Man player = e.m_Player;
- if (m_Dst && m_Dst.IsValid())
- {
- EntityAI item = m_Dst.GetItem();
- InventoryLocation src = new InventoryLocation;
- if (item.GetInventory().GetCurrentInventoryLocation(src))
- {
- if (GameInventory.LocationSyncMoveEntity(src, m_Dst))
- {
- player.OnItemInHandsChanged();
- }
- else
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("[hndfsm] HandAnimatedMoveToDst_W4T_Basic - not allowed");
- }
- #endif
- }
- }
- else
- Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandAnimatedMoveToDst_W4T_Basic - item " + item + " has no Inventory or Location, inv=" + item.GetInventory());
- }
- else
- Error("[hndfsm] HandAnimatedMoveToDst_W4T_Basic - event has no valid m_Dst");
- super.OnEntry(e);
- }
- override void OnAbort(HandEventBase e)
- {
- m_Dst = null;
- super.OnAbort(e);
- }
- override void OnExit(HandEventBase e)
- {
- m_Dst = null;
- super.OnExit(e);
- }
- override bool IsWaitingForActionFinish() { return true; }
- };
- class HandForceSwappingAnimated_Show extends HandStartAction
- {
- ref InventoryLocation m_Src1 = null;
- ref InventoryLocation m_Src2 = null;
- ref InventoryLocation m_Dst1 = null;
- ref InventoryLocation m_Dst2 = null;
- void HandForceSwapingAnimated_Show(Man player = null, HandStateBase parent = null, WeaponActions action = WeaponActions.NONE, int actionType = -1) { }
- override void OnEntry(HandEventBase e)
- {
- if (m_Src1 && m_Src2 && m_Dst1 && m_Dst2)
- {
- //InventoryLocation dummy;
- //dummy.Copy(m_Dst2);
- //if (GameInventory.CanForceSwapEntitiesEx(m_Src1.GetItem(), m_Dst1, m_Src2.GetItem(), dummy) && dummy == m_Dst2)
- //{
- //! TODO(kumarjac): THIS IS WHAT IS BEING CALLED FOR SOME REASON!!!!!
- GameInventory.LocationSwap(m_Src1, m_Src2, m_Dst1, m_Dst2);
- e.m_Player.OnItemInHandsChanged();
- //}
- //else
- //{
- // if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandForceSwapingAnimated_Show - not allowed");
- //}
- }
- else
- Error("[hndfsm] HandForceSwappingAnimated_Show is not properly configured!");
- super.OnEntry(e);
- }
- override void OnAbort(HandEventBase e)
- {
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
- super.OnAbort(e);
- }
- override void OnExit(HandEventBase e)
- {
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
- super.OnExit(e);
- }
- override bool IsWaitingForActionFinish() { return true; }
- };
- class HandAnimatedForceSwapping extends HandStateBase
- {
- ref InventoryLocation m_Src1 = null;
- ref InventoryLocation m_Src2 = null;
- ref InventoryLocation m_Dst1 = null;
- ref InventoryLocation m_Dst2 = null;
- ref HandStartHidingAnimated m_Start;
- ref HandAnimatedMoveToDst_W4T m_Show;
- ref HandAnimatedMoveToDst_W4T_Basic m_Hide;
- void HandAnimatedForceSwapping(Man player = null, HandStateBase parent = null)
- {
- // setup nested state machine
- m_Start = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
- m_Show = new HandAnimatedMoveToDst_W4T(player, this, WeaponActions.SHOW, -1);
- m_Hide = new HandAnimatedMoveToDst_W4T_Basic(player, this);
- // 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_Start, _AEh_, m_Hide ));
- m_FSM.AddTransition(new HandTransition( m_Hide, _AEh_, m_Show )); // no animation in Hide step
- m_FSM.AddTransition(new HandTransition( m_Show, _fin_, null ));
- m_FSM.AddTransition(new HandTransition( m_Hide, _fin_, null ));
- m_FSM.AddTransition(new HandTransition( m_Show, __Xd_, null ));
- m_FSM.AddTransition(new HandTransition( m_Hide, __Xd_, null ));
- m_FSM.SetInitialState(m_Start);
- }
- override void OnEntry(HandEventBase e)
- {
- HandEventForceSwap efs = HandEventForceSwap.Cast(e);
- if (efs)
- {
- if ( efs.GetSrc().GetType() == InventoryLocationType.HANDS )
- {
- m_Start.m_ActionType = efs.m_AnimationID;
-
- m_Src1 = efs.GetSrc();
- m_Src2 = efs.m_Src2;
- m_Dst1 = efs.GetDst();
- m_Dst2 = efs.m_Dst2;
-
- m_Show.m_ActionType = efs.m_Animation2ID;
- }
- else
- {
- m_Start.m_ActionType = efs.m_Animation2ID;
-
- m_Src1 = efs.m_Src2;
- m_Src2 = efs.GetSrc();
- m_Dst1 = efs.m_Dst2;
- m_Dst2 = efs.GetDst();
-
- m_Show.m_ActionType = efs.m_AnimationID;
- }
-
- m_Hide.m_Dst = m_Dst1;
- m_Show.m_Dst = m_Dst2;
- if (!GetGame().IsDedicatedServer())
- {
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
- }
- }
- super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
- }
- override void OnAbort(HandEventBase e)
- {
- if ( !GetGame().IsDedicatedServer())
- {
- if (m_Dst1)
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
- }
- }
- else
- {
- if (m_Dst1)
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst1.GetItem());
- GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
- }
- }
-
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
-
- super.OnAbort(e);
- }
- override void OnExit(HandEventBase e)
- {
- if ( !GetGame().IsDedicatedServer())
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
- }
- else
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst1.GetItem());
- GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
- }
-
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
- super.OnExit(e);
- }
- };
- class HandAnimatedForceSwapping_Inst extends HandStateBase
- {
- ref InventoryLocation m_Src1 = null;
- ref InventoryLocation m_Src2 = null;
- ref InventoryLocation m_Dst1 = null;
- ref InventoryLocation m_Dst2 = null;
- ref HandStartHidingAnimated m_Start;
- ref HandForceSwappingAnimated_Show m_Swap;
- void HandAnimatedForceSwapping_Inst(Man player = null, HandStateBase parent = null)
- {
- // setup nested state machine
- m_Start = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
- m_Swap = new HandForceSwappingAnimated_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_Start, _AEh_, m_Swap ));
- m_FSM.AddTransition(new HandTransition( m_Swap, _fin_, null ));
- m_FSM.AddTransition(new HandTransition( m_Swap, __Xd_, null ));
- m_FSM.SetInitialState(m_Start);
- }
- override void OnEntry(HandEventBase e)
- {
- HandEventForceSwap efs = HandEventForceSwap.Cast(e);
- if (efs)
- {
- if ( efs.GetSrc().GetType() == InventoryLocationType.HANDS )
- {
- m_Start.m_ActionType = efs.m_AnimationID;
-
- m_Src1 = efs.GetSrc();
- m_Src2 = efs.m_Src2;
- m_Dst1 = efs.GetDst();
- m_Dst2 = efs.m_Dst2;
- m_Swap.m_ActionType = efs.m_Animation2ID;
- }
- else
- {
- m_Start.m_ActionType = efs.m_Animation2ID;
-
- m_Src1 = efs.m_Src2;
- m_Src2 = efs.GetSrc();
- m_Dst1 = efs.m_Dst2;
- m_Dst2 = efs.GetDst();
- m_Swap.m_ActionType = efs.m_AnimationID;
- }
-
- m_Swap.m_Src1 = m_Src1;
- m_Swap.m_Dst1 = m_Dst1;
- m_Swap.m_Src2 = m_Src2;
- m_Swap.m_Dst2 = m_Dst2;
-
- if (!GetGame().IsDedicatedServer())
- {
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
- }
- }
- super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
- }
- override void OnAbort(HandEventBase e)
- {
- if ( !GetGame().IsDedicatedServer())
- {
- if (m_Dst1)
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- }
- if (m_Dst2)
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
- }
- }
- else
- {
- if (m_Dst1)
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst1.GetItem());
- }
- if (m_Dst2)
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
- }
- }
-
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
-
- super.OnAbort(e);
- }
- override void OnExit(HandEventBase e)
- {
- if ( !GetGame().IsDedicatedServer())
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
- }
- else
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst1.GetItem());
- GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
- }
-
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
- super.OnExit(e);
- }
- };
|