8 protected int m_LastAcknowledgmentID;
9 protected bool m_ActionPossible;
17 protected int m_SelectedActionInputToSrollIndex;
21 protected bool m_ActionWantEndRequest_Send;
22 protected bool m_ActionInputWantEnd_Send;
27 m_HandInventoryLocationTest.SetHands(player,
null);
28 m_LastAcknowledgmentID = 1;
33 m_ActionWantEndRequest_Send =
false;
34 m_ActionInputWantEnd_Send =
false;
35 RegisterInputs(player);
36 m_SelectedActionInputToSrollIndex = 0;
40 override void Update(
int pCurrentCommandID)
42 m_InventoryActionHandler.OnUpdate();
43 super.Update(pCurrentCommandID);
44 int currentCommandID =
m_Player.GetCurrentCommandID();
47 if (m_PendingActionData)
56 m_PendingActionData =
null;
73 bool can_be_action_done = ((condition_mask &
m_CurrentActionData.m_Action.m_ConditionMask) == condition_mask);
75 if (m_ActionPossible && can_be_action_done && currentCommandID !=
DayZPlayerConstants.COMMANDID_SWIM)
97 ProcessActionRequestEnd();
98 ProcessActionInputEnd();
106 m_ActionPossible =
false;
107 ResetInputsActions();
114 bool isMenuOpen =
false;
118 if (
m_Player.IsRaised() || isMenuOpen)
126 FindContextualUserActions(currentCommandID);
138 if (!m_RegistredInputsMap)
142 for (
int i = 0; i < m_ActionsArray.Count(); i++)
145 typename input_type_name = action.GetInputType();
148 ai =
ActionInput.Cast(m_RegistredInputsMap.Get(input_type_name));
152 m_RegistredInputsMap.Insert(input_type_name, ai);
157 for (
int j = 0; j < m_RegistredInputsMap.Count(); j++)
159 m_RegistredInputsMap.GetElement(j).Init(player,
this);
161 SetActioninputOrder();
167 void SetActioninputOrder()
178 for (i = 0; i < m_RegistredInputsMap.Count(); i++)
180 input = m_RegistredInputsMap.GetElement(i);
181 priority = input.GetPriority();
182 same_priority_input_array = temp_map_for_sort.Get(priority);
183 if (same_priority_input_array)
185 same_priority_input_array.Insert(input);
190 same_priority_input_array.Insert(input);
191 temp_map_for_sort.Insert(priority,same_priority_input_array);
192 array_of_priorities_to_sort.Insert(priority);
194 array_of_priorities_to_sort.Sort();
196 for (i = 0; i < array_of_priorities_to_sort.Count(); i++)
198 priority = array_of_priorities_to_sort[i];
199 same_priority_input_array = temp_map_for_sort.Get(priority);
200 for (j = 0; j < same_priority_input_array.Count(); j++)
202 input = same_priority_input_array.Get(j);
203 m_OrederedAllActionInput.Insert(input);
207 SetDefaultInputsOrder();
211 void SetDefaultInputsOrder()
219 m_OrderedStandartActionInputs.Insert(input);
225 m_OrderedStandartActionInputs.Insert(input);
231 m_OrderedStandartActionInputs.Insert(input);
237 m_OrderedStandartActionInputs.Insert(input);
240 for (i = 0; i < m_OrederedAllActionInput.Count(); i++)
242 for (j = 0; j < m_OrderedStandartActionInputs.Count(); j++)
244 if (m_OrederedAllActionInput[i] == m_OrderedStandartActionInputs[j])
246 m_DefaultOrderOfActionInputs.Insert(m_OrederedAllActionInput[i]);
258 return action.GetVariantManager();
264 override void RequestEndAction()
266 if (!m_ActionWantEndRequest_Send)
272 override void EndActionInput()
274 if (!m_ActionInputWantEnd_Send)
291 if (ai.JustActivate())
307 for (
int i = 0; i < m_OrederedAllActionInput.Count();i++)
310 ain = m_OrederedAllActionInput[i];
313 if (ain.JustActivate())
318 ActionStart(action, ain.GetUsedActionTarget(), ain.GetUsedMainItem());
327 void ProcessActionRequestEnd()
343 m_ActionWantEndRequest_Send =
true;
357 void ProcessActionInputEnd()
373 m_ActionInputWantEnd_Send =
true;
381 if (!m_ActionInputWantEnd_Send)
383 m_ActionInputWantEnd_Send =
true;
391 ActionBase GetPossibleAction(
typename inputType)
393 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
396 return action_input.GetAction();
403 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
406 return action_input.GetPossibleActions();
411 int GetPossibleActionIndex(
typename inputType)
413 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
416 return action_input.GetPossibleActionIndex();
421 int GetPossibleActionCount(
typename inputType)
423 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
426 return action_input.GetPossibleActionsCount();
437 ai.ForceAction(action, target, item);
443 InjectAction(action, target, item);
449 ai.ClearForcedAction();
452 void EjectAction(
typename actionType)
458 void ForceTarget(
Object targetObject)
463 parent = targetEntity.GetHierarchyParent();
467 void ClearForceTarget()
469 m_ForceTarget = NULL;
477 return m_ForceTarget;
480 action_target = NULL;
481 int targetsCount = m_Targets.GetTargetsCount();
484 for (
int i = 0; i < targetsCount; ++i)
486 action_target = m_Targets.GetTarget(i);
487 Object targetObject = action_target.GetObject();
488 Object targetParent = action_target.GetParent();
505 return action_target;
518 protected bool HasHandInventoryReservation()
521 if (
m_Player.GetHumanInventory().HasInventoryReservation(
m_Player.GetItemInHands(),m_HandInventoryLocationTest))
526 protected void FindContextualUserActions(
int pCurrentCommandID)
531 if (!m_ActionPossible || HasHandInventoryReservation() ||
GetGame().IsInventoryOpen())
533 ResetInputsActions();
546 item = FindActionItem();
547 target = FindActionTarget();
550 for (
int i = 0; i < m_OrederedAllActionInput.Count();i++)
553 ain.UpdatePossibleActions(
m_Player,target,item, actionConditionMask);
560 protected bool LockInventory(
ActionData action_data)
562 bool success =
false;
563 if (action_data.m_Action.IsInstant())
567 Debug.ActionLog(
"(-) Inventory lock - Not Used", action_data.m_Action.ToString() ,
"n/a",
"LockInventory", action_data.m_Player.ToString());
575 Debug.ActionLog(
"(X) Inventory lock", action_data.m_Action.ToString() ,
"n/a",
"LockInventory", action_data.m_Player.ToString());
577 if (action_data.m_Action)
579 success = action_data.m_Action.InventoryReservation(action_data);
588 Debug.ActionLog(
"(O) Inventory unlock", action_data.m_Action.ToString() ,
"n/a",
"UnlockInventory", action_data.m_Player.ToString());
590 if (action_data.m_Action)
591 action_data.m_Action.ClearInventoryReservationEx(action_data);
598 m_ActionWantEndRequest_Send =
false;
599 m_ActionInputWantEnd_Send =
false;
603 if (action.CanBePerformedFromQuickbar())
606 HandleInputsOnActionStart(action);
612 Debug.ActionLog(
"Item = " + item +
", " + target.DumpToString(), action.ToString() ,
"n/a",
"ActionStart",
m_Player.ToString());
616 Debug.ActionLog(
"Item = " + item +
", no target", action.ToString() ,
"n/a",
"ActionStart",
m_Player.ToString());
620 if (
GetGame().IsMultiplayer() && !action.IsLocal())
624 DPrint(
"ScriptInputUserData already posted - ActionManagerClient");
628 Debug.ActionLog(
"Cannot start because ScriptInputUserData is already used", action.ToString() ,
"n/a",
"ActionStart",
m_Player.ToString());
636 DPrint(
"Can not inicialize action" + action +
" - ActionManagerClient");
643 Debug.ActionLog(
"Action data created wait to start", action.ToString() ,
"n/a",
"ActionStart",
m_Player.ToString());
646 if (
GetGame().IsMultiplayer() && !action.IsLocal())
650 ctx.Write(action.GetID());
654 if (action.UseAcknowledgment())
664 if (!action.UseAcknowledgment())
667 if (action.IsInstant())
674 if (action.IsInstant())
680 void HandleInputsOnActionStart(
ActionBase action)
682 for (
int i = 0; i < m_OrederedAllActionInput.Count();i++)
685 if (action.GetInput() == ain)
696 void HandleInputsOnActionEnd()
701 void ResetInputsState()
703 for (
int i = 0; i < m_OrederedAllActionInput.Count();i++)
710 void ResetInputsActions()
712 for (
int i = 0; i < m_OrederedAllActionInput.Count();i++)
715 ain.ActionsSelectReset();
719 override void OnJumpStart()
736 override void OnInstantAction(
typename user_action_type,
Param data = NULL)
741 ActionStart(action,NULL,NULL, data);
749 ActionStart(
GetAction(user_action_id), target, item, extraData);
755 if (!
GetGame().IsMultiplayer())
759 if (!action.SetupAction(
m_Player,target,item,m_PendingActionData,extra_data))
760 m_PendingActionData =
null;
763 ActionStart(action, target, item, extra_data);
766 override void OnActionEnd()
772 m_InventoryActionHandler.DeactiveAction();
775 HandleInputsOnActionEnd();
781 m_InventoryActionHandler.SetAction(action_name, target_item, main_item);
786 m_InventoryActionHandler.SetAction(action_name, target, main_item);
789 void UnsetInventoryAction()
791 m_InventoryActionHandler.DeactiveAction();
794 override typename GetSelectedActionCategory()
796 return m_OrderedStandartActionInputs[m_SelectedActionInputToSrollIndex].Type();
799 void UpdateActionCategoryPriority()
802 int last_target_index = 0;
803 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
805 if (m_DefaultOrderOfActionInputs[i].
HasTarget())
807 m_OrderedStandartActionInputs[last_target_index] = m_DefaultOrderOfActionInputs[i];
812 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
814 if (!m_DefaultOrderOfActionInputs[i].
HasTarget())
816 m_OrderedStandartActionInputs[last_target_index] = m_DefaultOrderOfActionInputs[i];
822 override void SelectFirstActionCategory()
824 UpdateActionCategoryPriority();
825 m_SelectedActionInputToSrollIndex = 0;
827 for (
int index = 0; index < m_OrderedStandartActionInputs.Count(); index++)
831 m_SelectedActionInputToSrollIndex = index;
837 override void SelectNextActionCategory()
841 for (index = m_SelectedActionInputToSrollIndex + 1; index != m_SelectedActionInputToSrollIndex;;)
843 if (++index >= m_OrderedStandartActionInputs.Count())
849 m_SelectedActionInputToSrollIndex = index;
855 override void SelectPrevActionCategory()
859 for (index = m_SelectedActionInputToSrollIndex; index != m_SelectedActionInputToSrollIndex;;)
863 index = m_OrderedStandartActionInputs.Count() - 1;
868 m_SelectedActionInputToSrollIndex = index;
875 override void SelectNextAction()
878 if (m_SelectedActionInputToSrollIndex < m_OrderedStandartActionInputs.Count())
880 ai = m_OrderedStandartActionInputs[m_SelectedActionInputToSrollIndex];
881 if (ai && ai.GetPossibleActionsCount() > 1)
883 ai.SelectNextAction();
888 override void SelectPrevAction()
891 if (m_SelectedActionInputToSrollIndex < m_OrderedStandartActionInputs.Count())
893 ai = m_OrderedStandartActionInputs[m_SelectedActionInputToSrollIndex];
894 if (ai && ai.GetPossibleActionsCount() > 1)
896 ai.SelectPrevAction();
906 bool hasTarget = targetItem != NULL;
917 for (i = 0; i < actions.Count(); i++)
920 if (picked_action && picked_action.Can(
m_Player,target, itemInHand))
922 if (hasTarget == picked_action.HasTarget())
931 for (i = 0; i < actions.Count(); i++)
934 if (picked_action && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
936 if (hasTarget == picked_action.HasTarget())
945 for (i = 0; i < actions.Count(); i++)
948 if (picked_action && picked_action.HasTarget() && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
950 if (hasTarget == picked_action.HasTarget())
965 parent =
ItemBase.Cast(targetItem.GetHierarchyParent());
967 bool hasTarget = targetItem != NULL;
978 for (i = 0; i < actions.Count(); i++)
981 if (picked_action && picked_action.HasTarget() && picked_action.Can(
m_Player,target, itemInHand))
983 if (hasTarget == picked_action.HasTarget())
985 ActionStart(picked_action, target, mainItem);
996 for (i = 0; i < actions.Count(); i++)
999 if (picked_action && picked_action.HasTarget() && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
1001 if (hasTarget == picked_action.HasTarget())
1003 ActionStart(picked_action, target, mainItem);
1013 for (i = 0; i < actions.Count(); i++)
1016 if (picked_action && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
1018 if (hasTarget == picked_action.HasTarget())
1020 ActionStart(picked_action, target, mainItem);
1036 bool hasTarget = targetItem != NULL;
1048 for (i = 0; i < actions.Count(); i++)
1051 if (picked_action && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1053 if (hasTarget == picked_action.HasTarget())
1063 for (i = 0; i < actions.Count(); i++)
1066 if (picked_action && picked_action.Can(
m_Player,target, itemInHand))
1068 if (hasTarget == picked_action.HasTarget())
1083 bool hasTarget = targetItem != NULL;
1095 for (i = 0; i < actions.Count(); i++)
1098 if (picked_action && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1100 if (hasTarget == picked_action.HasTarget())
1102 ActionStart(picked_action, target, mainItem);
1113 for (i = 0; i < actions.Count(); i++)
1116 if (picked_action && picked_action.Can(
m_Player,target, itemInHand))
1118 if (hasTarget == picked_action.HasTarget())
1120 ActionStart(picked_action, target, mainItem);
1136 parent = targetItem.GetHierarchyParent();
1139 bool hasTarget = targetItem != NULL;
1146 int variants_count,v;
1152 for (
int i = 0; i < actions.Count(); i++)
1155 if (picked_action.HasVariants())
1157 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1158 picked_action.GetVariants(variant_actions);
1159 for (v = 0; v < variant_actions.Count(); v ++)
1161 picked_action = variant_actions[v];
1162 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(
m_Player,target, itemInHand))
1164 if (hasTarget == picked_action.HasTarget())
1171 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(
m_Player,target, itemInHand))
1173 if (hasTarget == picked_action.HasTarget())
1183 for (
int j = 0; j < actions.Count(); j++)
1186 if (picked_action.HasVariants())
1188 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1189 picked_action.GetVariants(variant_actions);
1190 for (v = 0; v < variant_actions.Count(); v ++)
1192 picked_action = variant_actions[v];
1193 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(
m_Player,target, itemInHand))
1195 if (hasTarget == picked_action.HasTarget())
1202 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(
m_Player,target, itemInHand))
1204 if (hasTarget == picked_action.HasTarget())
1220 bool hasTarget = targetItem != NULL;
1231 for (
int i = 0; i < actions.Count(); i++)
1234 if (picked_action && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1236 if (hasTarget == picked_action.HasTarget())
1238 SetInventoryAction(picked_action, target, itemInHand);
1248 for (
int j = 0; j < actions.Count(); j++)
1251 if (picked_action && picked_action.HasTarget() && picked_action.Can(
m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1253 if (hasTarget == picked_action.HasTarget())
1255 SetInventoryAction(picked_action, target, itemInHand);
1264 override void Interrupt()
1273 void RequestInterruptAction()