DayZ 1.24
Loading...
Searching...
No Matches
HumanInventoryWithFSM Class Reference

HumanInventory... with FSM (synchronous, no anims) More...

Inheritance diagram for HumanInventoryWithFSM:
[legend]
Collaboration diagram for HumanInventoryWithFSM:
[legend]

Protected Member Functions

void HumanInventoryWithFSM ()
 
void CreateStableStates ()
 
override void Init ()
 
bool CanProcessHandEvents ()
 
override bool ProcessHandEvent (HandEventBase e)
 hand's fsm handling of events @NOTE: warning: ProcessHandEvent can be called only within DayZPlayer::HandleInventory (or CommandHandler)
 
bool ProcessHandAbortEvent (HandEventBase e)
 
override bool OnStoreLoad (ParamsReadContext ctx, int version)
 
override void OnStoreSave (ParamsWriteContext ctx)
 
int GetCurrentStateID ()
 
bool IsIdle ()
 
void NetSyncCurrentStateID (int id)
 Engine callback - network synchronization of FSM's state. not intended to direct use.
 

Protected Attributes

ref HandFSM m_FSM
 
ref HandStateBase m_Empty
 hand slot state machine
 
ref HandStateBase m_Equipped
 

Additional Inherited Members

- Private Member Functions inherited from HumanInventory
bool ReplaceItemInElsewhereWithNewinHandsImpl (InventoryMode mode, HandEventBase e)
 
bool ReplaceItemInHandsWithNewImpl (InventoryMode mode, HandEventBase e)
 
