DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionManagerClient.c
См. документацию.
3
5{
6
7 //Last send AcknowledgmentID (client can send more requests before recive ackfor first action)
8 protected int m_LastAcknowledgmentID;
9 protected bool m_ActionPossible;
18 protected bool m_IgnoreAutoInputEnd;
19
21
22 protected bool m_ActionWantEndRequest_Send; //Request to server was sended
24
26 {
28 m_HandInventoryLocationTest.SetHands(player,null);
30 m_Targets = new ActionTargets(player);
31 //m_ReservedInventoryLocations = new array<ref InventoryLocation>;
33
36 RegisterInputs(player);
38 }
39
40 //pCurrentCommandID is command ID at time of call command handler, some called methods can change actual true value (need call m_Player.GetCurrentCommandID() for actual command ID)
41 override void Update(int pCurrentCommandID)
42 {
43 m_InventoryActionHandler.OnUpdate();
44 super.Update(pCurrentCommandID);
45 int currentCommandID = m_Player.GetCurrentCommandID();
46 m_ActionPossible = ActionPossibilityCheck(currentCommandID);
47
48 if (m_PendingActionData) //SP only
49 {
51
53
54 if (m_CurrentActionData.m_Action.IsInstant())
56
58 }
59
61 {
63 m_CurrentActionData.m_Action.OnUpdateClient(m_CurrentActionData);
64
65 switch (m_CurrentActionData.m_State)
66 {
67 case UA_AM_PENDING:
68 break;
69
70 case UA_AM_ACCEPTED:
71 int condition_mask = ActionBase.ComputeConditionMask(m_Player, m_CurrentActionData.m_Target, m_CurrentActionData.m_MainItem);
72
73 m_CurrentActionData.m_Action.ClearInventoryReservationEx(m_CurrentActionData);
74 bool can_be_action_done = ((condition_mask & m_CurrentActionData.m_Action.m_ConditionMask) == condition_mask);
75 // check currentCommandID before start or reject
76 if (m_ActionPossible && can_be_action_done)
77 {
78 m_CurrentActionData.m_Action.InventoryReservation(m_CurrentActionData);
81
82 if (m_CurrentActionData.m_Action.IsInstant())
84 }
85 else
86 {
89 }
91 break;
92
93 case UA_AM_REJECTED:
96 break;
97
98 default:
101 break;
102 }
103 }
104
105#ifdef DEVELOPER
107 {
108 m_ActionPossible = false;
110 }
111 else
112 {
113#endif
115 {
116 bool isMenuOpen = false;
117#ifndef NO_GUI
119#endif
120 if (m_Player.IsRaised() || isMenuOpen)
121 {
122 m_Targets.Clear();
123 }
124 else
125 {
126 m_Targets.Update();
127 }
128 FindContextualUserActions(currentCommandID);
129 }
130
131 InputsUpdate();
132#ifdef DEVELOPER
133 }
134#endif
135
136 }
137
139 {
141 {
143
144 for (int i = 0; i < m_ActionsArray.Count(); i++)
145 {
146 ActionBase action = m_ActionsArray.Get(i);
147 typename input_type_name = action.GetInputType();
148 ref ActionInput ai;
149
150 ai = ActionInput.Cast(m_RegistredInputsMap.Get(input_type_name));
151 if (!ai)
152 {
153 ai = ActionInput.Cast(input_type_name.Spawn());
154 m_RegistredInputsMap.Insert(input_type_name, ai);
155 }
156 action.SetInput(ai);
157 }
158
159 for (int j = 0; j < m_RegistredInputsMap.Count(); j++)
160 {
161 m_RegistredInputsMap.GetElement(j).Init(player, this);
162 }
164 }
165
166 }
167
168 //Set order of inputs base of priority (output -> m_OrederedAllActionInput)
170 {
171 int i, j;
172 int priority;
173 ActionInput input;
175
177 array<int> array_of_priorities_to_sort = new array<int>;
178 ref array<ActionInput> same_priority_input_array;
179
180 for (i = 0; i < m_RegistredInputsMap.Count(); i++)
181 {
182 input = m_RegistredInputsMap.GetElement(i);
183 priority = input.GetPriority();
184 same_priority_input_array = temp_map_for_sort.Get(priority);
185 if (same_priority_input_array)
186 {
187 same_priority_input_array.Insert(input);
188 continue;
189 }
190
191 same_priority_input_array = new array<ActionInput>;
192 same_priority_input_array.Insert(input);
193 temp_map_for_sort.Insert(priority,same_priority_input_array);
194 array_of_priorities_to_sort.Insert(priority);
195 }
196 array_of_priorities_to_sort.Sort();
197
198 for (i = 0; i < array_of_priorities_to_sort.Count(); i++)
199 {
200 priority = array_of_priorities_to_sort[i];
201 same_priority_input_array = temp_map_for_sort.Get(priority);
202 for (j = 0; j < same_priority_input_array.Count(); j++)
203 {
204 input = same_priority_input_array.Get(j);
205 m_OrederedAllActionInput.Insert(input);
206 }
207 }
208
210 }
211
212 //Order for user action inputs - will be dynamically change base on context (more complex handling viz set m_OrderedStandartActionInputs in UpdateActionCategoryPriority())
214 {
215 int i, j;
219 if (input)
220 {
221 m_OrderedStandartActionInputs.Insert(input);
222 }
223
225 if (input)
226 {
227 m_OrderedStandartActionInputs.Insert(input);
228 }
229
231 if (input)
232 {
233 m_OrderedStandartActionInputs.Insert(input);
234 }
235
237 if (input)
238 {
239 m_OrderedStandartActionInputs.Insert(input);
240 }
241
242 for (i = 0; i < m_OrederedAllActionInput.Count(); i++)
243 {
244 for (j = 0; j < m_OrderedStandartActionInputs.Count(); j++)
245 {
247 {
249 break;
250 }
251 }
252 }
253 }
254
255 static ActionVariantManager GetVariantManager(typename actionName)
256 {
257 ActionBase action = GetAction(actionName);
258 if (action)
259 {
260 return action.GetVariantManager();
261 }
262 //VME ACTION not exist typo most likely
263 return null;
264 }
265
266 override void RequestEndAction()
267 {
269 {
271 }
272 }
273
274 override void EndActionInput()
275 {
277 {
279 }
280 }
281
283 {
284 ActionInput ain;
286 {
288 {
289 ActionInput ai = m_CurrentActionData.m_Action.GetInput();
290 ai.Update();
291 if (m_Player.IsQBControl())
292 {
293 if (ai.JustActivate())
294 m_Player.SetActionEndInput(m_CurrentActionData.m_Action);
295 }
296 else
297 {
298 if (ai.WasEnded() && (ai.GetInputType() == ActionInputType.AIT_CONTINUOUS || ai.GetInputType() == ActionInputType.AIT_CLICKCONTINUOUS) && !m_IgnoreAutoInputEnd)
299 {
301 }
302 }
303 }
304 }
305 else
306 {
308 {
309 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
310 {
311
313 ain.Update();
314
315 if (ain.JustActivate())
316 {
317 ActionBase action = ain.GetAction();
318 if (action)
319 {
320 ActionStart(action, ain.GetUsedActionTarget(), ain.GetUsedMainItem());
321 break;
322 }
323 }
324 }
325 }
326 }
327 }
328
330 {
332 {
333 if (GetGame().IsMultiplayer() && !m_CurrentActionData.m_Action.IsLocal())
334 {
336 {
338 {
339 Debug.ActionLog("Time stamp: " + m_Player.GetSimulationTimeStamp(), m_CurrentActionData.m_Action.ToString() , "n/a", "EndRequest", m_CurrentActionData.m_Player.ToString());
340 }
343 ctx.Send();
344
346
348 m_CurrentActionData.m_Action.EndRequest(m_CurrentActionData);
349 }
350 }
351 else
352 {
354 m_CurrentActionData.m_Action.EndRequest(m_CurrentActionData);
355 }
356 }
357 }
358
360 {
362 {
363 if (GetGame().IsMultiplayer() && !m_CurrentActionData.m_Action.IsLocal())
364 {
366 {
368 {
369 Debug.ActionLog("Time stamp: " + m_Player.GetSimulationTimeStamp(), m_CurrentActionData.m_Action.ToString() , "n/a", "EndInput", m_CurrentActionData.m_Player.ToString());
370 }
373 ctxi.Send();
374
376
377 m_ActionInputWantEnd = false;
378 m_CurrentActionData.m_Action.EndInput(m_CurrentActionData);
379 }
380 }
381 else
382 {
384 {
386 m_ActionInputWantEnd = false;
387 m_CurrentActionData.m_Action.EndInput(m_CurrentActionData);
388 }
389 }
390 }
391 }
392
393 ActionBase GetPossibleAction(typename inputType)
394 {
395 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
396 if (action_input)
397 {
398 return action_input.GetAction();
399 }
400 return NULL;
401 }
402
404 {
405 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
406 if (action_input)
407 {
408 return action_input.GetPossibleActions();
409 }
410 return NULL;
411 }
412
413 int GetPossibleActionIndex(typename inputType)
414 {
415 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
416 if (action_input)
417 {
418 return action_input.GetPossibleActionIndex();
419 }
420 return -1;
421 }
422
423 int GetPossibleActionCount(typename inputType)
424 {
425 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
426 if (action_input)
427 {
428 return action_input.GetPossibleActionsCount();
429 }
430 return 0;
431 }
432
433 //--------------------------------------------------------
434 // Alows to set different action to current contextual one
435 //--------------------------------------------------------
436 void InjectAction(ActionBase action, ActionTarget target, ItemBase item)
437 {
438 ActionInput ai = action.GetInput();
439 ai.ForceAction(action, target, item);
440 }
441
442 void InjectAction(typename actionType, ActionTarget target, ItemBase item)
443 {
444 ActionBase action = GetAction(actionType);
445 InjectAction(action, target, item);
446 }
447
449 {
450 ActionInput ai = action.GetInput();
452 }
453
454 void EjectAction(typename actionType)
455 {
456 ActionBase action = GetAction(actionType);
457 EjectAction(action);
458 }
459
460 void ForceTarget(Object targetObject)
461 {
462 Object parent = null;
463 EntityAI targetEntity = EntityAI.Cast(targetObject);
464 if (targetEntity)
465 parent = targetEntity.GetHierarchyParent();
466 m_ForceTarget = new ActionTarget(targetObject, parent, -1, vector.Zero, -1);
467 }
468
470 {
471 m_ForceTarget = NULL;
472 }
473
474
475 //-------------------------------------------------------------------------
477 {
478 if (m_ForceTarget)
479 return m_ForceTarget;
480
481 ActionTarget action_target;
482 action_target = NULL;
483 int targetsCount = m_Targets.GetTargetsCount();
484 if (targetsCount)
485 {
486 for (int i = 0; i < targetsCount; ++i)
487 {
488 action_target = m_Targets.GetTarget(i);
489 Object targetObject = action_target.GetObject();
490 Object targetParent = action_target.GetParent();
491
492 if (targetParent)
493 {
494 break;
495 }
496
497 if (targetObject)
498 {
499 break;
500 }
501 }
502 }
503 else
504 {
505 action_target = new ActionTarget(null, null, -1, vector.Zero, -1);
506 }
507 return action_target;
508 }
509
511 {
512 ItemBase item;
513 if (m_Player && m_Player.GetItemInHands() && m_Player.GetItemInHands().IsItemBase())
514 {
515 item = m_Player.GetItemInHands();
516 }
517 return item;
518 }
519
521 {
522 m_HandInventoryLocationTest.SetHands(m_Player,m_Player.GetItemInHands());
523 if (m_Player.GetHumanInventory().HasInventoryReservation(m_Player.GetItemInHands(),m_HandInventoryLocationTest))
524 return true;
525 return false;
526 }
527
528 protected void FindContextualUserActions(int pCurrentCommandID)
529 {
530 // TODO: NEEDS OPTIMIZATION (focus on UpdatePossibleActions > CraftingManager::OnUpdate)
531
532 m_ActionsAvaibale = false;
533 if (!m_ActionPossible || HasHandInventoryReservation() || GetGame().IsInventoryOpen())
534 {
536 return;
537 }
538
539 if (!GetRunningAction())
540 {
541 ActionBase action;
542 ActionTarget target;
543 ItemBase item;
544
545 // Gathering current inputs
546 m_ActionsAvaibale = true;
547
548 item = FindActionItem();
549 target = FindActionTarget();
550
551 int actionConditionMask = ActionBase.ComputeConditionMask(m_Player,target,item);
552 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
553 {
555 ain.UpdatePossibleActions(m_Player,target,item, actionConditionMask);
556 }
557
559 SetActionContext(target,item);
560 }
561 }
562
563 //TOOD MW In progress
564 protected bool LockInventory(ActionData action_data)
565 {
566 bool success = false;
567 if (action_data.m_Action.IsInstant())
568 {
570 {
571 Debug.ActionLog("(-) Inventory lock - Not Used", action_data.m_Action.ToString() , "n/a", "LockInventory", action_data.m_Player.ToString());
572 }
573 success = true;
574 }
575 else
576 {
578 {
579 Debug.ActionLog("(X) Inventory lock", action_data.m_Action.ToString() , "n/a", "LockInventory", action_data.m_Player.ToString());
580 }
581 if (action_data.m_Action)
582 {
583 success = action_data.m_Action.InventoryReservation(action_data);
584 }
585 }
586 return success;
587 }
588 void UnlockInventory(ActionData action_data)
589 {
591 {
592 Debug.ActionLog("(O) Inventory unlock", action_data.m_Action.ToString() , "n/a", "UnlockInventory", action_data.m_Player.ToString());
593 }
594 if (action_data.m_Action)
595 action_data.m_Action.ClearInventoryReservationEx(action_data);
596 }
597
598 protected void ActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data = NULL)
599 {
600 if (!m_CurrentActionData && action && ActionPossibilityCheck(m_Player.GetCurrentCommandID()))
601 {
605 m_ActionInputWantEnd = false;
606
607 if (action.CanBePerformedFromQuickbar())
608 m_Player.SetActionEndInput(action);
609
611
613 {
614 if ( target )
615 {
616 Debug.ActionLog("Item = " + item + ", " + target.DumpToString(), action.ToString() , "n/a", "ActionStart", m_Player.ToString());
617 }
618 else
619 {
620 Debug.ActionLog("Item = " + item + ", no target", action.ToString() , "n/a", "ActionStart", m_Player.ToString());
621 }
622 }
623 m_Interrupted = false;
624 if (GetGame().IsMultiplayer() && !action.IsLocal())
625 {
627 {
628 DPrint("ScriptInputUserData already posted - ActionManagerClient");
629
631 {
632 Debug.ActionLog("Cannot start because ScriptInputUserData is already used", action.ToString() , "n/a", "ActionStart", m_Player.ToString());
633 }
634 return;
635 }
636 }
637
638 if (!action.SetupAction(m_Player, target, item, m_CurrentActionData, extra_data))
639 {
640 DPrint("Can not inicialize action" + action + " - ActionManagerClient");
641 m_CurrentActionData = NULL;
642 return;
643 }
644
646 {
647 Debug.ActionLog("Action data created wait to start", action.ToString() , "n/a", "ActionStart", m_Player.ToString());
648 }
649
650 if (GetGame().IsMultiplayer() && !action.IsLocal())
651 {
654 ctx.Write(action.GetID());
655
657
658 if (action.UseAcknowledgment())
659 {
662
664 }
665
666 ctx.Send();
667
668 if (!action.UseAcknowledgment())
669 {
671 if (action.IsInstant())
672 OnActionEnd();
673 }
674 }
675 else
676 {
678 if (action.IsInstant())
679 OnActionEnd();
680 }
681 }
682 }
683
685 {
686 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
687 {
689 if (action.GetInput() == ain)
690 {
691 ain.OnActionStart();
692 }
693 else
694 {
695 ain.Reset();
696 }
697 }
698 }
699
701 {
703 }
704
706 {
707 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
708 {
710 ain.Reset();
711 }
712 }
713
715 {
716 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
717 {
719 ain.ActionsSelectReset();
720 }
721 }
722
723 override void OnJumpStart()
724 {
726 }
727
729 {
731 {
733 {
734 OnActionEnd();
736 }
737 else
738 {
739 m_CurrentActionData.m_Action.Interrupt(m_CurrentActionData);
740 }
741 }
742 }
743
744 //Instant Action (Debug Actions) ---------------------------------
745 override void OnInstantAction(typename user_action_type, Param data = NULL)
746 {
747 ActionBase action = GetAction(user_action_type);
748 if (action)
749 {
750 ActionStart(action,NULL,NULL, data);
751 }
752 }
753
754#ifdef BOT
756 void PerformAction(int user_action_id, ActionTarget target, ItemBase item, Param extraData = NULL)
757 {
758 ActionStart(GetAction(user_action_id), target, item, extraData);
759 }
760#endif
761
762 void PerformActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data = NULL)
763 {
764 if (!GetGame().IsMultiplayer())
765 {
767
768 if (!action.SetupAction(m_Player,target,item,m_PendingActionData,extra_data))
769 m_PendingActionData = null;
770 }
771 else
772 ActionStart(action, target, item, extra_data);
773 }
774
775 override void OnActionEnd()
776 {
778 {
780 if (m_CurrentActionData.m_Action.RemoveForceTargetAfterUse())
781 m_InventoryActionHandler.DeactiveAction();
782
783 super.OnActionEnd();
785 }
786 }
787
788 void SetInventoryAction(ActionBase action_name, ItemBase target_item, ItemBase main_item)
789 {
790 m_InventoryActionHandler.SetAction(action_name, target_item, main_item);
791 }
792
793 void SetInventoryAction(ActionBase action_name, ActionTarget target, ItemBase main_item)
794 {
795 m_InventoryActionHandler.SetAction(action_name, target, main_item);
796 }
797
799 {
800 m_InventoryActionHandler.DeactiveAction();
801 }
802
807
809 {
810 int i;
811 int last_target_index = 0;
812 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
813 {
815 {
817 last_target_index++;
818 }
819 }
820
821 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
822 {
824 {
826 last_target_index++;
827 }
828 }
829 }
830
832 {
835
836 for (int index = 0; index < m_OrderedStandartActionInputs.Count(); index++)
837 {
839 {
841 break;
842 }
843 }
844 }
845
847 {
848 int index;
849
851 {
852 if (++index >= m_OrderedStandartActionInputs.Count())
853 {
854 index = 0;
855 }
857 {
859 break;
860 }
861 }
862 }
863
865 {
866 int index;
867
869 {
870 if (--index < 0)
871 {
872 index = m_OrderedStandartActionInputs.Count() - 1;
873 }
874
876 {
878 break;
879 }
880 }
881 }
882
883
884 override void SelectNextAction()
885 {
886 ActionInput ai;
888 {
890 if (ai && ai.GetPossibleActionsCount() > 1)
891 {
892 ai.SelectNextAction();
893 }
894 }
895 }
896
897 override void SelectPrevAction()
898 {
899 ActionInput ai;
901 {
903 if (ai && ai.GetPossibleActionsCount() > 1)
904 {
905 ai.SelectPrevAction();
906 }
907 }
908 }
909
911 {
912 ItemBase itemInHand = m_Player.GetItemInHands();
913 ActionTarget target;
914 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
915 bool hasTarget = targetItem != NULL;
916
917 if (mainItem)
918 {
920 ActionBase picked_action;
921 int i;
922
923 mainItem.GetActions(QuickaBarActionInput, actions);
924 if (actions)
925 {
926 for (i = 0; i < actions.Count(); i++)
927 {
928 picked_action = ActionBase.Cast(actions[i]);
929 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
930 {
931 if (hasTarget == picked_action.HasTarget())
932 return true;
933 }
934 }
935 }
936 //First check continuous actions
937 mainItem.GetActions(ContinuousDefaultActionInput, actions);
938 if (actions)
939 {
940 for (i = 0; i < actions.Count(); i++)
941 {
942 picked_action = ActionBase.Cast(actions[i]);
943 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
944 {
945 if (hasTarget == picked_action.HasTarget())
946 return true;
947 }
948 }
949 }
950 //second single use actions
951 mainItem.GetActions(DefaultActionInput, actions);
952 if (actions)
953 {
954 for (i = 0; i < actions.Count(); i++)
955 {
956 picked_action = ActionBase.Cast(actions[i]);
957 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
958 {
959 if (hasTarget == picked_action.HasTarget())
960 return true;
961 }
962 }
963 }
964 }
965 return false;
966 }
967
968 void PerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
969 {
970 ItemBase itemInHand = m_Player.GetItemInHands();
971 ActionTarget target;
972 ItemBase parent = null;
973 if (targetItem)
974 parent = ItemBase.Cast(targetItem.GetHierarchyParent());
975 target = new ActionTarget(targetItem, parent, -1, vector.Zero, -1);
976 bool hasTarget = targetItem != NULL;
977
978 if (mainItem)
979 {
980 ActionBase picked_action;
982 int i;
983
984 mainItem.GetActions(QuickaBarActionInput, actions);
985 if (actions)
986 {
987 for (i = 0; i < actions.Count(); i++)
988 {
989 picked_action = ActionBase.Cast(actions[i]);
990 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand))
991 {
992 if (hasTarget == picked_action.HasTarget())
993 {
994 ActionStart(picked_action, target, mainItem);
995 return;
996 }
997 }
998 }
999 }
1000
1001 //First continuous actions
1002 mainItem.GetActions(ContinuousDefaultActionInput, actions);
1003 if (actions)
1004 {
1005 for (i = 0; i < actions.Count(); i++)
1006 {
1007 picked_action = ActionBase.Cast(actions[i]);
1008 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
1009 {
1010 if (hasTarget == picked_action.HasTarget())
1011 {
1012 ActionStart(picked_action, target, mainItem);
1013 return;
1014 }
1015 }
1016 }
1017 }
1018 //Second check single use actions
1019 mainItem.GetActions(DefaultActionInput, actions);
1020 if (actions)
1021 {
1022 for (i = 0; i < actions.Count(); i++)
1023 {
1024 picked_action = ActionBase.Cast(actions[i]);
1025 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
1026 {
1027 if (hasTarget == picked_action.HasTarget())
1028 {
1029 ActionStart(picked_action, target, mainItem);
1030 return;
1031 }
1032 }
1033 }
1034 }
1035
1036 }
1037 }
1038
1039 //TODO Variants support ???
1041 {
1042 ItemBase itemInHand = m_Player.GetItemInHands();
1043 ActionTarget target;
1044 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1045 bool hasTarget = targetItem != NULL;
1046
1047 if (mainItem)
1048 {
1050 ActionBase picked_action;
1051 int i;
1052
1053 //First check single use actions
1054 mainItem.GetActions(DefaultActionInput, actions);
1055 if (actions)
1056 {
1057 for (i = 0; i < actions.Count(); i++)
1058 {
1059 picked_action = ActionBase.Cast(actions[i]);
1060 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1061 {
1062 if (hasTarget == picked_action.HasTarget())
1063 return true;
1064 }
1065 }
1066 }
1067
1068 //Inventory specific actions
1069 mainItem.GetActions(InventoryOnlyActionInput, actions);
1070 if (actions)
1071 {
1072 for (i = 0; i < actions.Count(); i++)
1073 {
1074 picked_action = ActionBase.Cast(actions[i]);
1075 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
1076 {
1077 if (hasTarget == picked_action.HasTarget())
1078 return true;
1079 }
1080 }
1081 }
1082 }
1083 return false;
1084 }
1085
1086 //TODO Variants support ???
1088 {
1089 ItemBase itemInHand = m_Player.GetItemInHands();
1090 ActionTarget target;
1091 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1092 bool hasTarget = targetItem != NULL;
1093
1094 if (mainItem)
1095 {
1096 ActionBase picked_action;
1098 int i;
1099
1100 //First check single use actions
1101 mainItem.GetActions(DefaultActionInput, actions);
1102 if (actions)
1103 {
1104 for (i = 0; i < actions.Count(); i++)
1105 {
1106 picked_action = ActionBase.Cast(actions[i]);
1107 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1108 {
1109 if (hasTarget == picked_action.HasTarget())
1110 {
1111 ActionStart(picked_action, target, mainItem);
1112 return;
1113 }
1114 }
1115 }
1116 }
1117
1118 //Inventory specific actions
1119 mainItem.GetActions(InventoryOnlyActionInput, actions);
1120 if (actions)
1121 {
1122 for (i = 0; i < actions.Count(); i++)
1123 {
1124 picked_action = ActionBase.Cast(actions[i]);
1125 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
1126 {
1127 if (hasTarget == picked_action.HasTarget())
1128 {
1129 ActionStart(picked_action, target, mainItem);
1130 return;
1131 }
1132 }
1133 }
1134 }
1135 }
1136 }
1137
1139 {
1140 ItemBase itemInHand = m_Player.GetItemInHands();
1141 ActionTarget target;
1142 EntityAI parent = null;
1143 if (targetItem)
1144 {
1145 parent = targetItem.GetHierarchyParent();
1146 }
1147 target = new ActionTarget(targetItem, parent, -1, vector.Zero, -1);
1148 bool hasTarget = targetItem != NULL;
1149
1150 if (mainItem)
1151 {
1153 array<ref ActionBase> variant_actions;
1154 ActionBase picked_action;
1155 int variants_count,v;
1156
1157 //First check single use actions
1158 mainItem.GetActions(DefaultActionInput, actions);
1159 if (actions)
1160 {
1161 for (int i = 0; i < actions.Count(); i++)
1162 {
1163 picked_action = ActionBase.Cast(actions[i]);
1164 if (picked_action.HasVariants())
1165 {
1166 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1167 picked_action.GetVariants(variant_actions);
1168 for (v = 0; v < variant_actions.Count(); v ++)
1169 {
1170 picked_action = variant_actions[v];
1171 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1172 {
1173 if (hasTarget == picked_action.HasTarget())
1174 return true;
1175 }
1176 }
1177 }
1178 else
1179 {
1180 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1181 {
1182 if (hasTarget == picked_action.HasTarget())
1183 return true;
1184 }
1185 }
1186 }
1187 }
1188 //second continuous actions
1189 mainItem.GetActions(ContinuousDefaultActionInput, actions);
1190 if (actions)
1191 {
1192 for (int j = 0; j < actions.Count(); j++)
1193 {
1194 picked_action = ActionBase.Cast(actions[j]);
1195 if (picked_action.HasVariants())
1196 {
1197 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1198 picked_action.GetVariants(variant_actions);
1199 for (v = 0; v < variant_actions.Count(); v ++)
1200 {
1201 picked_action = variant_actions[v];
1202 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1203 {
1204 if (hasTarget == picked_action.HasTarget())
1205 return true;
1206 }
1207 }
1208 }
1209 else
1210 {
1211 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1212 {
1213 if (hasTarget == picked_action.HasTarget())
1214 return true;
1215 }
1216 }
1217 }
1218 }
1219 }
1220 return false;
1221 }
1222
1223 //TODO fix for variants
1224 void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
1225 {
1226 ItemBase itemInHand = m_Player.GetItemInHands();
1227 ActionTarget target;
1228 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1229 bool hasTarget = targetItem != NULL;
1230
1231 if (mainItem)
1232 {
1234 ActionBase picked_action;
1235
1236 //First check single use actions
1237 mainItem.GetActions(DefaultActionInput, actions);
1238 if (actions)
1239 {
1240 for (int i = 0; i < actions.Count(); i++)
1241 {
1242 picked_action = ActionBase.Cast(actions[i]);
1243 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1244 {
1245 if (hasTarget == picked_action.HasTarget())
1246 {
1247 SetInventoryAction(picked_action, target, itemInHand);
1248 return;
1249 }
1250 }
1251 }
1252 }
1253 //second continuous actions
1254 mainItem.GetActions(ContinuousDefaultActionInput, actions);
1255 if (actions)
1256 {
1257 for (int j = 0; j < actions.Count(); j++)
1258 {
1259 picked_action = ActionBase.Cast(actions[j]);
1260 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1261 {
1262 if (hasTarget == picked_action.HasTarget())
1263 {
1264 SetInventoryAction(picked_action, target, itemInHand);
1265 return;
1266 }
1267 }
1268 }
1269 }
1270 }
1271 }
1272
1273 // disables automatic end of continuous action when input ended
1275 {
1276 m_IgnoreAutoInputEnd = state;
1277 }
1278
1281 {
1283 {
1286 ctx.Write(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
1287 ctx.Send();
1288 }
1289 }
1290
1293};
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Определения _constants.c:3
const int INPUT_UDT_STANDARD_ACTION_START
Определения _constants.c:2
const int INPUT_UDT_STANDARD_ACTION_INPUT_END
Определения _constants.c:4
ActionBase ActionData
Определения ActionBase.c:30
void ContinuousDefaultActionInput(PlayerBase player)
Определения ActionInput.c:607
override ActionBase GetAction()
Определения ActionInput.c:483
ActionInputType
Определения ActionInput.c:2
override int GetPossibleActionsCount()
Определения ActionInput.c:468
override bool HasTarget()
Определения ActionInput.c:473
bool m_Interrupted
Определения ActionManagerBase.c:49
ref ActionData m_CurrentActionData
Определения ActionManagerBase.c:61
void SetActionContext(ActionTarget target, ItemBase item)
Определения ActionManagerBase.c:255
bool m_ActionsAvaibale
Определения ActionManagerBase.c:55
bool m_ActionInputWantEnd
Определения ActionManagerBase.c:53
bool ActionPossibilityCheck(int pCurrentCommandID)
Определения ActionManagerBase.c:244
static ref array< ref ActionBase > m_ActionsArray
Определения ActionManagerBase.c:50
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
int m_PendingActionAcknowledgmentID
Определения ActionManagerBase.c:59
bool m_ActionWantEndRequest
Определения ActionManagerBase.c:52
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
map< typename, ref ActionInput > TTypeNameActionInputMap
Определения ActionManagerClient.c:2
class ActionTargets ActionTarget
map
Определения ControlsXboxNew.c:4
DayZPlayer m_Player
Определения Hand_Events.c:42
int GetVariants(out array< ref ActionBase > variants)
Определения ActionBase.c:928
int GetID()
Определения ActionBase.c:1321
bool HasVariants()
Определения ActionBase.c:915
void UpdateVariants(Object item, Object target, int componet_index)
Определения ActionBase.c:946
bool CanBePerformedFromInventory()
Определения ActionBase.c:308
bool HasTarget()
Определения ActionBase.c:244
void Start(ActionData action_data)
Определения ActionBase.c:725
bool CanBePerformedFromQuickbar()
Определения ActionBase.c:303
bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Определения ActionBase.c:861
bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Определения ActionBase.c:156
bool UseAcknowledgment()
Определения ActionBase.c:1123
void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
Определения ActionBase.c:426
ActionVariantManager GetVariantManager()
Определения ActionBase.c:954
bool IsInstant()
Определения ActionBase.c:262
bool CanBeSetFromInventory()
Определения ActionBase.c:313
GetInputType()
Определения ActionBase.c:215
ActionInput GetInput()
Определения ActionBase.c:1311
void SetInput(ActionInput ai)
Определения ActionBase.c:220
bool IsLocal()
Определения ActionBase.c:256
static int ComputeConditionMask(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionBase.c:807
Определения ActionBase.c:53
int GetPossibleActionsCount()
Определения ActionInput.c:274
void ActionsSelectReset()
Определения ActionInput.c:227
void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
Определения ActionInput.c:178
void Update()
Определения ActionInput.c:114
array< ActionBase > GetPossibleActions()
Определения ActionInput.c:197
void OnActionStart()
Определения ActionInput.c:217
void SelectPrevAction()
Определения ActionInput.c:271
void ClearForcedAction()
Определения ActionInput.c:243
void SelectNextAction()
Определения ActionInput.c:267
int GetPossibleActionIndex()
Определения ActionInput.c:207
ActionBase GetAction()
Определения ActionInput.c:182
int GetPriority()
Определения ActionInput.c:284
bool WasEnded()
Определения ActionInput.c:109
int GetInputType()
Определения ActionInput.c:89
void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
Определения ActionInput.c:230
ItemBase GetUsedMainItem()
Определения ActionInput.c:192
ActionTarget GetUsedActionTarget()
Определения ActionInput.c:187
bool JustActivate()
Определения ActionInput.c:99
void Reset()
Определения ActionInput.c:172
Определения ActionInput.c:20
override void SelectNextAction()
Определения ActionManagerClient.c:884
void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1224
ref array< ActionInput > m_OrderedStandartActionInputs
Определения ActionManagerClient.c:15
override void SelectFirstActionCategory()
Определения ActionManagerClient.c:831
bool CanPerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:910
void EjectAction(typename actionType)
Определения ActionManagerClient.c:454
void RegisterInputs(PlayerBase player)
Определения ActionManagerClient.c:138
void SetDefaultInputsOrder()
Определения ActionManagerClient.c:213
int GetPossibleActionCount(typename inputType)
Определения ActionManagerClient.c:423
array< ActionBase > GetPossibleActions(typename inputType)
Определения ActionManagerClient.c:403
override void OnActionEnd()
Определения ActionManagerClient.c:775
void ProcessActionRequestEnd()
Определения ActionManagerClient.c:329
ActionBase GetPossibleAction(typename inputType)
Определения ActionManagerClient.c:393
void SetInventoryAction(ActionBase action_name, ItemBase target_item, ItemBase main_item)
Определения ActionManagerClient.c:788
void ClearForceTarget()
Определения ActionManagerClient.c:469
void ActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data=NULL)
Определения ActionManagerClient.c:598
override GetSelectedActionCategory()
Определения ActionManagerClient.c:803
bool m_IgnoreAutoInputEnd
Определения ActionManagerClient.c:18
ref array< ref InventoryLocation > m_ReservedInventoryLocations
Определения ActionManagerClient.c:10
ref InventoryActionHandler m_InventoryActionHandler
Определения ActionManagerClient.c:11
void SetActioninputOrder()
Определения ActionManagerClient.c:169
void InjectAction(ActionBase action, ActionTarget target, ItemBase item)
Определения ActionManagerClient.c:436
override ActionTarget FindActionTarget()
Определения ActionManagerClient.c:476
void PerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:968
override void SelectNextActionCategory()
Определения ActionManagerClient.c:846
void SetInventoryAction(ActionBase action_name, ActionTarget target, ItemBase main_item)
Определения ActionManagerClient.c:793
override void RequestInterruptAction()
client requests action interrupt
Определения ActionManagerClient.c:1280
bool LockInventory(ActionData action_data)
Определения ActionManagerClient.c:564
void FindContextualUserActions(int pCurrentCommandID)
Определения ActionManagerClient.c:528
void HandleInputsOnActionEnd()
Определения ActionManagerClient.c:700
void UnlockInventory(ActionData action_data)
Определения ActionManagerClient.c:588
override void EndOrInterruptCurrentAction()
Определения ActionManagerClient.c:728
void UnsetInventoryAction()
Определения ActionManagerClient.c:798
void InputsUpdate()
Определения ActionManagerClient.c:282
bool m_ActionWantEndRequest_Send
Определения ActionManagerClient.c:22
override void RequestEndAction()
Определения ActionManagerClient.c:266
void PerformActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data=NULL)
Определения ActionManagerClient.c:762
ref array< ActionInput > m_DefaultOrderOfActionInputs
Определения ActionManagerClient.c:16
ref array< ActionInput > m_OrederedAllActionInput
Определения ActionManagerClient.c:14
override void SelectPrevAction()
Определения ActionManagerClient.c:897
bool HasHandInventoryReservation()
Определения ActionManagerClient.c:520
override void OnJumpStart()
Определения ActionManagerClient.c:723
void InjectAction(typename actionType, ActionTarget target, ItemBase item)
Определения ActionManagerClient.c:442
ref ActionTargets m_Targets
Определения ActionManagerClient.c:1292
void ResetInputsActions()
Определения ActionManagerClient.c:714
void PerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1087
override void OnInstantAction(typename user_action_type, Param data=NULL)
Определения ActionManagerClient.c:745
override void EndActionInput()
Определения ActionManagerClient.c:274
ref InventoryLocation m_HandInventoryLocationTest
Определения ActionManagerClient.c:12
override void Update(int pCurrentCommandID)
Определения ActionManagerClient.c:41
void ForceTarget(Object targetObject)
Определения ActionManagerClient.c:460
ref ActionTarget m_ForceTarget
Определения ActionManagerClient.c:1291
void HandleInputsOnActionStart(ActionBase action)
Определения ActionManagerClient.c:684
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1040
void UpdateActionCategoryPriority()
Определения ActionManagerClient.c:808
bool m_ActionPossible
Определения ActionManagerClient.c:9
int m_SelectedActionInputToSrollIndex
Определения ActionManagerClient.c:17
ref TTypeNameActionInputMap m_RegistredInputsMap
Определения ActionManagerClient.c:13
void ActionManagerClient(PlayerBase player)
Определения ActionManagerClient.c:25
void ProcessActionInputEnd()
Определения ActionManagerClient.c:359
int m_LastAcknowledgmentID
Определения ActionManagerClient.c:8
static ActionVariantManager GetVariantManager(typename actionName)
Определения ActionManagerClient.c:255
void EjectAction(ActionBase action)
Определения ActionManagerClient.c:448
int GetPossibleActionIndex(typename inputType)
Определения ActionManagerClient.c:413
ref ActionData m_PendingActionData
Определения ActionManagerClient.c:20
override void SelectPrevActionCategory()
Определения ActionManagerClient.c:864
ItemBase FindActionItem()
Определения ActionManagerClient.c:510
bool m_ActionInputWantEnd_Send
Определения ActionManagerClient.c:23
void SetIgnoreAutomaticInputEnd(bool state)
Определения ActionManagerClient.c:1274
void ResetInputsState()
Определения ActionManagerClient.c:705
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1138
Определения ActionTargets.c:174
proto native UIManager GetUIManager()
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:127
Определения Debug.c:2
static bool IsFreeCameraEnabled()
Определения DeveloperFreeCamera.c:23
Определения Building.c:6
Client only - manage set up crafting on client.
Определения InventoryActionHandler.c:3
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
static bool IsActionLogEnable()
Определения Debug.c:638
Определения Debug.c:594
Определения ObjectTyped.c:2
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения PlayerBaseClient.c:2
proto native void Send()
proto static native bool CanStoreInputUserData()
Returns true when the channel is free, AND the InputBuffer is NOT full (same as '!...
Определения gameplay.c:121
proto bool Write(void value_out)
bool IsMenuOpen(int id)
Returns true if menu with specific ID is opened (see MenuID)
Определения UIManager.c:154
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
proto native CGame GetGame()
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
const int MENU_INVENTORY
Определения constants.c:180
const int UA_START
Определения constants.c:467
const int UA_AM_ACCEPTED
Определения constants.c:475
const int UA_AM_REJECTED
Определения constants.c:476
const int UA_AM_PENDING
Определения constants.c:474
proto native int GetRunningAction()
returns -1 when no action is running or RELOAD,MECHANISM, ....
Определения ActionManagerBase.c:91