123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- class HandSwappingAnimated_Show extends HandForceSwappingAnimated_Show
- {
- };
- class HandAnimatedSwapping 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_Hide;
- ref HandSwappingAnimated_Show m_Show;
- void HandAnimatedSwapping(Man player = null, HandStateBase parent = null)
- {
- // setup nested state machine
- m_Hide = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
- m_Show = new HandSwappingAnimated_Show(player, this, WeaponActions.SHOW, -1);
- // events:
- HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
- HandEventBase _AEh_ = new HandAnimEventChanged;
- 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_Show, _fin_, null ));
- m_FSM.SetInitialState(m_Hide);
- }
- override void OnEntry(HandEventBase e)
- {
- HandEventSwap es = HandEventSwap.Cast(e);
- if (es)
- {
- m_Src1 = es.GetSrc();
- m_Src2 = es.m_Src2;
- m_Dst1 = es.GetDst();
- m_Dst2 = es.m_Dst2;
- m_Show.m_Src1 = m_Src1;
- m_Show.m_Src2 = m_Src2;
- m_Show.m_Dst1 = m_Dst1;
- m_Show.m_Dst2 = m_Dst2;
- m_Hide.m_ActionType = es.m_AnimationID;
- m_Show.m_ActionType = es.m_Animation2ID;
-
- if (!GetGame().IsDedicatedServer())
- {
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
- e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, 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_Dst2)
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
- }
- if (m_Dst1)
- {
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- }
- }
- else
- {
- if (m_Dst2)
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
- }
- if (m_Dst1)
- {
- GetGame().ClearJuncture(e.m_Player, m_Dst1.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_Dst2.GetItem(), m_Dst2);
- e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
- }
-
- m_Src1 = null;
- m_Src2 = null;
- m_Dst1 = null;
- m_Dst2 = null;
- super.OnExit(e);
- }
- };
|