DayZ 1.24
Loading...
Searching...
No Matches
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)
7 string m_AnimSource = "";
8 // ---
9
11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
13 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
14 m_LockTargetOnUse = false;
15 }
16
18 {
21 }
22
23 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
24 {
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 return false;
38
39 animSource = car.GetAnimSourceFromSelection(car.GetDoorSelectionNameFromSeatPos(crewIdx));
40
42 if (!car.CanReachDoorsFromSeat(animSource, crewIdx) || !car.IsAreaAtDoorFree(crewIdx))
43 return false;
44
46
47 float animationPhaseInside = car.GetAnimationPhase(animSource);
48 return (m_IsOpening && animationPhaseInside <= 0.5) || (!m_IsOpening && animationPhaseInside > 0.5);
49 }
50 }
51
52 return false;
53 }
54
56 {
57 PlayerBase player = action_data.m_Player;
58
59 float phase;
60 if (m_IsOpening)
61 phase = 1.0;
62 else
63 phase = 0.0;
64
65 string animSource = "";
66
68 if (player && player.GetCommand_Vehicle())
69 {
70 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
71 if (car)
72 {
73 int crewIdx = car.CrewMemberIndex(player);
74 animSource = car.GetAnimSourceFromSelection(car.GetDoorSelectionNameFromSeatPos(crewIdx));
75 }
76 }
77
78 if (car)
79 {
80 car.ForceUpdateLightsStart();
81 car.SetAnimationPhase(animSource, phase);
82 }
83 }
84
86 {
88 PlayerBase player = action_data.m_Player;
89 if (player && player.GetCommand_Vehicle())
90 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
91
92 if (car)
93 car.ForceUpdateLightsEnd();
94 }
95
97 {
98 if (m_Car || m_AnimSource.Length() > 0)
99 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.");
100 }
101
102 override bool CanBeUsedInVehicle()
103 {
104 return true;
105 }
106
114
119};
bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
CarDoorState
Definition CarScript.c:2
void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
int m_CommandUIDPerCrewIdx[4]
override void CreateConditionComponents()
void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
CarScript m_Car
override bool CanBeUsedInVehicle()
override void OnStartServer(ActionData action_data)
override void OnEndServer(ActionData action_data)
override void OnEnd(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native int Length()
Returns length of string.