Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actioncardoors.c
Go to the documentation of this file.
2 {
3  protected int m_CommandUIDPerCrewIdx[4];
4  protected bool m_IsOpening = true;
5  // --- Backwards compatibility 1.09 -> 1.10 (But please do not use these)
6  CarScript m_Car = null;
7  string m_AnimSource = "";
8  // ---
9 
10  void ActionCarDoors()
11  {
12  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
13  m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
14  m_LockTargetOnUse = false;
15  }
16 
17  override void CreateConditionComponents()
18  {
21  }
22 
23  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
24  {
25  CarScript car = null;
26  string animSource = "";
27 
29  if (player && player.GetCommand_Vehicle())
30  {
31  if (Class.CastTo(car, player.GetCommand_Vehicle().GetTransport()))
32  {
33  int crewIdx = car.CrewMemberIndex(player);
34 
36  if (crewIdx < 0 || crewIdx > 3 || car.GetCarDoorsState(car.GetDoorInvSlotNameFromSeatPos(crewIdx)) == CarDoorState.DOORS_MISSING)
37  {
38  return false;
39  }
40 
41  animSource = car.GetAnimSourceFromSelection(car.GetDoorSelectionNameFromSeatPos(crewIdx));
42 
44  if (!car.CanReachDoorsFromSeat(animSource, crewIdx) || !car.IsAreaAtDoorFree(crewIdx))
45  {
46  return false;
47  }
48 
49  m_CommandUID = m_CommandUIDPerCrewIdx[crewIdx];
50 
51  float animationPhaseInside = car.GetAnimationPhase(animSource);
52  return (m_IsOpening && animationPhaseInside <= 0.5) || (!m_IsOpening && animationPhaseInside > 0.5);
53  }
54  }
55 
56  return false;
57  }
58 
59  override void OnStartServer(ActionData action_data)
60  {
61  PlayerBase player = action_data.m_Player;
62 
63  float phase;
64  if (m_IsOpening)
65  {
66  phase = 1.0;
67  }
68  else
69  {
70  phase = 0.0;
71  }
72 
73  string animSource = "";
74 
75  CarScript car;
76  if (player && player.GetCommand_Vehicle())
77  {
78  car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
79  if (car)
80  {
81  int crewIdx = car.CrewMemberIndex(player);
82  animSource = car.GetAnimSourceFromSelection(car.GetDoorSelectionNameFromSeatPos(crewIdx));
83  }
84  }
85 
86  if (car)
87  {
88  car.ForceUpdateLightsStart();
89  car.SetAnimationPhase(animSource, phase);
90  }
91  }
92 
93  override void OnEndServer(ActionData action_data)
94  {
95  CarScript car;
96  PlayerBase player = action_data.m_Player;
97  if (player && player.GetCommand_Vehicle())
98  {
99  car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
100  }
101 
102  if (car)
103  {
104  car.ForceUpdateLightsEnd();
105  }
106  }
107 
108  override void OnEnd(ActionData action_data)
109  {
110  if (m_Car || m_AnimSource.Length() > 0)
111  {
112  Error("[WARNING] m_Car and m_AnimSource are left for backwards compatibility to not crash mods that are using it, but should no longer be used.");
113  }
114  }
115 
116  override bool CanBeUsedInVehicle()
117  {
118  return true;
119  }
120 
121  protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
122  {
123  m_CommandUIDPerCrewIdx[0] = crewIdx0;
124  m_CommandUIDPerCrewIdx[1] = crewIdx1;
125  m_CommandUIDPerCrewIdx[2] = crewIdx2;
126  m_CommandUIDPerCrewIdx[3] = crewIdx3;
127  }
128 
129  protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
130  {
131  FillCommandUIDPerCrewIdx(evenCrewIdx0, unevenCrewIdx1, evenCrewIdx0, unevenCrewIdx1);
132  }
133 };
ItemBase
Definition: inventoryitem.c:730
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
CCINone
Definition: ccinone.c:1
CarScript
Definition: civiliansedan.c:1
CCTNone
Definition: cctnone.c:1
m_Car
CarScript m_Car
Definition: actionpushcar.c:17
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
CarDoorState
CarDoorState
Definition: carscript.c:1
m_LockTargetOnUse
protected bool m_LockTargetOnUse
Definition: actionbase.c:51
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
ActionCarDoors
Definition: actioncardoors.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53