File size: 3,005 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
void hndDebugPrint (string s)
{
#ifdef INV_DEBUG
	PrintToRPT("" + s); // comment/uncomment to hide/see debug logs
#else
	//Print("" + s); // comment/uncomment to hide/see debug logs
#endif
}
void hndDebugSpam (string s)
{
#ifdef INV_DEBUG_SPAM
	PrintToRPT("" + s); // comment/uncomment to hide/see debug logs
#else
	//Print("" + s); // comment/uncomment to hide/see debug logs
#endif
}
void hndDebugSpamALot (string s)
{
#ifdef INV_DEBUG_SPAM_FREQ
	PrintToRPT("" + s); // comment/uncomment to hide/see debug logs
#else
	//Print("" + s); // comment/uncomment to hide/see debug logs
#endif
}



typedef FSMTransition<HandStateBase, HandEventBase, HandActionBase, HandGuardBase> HandTransition;


/**@class		HandFSM
 * @brief		Hand finite state machine
 **/
class HandFSM extends HFSMBase<HandStateBase, HandEventBase, HandActionBase, HandGuardBase>
{
	int GetCurrentStateID ()
	{
		/*if (m_States.Count() == 2)
		{
			int s0 = m_States[0].GetCurrentStateID();
			int s1 = m_States[1].GetCurrentStateID() << 8;
			return s1 | s0;
		}*/
		return 0;
	}

	/**@fn			SyncStateFromID
	 * @brief		load from database - reverse lookup for state from saved id
	 * @param[in]	id			the id stored in database during save
	 **/
	protected bool SyncStateFromID (int id)
	{
		/*if (id == 0)
			return false;

		int s0 = id & 0x000000ff;
		int s1 = id & 0x0000ff00;

		int count = m_Transitions.Count();
		bool set0 = false;
		bool set1 = false;
		for (int i = 0; i < count; ++i)
		{
			HandTransition t = m_Transitions.Get(i);
			if (!set0 && t.m_srcState && s0 == t.m_srcState.GetCurrentStateID())
			{
				m_States[0] = t.m_srcState;
				set0 = true;
			}
			if (!set1 && t.m_srcState && s1 == t.m_srcState.GetCurrentStateID())
			{
				m_States[1] = t.m_srcState;
				set1 = true;
			}
			if (set0 && set1)
				return true;
		}*/
		return false;
	}

	/**@fn			OnStoreLoad
	 * @brief		load state of fsm
	 **/
	bool OnStoreLoad (ParamsReadContext ctx, int version)
	{
		/*int id = 0;
		ctx.Read(id);
		if (SyncStateFromID(id))
			if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] OnStoreLoad - loaded current state from id=" + id);
		else
			Print("[hndfsm] Warning! OnStoreLoad - cannot load curent hand state, id=" + id);*/
		return true;
	}

	/**@fn			OnStoreSave
	 * @brief		save state of fsm
	 **/
	void OnStoreSave (ParamsWriteContext ctx)
	{
		/*int id = GetCurrentStateID();
		ctx.Write(id);
		if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] OnStoreSave - saving current state=" + GetCurrentState() + " id=" + id);*/
	}

	/**@fn			NetSyncCurrentStateID
	 * @brief		Engine callback - network synchronization of FSM's state. not intended to direct use.
	 **/
	void NetSyncCurrentStateID (int id)
	{
		/*if (SyncStateFromID(id))
			if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] NetSyncCurrentStateID - loaded current state from id=" + id);
		else
			Print("[hndfsm] NetSyncCurrentStateID called with null, ignoring request to set current fsm state.");*/
	}
};