Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actioncardoorsoutside.c
Go to the documentation of this file.
2 {
3  protected int m_CommandUIDPerCrewIdx[4];
4  protected bool m_IsOpening = true;
5 
7  {
8  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
9  m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
10  m_LockTargetOnUse = false;
11  }
12 
13  override void CreateConditionComponents()
14  {
17  }
18 
19  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
20  {
21  CarScript car = null;
22 
24  if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
25  {
26  return false;
27  }
28 
30  if (Class.CastTo(car, target.GetParent()))
31  {
32  array<string> selections = new array<string>();
33 
34  CarDoor carDoor = CarDoor.Cast(target.GetObject());
35  if (carDoor)
36  {
37  carDoor.GetActionComponentNameList(target.GetComponentIndex(), selections);
38 
39  string animSource = "";
40 
41  for (int i = 0; i < selections.Count(); i++)
42  {
43  animSource = car.GetAnimSourceFromSelection(selections[i]);
44  if (animSource != "")
45  {
46  int idx = car.GetSeatIndexFromDoor(animSource);
47  if (idx != -1 && !car.IsAreaAtDoorFree(idx))
48  {
49  return false;
50  }
51 
53  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
54 
55  float animationPhase = car.GetAnimationPhase(animSource);
57  return (m_IsOpening && animationPhase <= 0.5 ) || ( !m_IsOpening && animationPhase > 0.5);
58  }
59  }
60  }
61  }
62 
63  return false;
64  }
65 
66  override void OnStartServer( ActionData action_data )
67  {
68  float phase;
69 
70  if (m_IsOpening)
71  {
72  phase = 1.0;
73  }
74  else
75  {
76  phase = 0.0;
77  }
78 
79  string animSource = "";
80 
81  CarScript car = CarScript.Cast(action_data.m_Target.GetParent());
82  if (car)
83  {
84  array<string> selections = new array<string>();
85  CarDoor carDoor = CarDoor.Cast(action_data.m_Target.GetObject());
86  if (carDoor)
87  {
88  carDoor.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
89  for (int i = 0; i < selections.Count(); i++)
90  {
91  animSource = car.GetAnimSourceFromSelection(selections[i]);
92  if (animSource != "")
93  {
94  break;
95  }
96  }
97  }
98  }
99 
100  if (car)
101  {
102  car.ForceUpdateLightsStart();
103  car.SetAnimationPhase(animSource, phase);
104  }
105  }
106 
107  override void OnEndServer(ActionData action_data)
108  {
109  CarScript car = CarScript.Cast(action_data.m_Target.GetParent());
110  if (car)
111  {
112  car.ForceUpdateLightsEnd();
113  }
114  }
115 
116  //--------- Not used for this class
117  protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
118  {
119  m_CommandUIDPerCrewIdx[0] = crewIdx0;
120  m_CommandUIDPerCrewIdx[1] = crewIdx1;
121  m_CommandUIDPerCrewIdx[2] = crewIdx2;
122  m_CommandUIDPerCrewIdx[3] = crewIdx3;
123  }
124 
125  protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
126  {
127  FillCommandUIDPerCrewIdx(evenCrewIdx0, unevenCrewIdx1, evenCrewIdx0, unevenCrewIdx1);
128  }
129  //-----------------------------------
130 };
ItemBase
Definition: inventoryitem.c:730
CarDoor
Definition: inventoryitem.c:496
ActionCarDoorsOutside
Definition: actioncardoorsoutside.c:1
CCINone
Definition: ccinone.c:1
CarScript
Definition: civiliansedan.c:1
CCTNone
Definition: cctnone.c:1
UAMaxDistances
Definition: actionconstants.c:104
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
m_LockTargetOnUse
protected bool m_LockTargetOnUse
Definition: actionbase.c:51
IsInReach
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition: actionbase.c:928
array< string >
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53