bool ReplaceItemInHandsWithNew (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
 
bool ReplaceItemInHandsWithNewElsewhere (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
 
bool SwappingToPreviousLocation (EntityAI item1, EntityAI item2, out InventoryLocation dst)
 
void HandleInventoryManipulation ()
 
void Update (float delta_time)
 
bool ValidateUserReservationCancel (inout Serializer ctx, InventoryValidation validation)
 

Detailed Description

HumanInventory... with FSM (synchronous, no anims)

Definition at line 5 of file HumanInventoryWithFSM.c.

Constructor & Destructor Documentation

◆ HumanInventoryWithFSM()

void HumanInventoryWithFSM::HumanInventoryWithFSM ( )
inlineprotected

Definition at line 11 of file HumanInventoryWithFSM.c.

12 {
13 m_FSM = new HandFSM();
14 }
Hand finite state machine.

References m_FSM.

Member Function Documentation

◆ CanProcessHandEvents()

bool HumanInventoryWithFSM::CanProcessHandEvents ( )
inlineprotected

Definition at line 90 of file HumanInventoryWithFSM.c.

90{ return m_FSM && m_FSM.IsRunning(); }

References m_FSM.

◆ CreateStableStates()

void HumanInventoryWithFSM::CreateStableStates ( )
inlineprotected

Definition at line 16 of file HumanInventoryWithFSM.c.

17 {
18 // stable states are created only if they do not exist already (for example created by derived class like DayZPlayerInventory)
19 // @NOTE: this cannot be done in constructor, as there is NO owner set yet. GetManOwner() will therefore return NULL.
20 if (!m_Empty)
22 if (!m_Equipped)
24 }
ref HandStateBase m_Equipped
ref HandStateBase m_Empty
hand slot state machine

References HumanInventory::GetManOwner(), m_Empty, and m_Equipped.

Referenced by Init().

◆ GetCurrentStateID()

HumanInventoryWithFSM::GetCurrentStateID ( )
inlineprotected
Returns
identifier of current stable state

Definition at line 152 of file HumanInventoryWithFSM.c.

152{ return m_FSM.GetCurrentStateID(); }

References m_FSM.

◆ Init()

override void HumanInventoryWithFSM::Init ( )
inlineprotected

Definition at line 26 of file HumanInventoryWithFSM.c.

27 {
28 // setup state machine
29 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] Initializing Human Inventory FSM");
30
31 // basic states
33
34 // events
35 HandEventBase __T__ = new HandEventTake;
36 HandEventBase __D__ = new HandEventDrop;
37 HandEventBase __Tw_ = new HandEventThrow;
38 HandEventBase __M__ = new HandEventMoveTo;
40 HandEventBase __F__ = new HandEventForceSwap;
41 HandEventBase __X__ = new HandEventDestroy;
42 HandEventBase __Xd_ = new HandEventDestroyed;
44 HandEventBase __Re_ = new HandEventDestroyAndReplaceWithNewElsewhere;
45 HandEventBase __Rh_ = new HandEventDestroyElsewhereAndReplaceWithNewInHands;
46 HandEventBase __Rd_ = new HandEventReplaced;
47 HandEventBase __Cd_ = new HandEventCreated;
48 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
49 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
50
51
52 HandReplacingItemInHands replacing = new HandReplacingItemInHands(GetManOwner());
53 HandReplacingItemInHands replacingElsewhere = new HandReplacingItemInHands(GetManOwner());
54 HandReplacingItemElsewhereWithNewInHands replacingElsewhere3 = new HandReplacingItemElsewhereWithNewInHands(GetManOwner());
55
56 // setup transitions
59
62 m_FSM.AddTransition(new HandTransition(m_Equipped, __M__, m_Empty, new HandActionMoveTo, new HandGuardAnd(new HandGuardHasItemInHands(GetManOwner()), new HandGuardCanMove(GetManOwner()))));
63 m_FSM.AddTransition(new HandTransition(m_Equipped, __X__, m_Empty, new HandActionDestroy, new HandGuardHasItemInHands(GetManOwner())));
64 m_FSM.AddTransition(new HandTransition(m_Equipped, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
65 m_FSM.AddTransition(new HandTransition(m_Equipped, __Xd_, m_Equipped, new HandActionDestroyed, new HandGuardNot(new HandGuardHasDestroyedItemInHands(GetManOwner()))));
66
67 m_FSM.AddTransition(new HandTransition(m_Equipped, __R__, replacing));
68 m_FSM.AddTransition(new HandTransition(replacing, _fin_, m_Equipped));
69 replacing.AddTransition(new HandTransition(replacing.m_Replacing, _abt_, m_Equipped));
70
74
77 replacingElsewhere3.AddTransition(new HandTransition(replacingElsewhere3.m_Replacing, _abt_, m_Empty));
78
80 m_FSM.AddTransition(new HandTransition(m_Equipped, __W__, m_Equipped, new HandActionSwap, new HandGuardAnd(new HandGuardHasItemInHands(GetManOwner()), new HandGuardCanSwap(GetManOwner()))));
81 m_FSM.AddTransition(new HandTransition(m_Equipped, __F__, m_Equipped, new HandActionForceSwap, new HandGuardAnd(new HandGuardHasItemInHands(GetManOwner()), new HandGuardCanForceSwap(GetManOwner()))));
82
83 // start FSM
84 m_FSM.SetInitialState(m_Empty);
85 m_FSM.Start();
86
87 super.Init();
88 }
void hndDebugPrint(string s)
Definition HandFSM.c:1
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27
Abstracted event, not to be used, only inherited.
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749

References CreateStableStates(), HumanInventory::GetManOwner(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), m_Empty, m_Equipped, and m_FSM.

◆ IsIdle()

bool HumanInventoryWithFSM::IsIdle ( )
inlineprotected

Definition at line 154 of file HumanInventoryWithFSM.c.

154{ return m_FSM.GetCurrentState().IsIdle(); }

References m_FSM.

◆ NetSyncCurrentStateID()

HumanInventoryWithFSM::NetSyncCurrentStateID ( int id)
inlineprotected

Engine callback - network synchronization of FSM's state. not intended to direct use.

Definition at line 159 of file HumanInventoryWithFSM.c.

160 {
161 m_FSM.NetSyncCurrentStateID(id);
162 }

References m_FSM.

◆ OnStoreLoad()

override bool HumanInventoryWithFSM::OnStoreLoad ( ParamsReadContext ctx,
int version )
inlineprotected

Definition at line 131 of file HumanInventoryWithFSM.c.

132 {
133 if (!super.OnStoreLoad(ctx, version))
134 return false;
135
136 //@TODO
137 //m_FSM.OnStoreLoad(ctx, version);
138
139 return true;
140 }

◆ OnStoreSave()

override void HumanInventoryWithFSM::OnStoreSave ( ParamsWriteContext ctx)
inlineprotected

Definition at line 142 of file HumanInventoryWithFSM.c.

143 {
144 super.OnStoreSave(ctx);
145 //@TODO
146 //m_FSM.OnStoreSave(ctx, version);
147 }

◆ ProcessHandAbortEvent()

bool HumanInventoryWithFSM::ProcessHandAbortEvent ( HandEventBase e)
inlineprotected

Definition at line 114 of file HumanInventoryWithFSM.c.

115 {
116 //SyncRemote(e);
118 m_FSM.ProcessAbortEvent(e, aa);
119 if (aa == ProcessEventResult.FSM_OK)
120 {
121 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugSpam("[hndfsm] STS = " + GetManOwner().GetSimulationTimeStamp() + " Processed event e=" + e.ToString());
122 return true;
123 }
124 else
125 {
126 //if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("FSM refused to process event (no transition): src=" + GetCurrentState().ToString() + " event=" + e.ToString());
127 return false;
128 }
129 }
ProcessEventResult
Definition FSMBase.c:41
void hndDebugSpam(string s)
Definition HandFSM.c:9

References HumanInventory::GetManOwner(), hndDebugSpam(), LogManager::IsInventoryHFSMLogEnable(), and m_FSM.

◆ ProcessHandEvent()

HumanInventoryWithFSM::ProcessHandEvent ( HandEventBase e)
inlineprotected

hand's fsm handling of events @NOTE: warning: ProcessHandEvent can be called only within DayZPlayer::HandleInventory (or CommandHandler)

Definition at line 96 of file HumanInventoryWithFSM.c.

97 {
98 //SyncRemote(e);
99 if (m_FSM.ProcessEvent(e) == ProcessEventResult.FSM_OK)
100 {
101#ifdef DEVELOPER
103 Debug.InventoryHFSMLog("STS = " + GetManOwner().GetSimulationTimeStamp(), e.ToString(), "ProcessHandEvent", e.m_Player.ToString());
104#endif
105 return true;
106 }
107 else
108 {
109 //if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("FSM refused to process event (no transition): src=" + GetCurrentState().ToString() + " event=" + e.ToString());
110 return false;
111 }
112 }
Definition Debug.c:14
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:183

References HumanInventory::GetManOwner(), Debug::InventoryHFSMLog(), LogManager::IsInventoryHFSMLogEnable(), and m_FSM.

Member Data Documentation

◆ m_Empty

ref HandStateBase HumanInventoryWithFSM::m_Empty
protected

hand slot state machine

Definition at line 8 of file HumanInventoryWithFSM.c.

Referenced by CreateStableStates(), and Init().

◆ m_Equipped

ref HandStateBase HumanInventoryWithFSM::m_Equipped
protected

Definition at line 9 of file HumanInventoryWithFSM.c.

Referenced by CreateStableStates(), and Init().

◆ m_FSM


The documentation for this class was generated from the following file: