123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- ///@{ actions
- /**@class HandActionBase
- * @brief represents action executed on transition just between OnExit from old state and OnEntry to new state
- **/
- class HandActionBase
- {
- /**@fn Action
- * @brief executed when transition occurs
- **/
- void Action (HandEventBase e) { }
- };
- class HandActionCreated extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionCreated", e.m_Player.ToString() );
- }
- #endif
- e.m_Player.OnItemInHandsChanged();
- }
- };
- class HandActionTake extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionTake", e.m_Player.ToString() );
- }
- #endif
- GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
- e.m_Player.OnItemInHandsChanged();
- }
- };
- class HandActionDrop extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDrop", e.m_Player.ToString() );
- }
- #endif
- GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
- e.m_Player.OnItemInHandsChanged();
- }
- };
- class HandActionThrow extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionThrow", e.m_Player.ToString() );
- }
- #endif
- HandEventThrow throwEvent = HandEventThrow.Cast(e);
- GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
- DayZPlayer player = DayZPlayer.Cast(e.m_Player);
- if ( player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE )
- {
- InventoryItem item = InventoryItem.Cast(e.GetSrcEntity());
- if( item )
- item.ThrowPhysically(player, throwEvent.GetForce());
- else
- Error("[hndfsm] HandActionThrow - src entity null!");
- }
- player.OnItemInHandsChanged();
- }
- };
- class HandActionMoveTo extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionMoveTo", e.m_Player.ToString() );
- }
- #endif
- HandEventMoveTo es = HandEventMoveTo.Cast(e);
- if (es)
- {
- GameInventory.LocationSyncMoveEntity(e.GetSrc(), es.m_Dst);
- e.m_Player.OnItemInHandsChanged();
- }
- else
- Error("[hndfsm] HandActionMoveTo - this is no HandEventMoveTo");
- }
- };
- class HandActionDestroy extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroy", e.m_Player.ToString() );
- }
- #endif
- GetGame().ObjectDelete(e.GetSrcEntity());
- e.m_Player.OnItemInHandsChanged();
- }
- };
- class HandActionDestroyed extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyed", e.m_Player.ToString() );
- }
- #endif
- e.m_Player.OnItemInHandsChanged();
- }
- };
- class HandActionDestroyAndReplaceWithNew extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyAndReplaceWithNew", e.m_Player.ToString() );
- }
- #endif
- Man player = e.m_Player;
- EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
- InventoryLocation src = new InventoryLocation;
- if (itemInHands.GetInventory().GetCurrentInventoryLocation(src))
- {
- HandEventDestroyAndReplaceWithNew edr = HandEventDestroyAndReplaceWithNew.Cast(e);
- if (edr)
- {
- edr.m_Lambda.Execute();
- return;
- }
- else
- Error("[hndfsm] HandActionDestroyAndReplaceWithNew - not a HandEventDestroyAndReplaceWithNew event");
- }
- else
- Error("[hndfsm] HandActionDestroyAndReplaceWithNew - itemInHands has no InventoryLocation");
- }
- };
- class HandActionDestroyAndReplaceWithNewElsewhere extends HandActionDestroyAndReplaceWithNew
- {
- override void Action (HandEventBase e)
- {
- super.Action(e);
- }
- };
- class HandActionReplaced extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionReplaced", e.m_Player.ToString() );
- }
- #endif
- Man player = e.m_Player;
- player.OnItemInHandsChanged();
- }
- };
- class HandActionSwap extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionSwap", e.m_Player.ToString() );
- }
- #endif
- HandEventSwap es = HandEventSwap.Cast(e);
- if (es)
- {
- GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
- e.m_Player.OnItemInHandsChanged();
- }
- else
- Error("[hndfsm] HandActionSwap - this is no HandEventSwap");
- }
- };
- class HandActionForceSwap extends HandActionBase
- {
- override void Action (HandEventBase e)
- {
- #ifdef ENABLE_LOGGING
- if ( LogManager.IsInventoryHFSMLogEnable() )
- {
- Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionForceSwap", e.m_Player.ToString() );
- }
- #endif
- HandEventForceSwap es = HandEventForceSwap.Cast(e);
- if (es)
- {
- GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
- e.m_Player.OnItemInHandsChanged();
- }
- else
- Error("[hndfsm] HandActionForceSwap - this is no HandEventForceSwap");
- }
- };
- ///@} actions
|