Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionunfoldmap.c
Go to the documentation of this file.
2 {
3  bool m_MapFolding;
4  bool m_HasReceivedEvent;
5  bool m_CancelCondition;
6  int m_InitMovementState;
7  int m_FinalMovementState;
8 
9  void ActionUnfoldMapCB()
10  {
14  }
15 
16  void ~ActionUnfoldMapCB()
17  {
18  if (GetGame() && GetGame().GetMission())
19  {
20  if (!CfgGameplayHandler.GetUse3DMap())
21  {
22  GetGame().GetMission().RemoveActiveInputExcludes({"map"}, false);
23  }
24  else
25  {
26  GetGame().GetMission().RemoveActiveInputExcludes({"loopedactions"}, false);
27  }
28  GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
29  }
30 
31  if (!m_ActionData || !m_ActionData.m_Player)
32  return;
33 
34  ItemMap chernomap = ItemMap.Cast(m_ActionData.m_Player.GetItemInHands());
35  if (chernomap && m_ActionData.m_Player.IsMapOpen())
36  {
37  chernomap.SetMapStateOpen(false, m_ActionData.m_Player);
38  }
39  }
40 
41  override void SetActionData(ActionData action_data)
42  {
43  m_ActionData = action_data;
44  m_InitMovementState = m_ActionData.m_Player.m_MovementState.m_iStanceIdx;
45  }
46 
47  bool CancelCondition()
48  {
49  return m_CancelCondition;
50  }
51 
52  override void OnStateChange(int pOldState, int pCurrentState)
53  {
54  if (!m_ActionData || !m_ActionData.m_Player)
55  return;
56 
57  if ((pOldState == STATE_LOOP_IN && pCurrentState == STATE_LOOP_LOOP) && !m_HasReceivedEvent)
58  {
59  m_CancelCondition = true;
60  }
61  }
62 
63  override void OnAnimationEvent(int pEventID)
64  {
65  if (!m_ActionData || !m_ActionData.m_Player)
66  return;
67 
68  switch (pEventID)
69  {
70  case UA_ANIM_EVENT:
71  m_HasReceivedEvent = true;
72  m_FinalMovementState = m_ActionData.m_Player.m_MovementState.m_iStanceIdx;
73 
74  if (StateCheck())
75  {
76  PerformMapChange();
77  m_CancelCondition = false;
78  }
79  else
80  {
81  m_CancelCondition = true;
82  }
83  break;
84  }
85  }
86 
87  override void OnFinish(bool pCanceled)
88  {
89  if (m_ActionData && m_ActionData.m_Player)
90  {
91  if (m_ActionData && m_ActionData.m_ActionComponent)
92  m_ActionData.m_State = m_ActionData.m_ActionComponent.Interrupt(m_ActionData);
93 
94  if ((!GetGame().IsDedicatedServer()) && GetGame().GetUIManager() && GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
95  {
96  GetGame().GetUIManager().FindMenu(MENU_MAP).Close();
97  }
98 
99  ActionUnfoldMap action = ActionUnfoldMap.Cast(m_ActionData.m_Action);
100  m_InitMovementState = -1;
102 
103  m_ActionData.m_Player.SetMapClosingSyncSet(false); //reset
104 
105  ItemMap chernomap = ItemMap.Cast(m_ActionData.m_Player.GetItemInHands());
106  if (chernomap && m_ActionData.m_Player.IsMapOpen())
107  {
108  chernomap.SetMapStateOpen(false, m_ActionData.m_Player);
109  }
110 
111  if (action)
112  action.End(m_ActionData);
113  }
114  }
115 
116  void PerformMapChange()
117  {
118  if (m_ActionData.m_Player.IsSwimming() || m_ActionData.m_Player.IsClimbing() || m_ActionData.m_Player.IsFalling() || m_ActionData.m_Player.IsClimbingLadder() || m_ActionData.m_Player.IsUnconscious() || m_ActionData.m_Player.IsRestrained())
119  return;
120 
121  ItemMap chernomap = ItemMap.Cast(m_ActionData.m_Player.GetItemInHands());
122  if (chernomap)
123  {
124  if (!m_ActionData.m_Player.IsMapOpen() && !m_MapFolding)
125  {
126  if (m_CancelCondition) //do not open when cancelling in progress
127  return;
128 
129  chernomap.SetMapStateOpen(true, m_ActionData.m_Player);
130 
131  if (!GetGame().IsMultiplayer() || GetGame().IsServer())
132  {
133  //chernomap.SyncMapMarkers();
134  }
135 
136  if (!GetGame().IsDedicatedServer())
137  {
138  UIManager m_UIManager;
139  UIScriptedMenu mapMenu;
140  m_UIManager = GetGame().GetUIManager();
141  m_UIManager.CloseAll();
142  if (!CfgGameplayHandler.GetUse3DMap())
143  {
144  mapMenu = m_UIManager.EnterScriptedMenu(MENU_MAP, null);
145  mapMenu.InitMapItem(chernomap);
146  mapMenu.LoadMapMarkers();
147  GetGame().GetMission().AddActiveInputExcludes({"map"});
148  }
149  else
150  {
151  GetGame().GetMission().AddActiveInputExcludes({"loopedactions"});
152  }
153 
154  GetGame().GetMission().AddActiveInputRestriction(EInputRestrictors.MAP);
155  }
156  }
157  else if (m_ActionData.m_Player.IsMapOpen())
158  {
159  chernomap.SetMapStateOpen(false, m_ActionData.m_Player);
160  m_MapFolding = true;
161  m_ActionData.m_Player.SetMapOpen(false);
162  }
163  }
164  }
165 
166  bool StateCheck()
167  {
169  }
170 }
171 
173 {
175  {
176  m_Text = "#unfold_map";
177  }
178 
179  override bool IsInstant()
180  {
181  return false;
182  }
183 
185  {
187  m_ConditionTarget = new CCTNone();
188  }
189 
190  override bool HasTarget()
191  {
192  return false;
193  }
194 
195  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
196  {
197  if (player.m_hac || player.IsMapOpen())
198  {
199  return false;
200  }
201  return true;
202  }
203 
204  override int GetActionCategory()
205  {
206  return AC_SINGLE_USE;
207  }
208 
209  override void OnStartClient(ActionData action_data)
210  {
211  OpenMap(action_data);
212  }
213 
214  override void OnStartServer(ActionData action_data)
215  {
216  OpenMap(action_data);
217  ItemMap chernomap = ItemMap.Cast(action_data.m_MainItem);
218  chernomap.SyncMapMarkers();
219  }
220 
221  override void OnEndRequest(ActionData action_data)
222  {
223  action_data.m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
224  action_data.m_State = UA_FINISHED;
225  }
226 
227  override void Interrupt(ActionData action_data)
228  {
229  if (action_data.m_Player.m_hac)
230  {
231  action_data.m_Player.m_hac.m_MapFolding = true;
232  action_data.m_Player.m_hac.PerformMapChange();
233  action_data.m_Player.m_hac.Cancel();
234  }
235  else //should never get here, End called from the callback
236  {
237  End(action_data);
238  }
239  }
240 
241  void OpenMap(ActionData action_data)
242  {
243  if (!action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE))
244  {
245  action_data.m_Player.m_hac = ActionUnfoldMapCB.Cast(action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_VIEWMAP,ActionUnfoldMapCB));
246  }
247  else
248  {
249  action_data.m_Player.m_hac = ActionUnfoldMapCB.Cast(action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_VIEWMAP,ActionUnfoldMapCB,DayZPlayerConstants.STANCEMASK_PRONE));
250  }
251 
252  // sets player for associated callback to use
253  if (action_data.m_Player.m_hac)
254  {
255  action_data.m_Player.m_hac.SetActionData(action_data);
256  action_data.m_Callback = action_data.m_Player.m_hac;
257  }
258  }
259 };
ItemBase
Definition: inventoryitem.c:730
End
void End()
called on surrender end request end
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
CreateConditionComponents
override void CreateConditionComponents()
Definition: actionunfoldmap.c:184
OnStartClient
override void OnStartClient(ActionData action_data)
Definition: actionunfoldmap.c:209
MENU_MAP
const int MENU_MAP
Definition: constants.c:181
m_FinalMovementState
int m_FinalMovementState
Definition: actionunfoldmap.c:6
ItemMap
Definition: chernarusmap_open.c:1
IsInstant
override bool IsInstant()
Definition: actionunfoldmap.c:179
UA_ANIM_EVENT
const int UA_ANIM_EVENT
Definition: constants.c:443
GetActionCategory
override int GetActionCategory()
Definition: actionunfoldmap.c:204
HasTarget
override bool HasTarget()
Definition: actionunfoldmap.c:190
m_InitMovementState
int m_InitMovementState
Definition: actionunfoldmap.c:5
EnableCancelCondition
proto native void EnableCancelCondition(bool pEnable)
EnableStateChangeCallback
proto native void EnableStateChangeCallback()
enables state change callback OnStateChange
Interrupt
override void Interrupt(ActionData action_data)
Definition: actionunfoldmap.c:227
CCTNone
Definition: cctnone.c:1
OnEndRequest
override void OnEndRequest(ActionData action_data)
Definition: actionunfoldmap.c:221
UIManager
Definition: uimanager.c:1
PlayerBase
Definition: playerbaseclient.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
RegisterAnimationEvent
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ActionUnfoldMapCB
Definition: actionunfoldmap.c:1
OpenMap
void OpenMap(ActionData action_data)
Definition: actionunfoldmap.c:241
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
AC_SINGLE_USE
const int AC_SINGLE_USE
Definition: _constants.c:2
ActionBase
void ActionBase()
Definition: actionbase.c:73
ActionUnfoldMap
ActionUnfoldMapCB ActionBaseCB ActionUnfoldMap()
Definition: actionunfoldmap.c:174
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionunfoldmap.c:195
OnStartServer
override void OnStartServer(ActionData action_data)
Definition: actionunfoldmap.c:214
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
ActionBaseCB
Definition: animatedactionbase.c:1
m_MapFolding
bool m_MapFolding
Definition: actionunfoldmap.c:2
m_HasReceivedEvent
bool m_HasReceivedEvent
Definition: actionunfoldmap.c:3
m_CancelCondition
bool m_CancelCondition
Definition: actionunfoldmap.c:4