DayZ 1.24
Loading...
Searching...
No Matches
Land_Underground_Panel.c
Go to the documentation of this file.
7
8enum ELEDColors
9{
12}
13
14class Land_Underground_Panel: House
15{
18
20
21 const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)";
22 const string COLOR_LED_GREEN = "#(argb,8,8,3)color(0,1,0,1.0,co)";
23 const string COLOR_LED_RED = "#(argb,8,8,3)color(1,0,0,1.0,co)";
24
25 const string SELECTION_NAME_LED_RED = "LED_Red";
26 const string SELECTION_NAME_LED_GREEN = "LED_Green";
27
32
34
37
39 {
40 RegisterNetSyncVariableBool("m_PanelWasUsed");
41 RegisterPanel(this);
44 }
45
47 {
48 UnregisterPanel(this);
49 }
50
52 {
54 if (door)
56 return false;
57 }
58
59 void Interact()
60 {
62 if (door)
63 {
64 GetGame().RegisterNetworkStaticObject(this);
66 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetPanelUsed, 500);
67 m_PanelWasUsed = true;
68 SetSynchDirty();
69 }
70 else
71 ErrorEx("Can't find the instance of entrance the panel is linkined to");
72 }
73
80
82 {
83 if (m_Entrances)
84 {
85 int index = m_Entrances.Find(entrance);
86 if (index != -1)
87 m_Entrances.Remove(index);
88 else
89 ErrorEx("Attempted to unregistered non-registered entrance");
90 }
91 }
92
93 static void RegisterPanel(Land_Underground_Panel panel)
94 {
95 if (!m_Panels)
97 m_Panels.Insert(panel);
98 }
99
100 static void UnregisterPanel(Land_Underground_Panel panel)
101 {
102 if (m_Panels)
103 {
104 int index = m_Panels.Find(panel);
105 if (index != -1)
106 m_Panels.Remove(index);
107 else
108 ErrorEx("Attempted to unregistered non-registered panel");
109 }
110 }
111
116
123
125 {
126 if (!m_Entrances)
127 return null;
128
129 float closestDst = float.MAX;
132
134 {
135 float dist = vector.DistanceSq(thisPos, obj.GetPosition());
136 if (dist < closestDst)
137 {
139 closestObj = obj;
140 }
141 }
142
143 return closestObj;
144 }
145
147 {
148#ifndef SERVER
149 if (color == ELEDColors.RED)
150 {
151 if (m_LedStateRed != state)
152 {
155 }
156 }
157 else
158 {
159 if (m_LedStateGreen != state)
160 {
163 }
164 }
165#endif
166 }
167
169 {
170 if (enable)
171 {
172 if (!m_FlipFlopTimer)
173 {
174 m_FlipFlopTimer = new Timer();
175 m_FlipFlopTimer.Run(0.1, this, "ToggleFlipFlop", NULL, true);
176 }
177 }
178 else
179 {
180 if (m_FlipFlopTimer)
182 }
183 }
184
186 {
187 /*
188 Print("OnLEDStateChanged()");
189 Print("m_LedStateRed: " + m_LedStateRed);
190 Print("m_LedStateGreen: " + m_LedStateGreen);
191 */
192 if (m_LedStateRed == ELEDState.BLINKING || m_LedStateGreen == ELEDState.BLINKING)
193 SetBlinkingTimer(true);
194 else
195 SetBlinkingTimer(false);
196 //red
197 if (m_LedStateRed == ELEDState.ON)
199 else if (m_LedStateRed == ELEDState.OFF)
201 else if (m_LedStateRed == ELEDState.BLINKING)
202 {
205 else
207
208 //green
209 }
210 if (m_LedStateGreen == ELEDState.ON)
212 else if (m_LedStateGreen == ELEDState.OFF)
214 else if (m_LedStateGreen == ELEDState.BLINKING)
215 {
218 else
220
221 }
222 }
223
225 {
226 m_PanelWasUsed = false;
227 SetSynchDirty();
228 }
229
231 {
232 switch (GetLinkedDoorType())
233 {
234 case EUndegroundDoorType.MAIN:
235 {
238 else if (newState == EUndegroundEntranceState.OPENING_G)
240 else if (newState >= EUndegroundEntranceState.CLOSING_A)
241 SetLEDState(ELEDColors.RED, ELEDState.BLINKING);
242
244 SetLEDState(ELEDColors.GREEN, ELEDState.OFF);
245 else if (newState >= EUndegroundEntranceState.OPENING_A && newState < EUndegroundEntranceState.OPENING_G)
246 SetLEDState(ELEDColors.GREEN, ELEDState.BLINKING);
247 else if (newState >= EUndegroundEntranceState.OPENING_G)
249 }
250 break;
251 case EUndegroundDoorType.SMALL:
252 {
253 if (newState == EUndegroundEntranceState.OPENING_A)
254 {
256 SetLEDState(ELEDColors.GREEN, ELEDState.BLINKING);
257 }
258 else if (newState == EUndegroundEntranceState.OPENING_B)
259 {
262 }
263 else if (newState == EUndegroundEntranceState.CLOSING_A)
264 {
265 SetLEDState(ELEDColors.RED, ELEDState.BLINKING);
267 }
269 {
271 SetLEDState(ELEDColors.GREEN, ELEDState.OFF);
272 }
273 }
274 break;
275 }
276 }
277
278
279 protected void UpdateLED(string selection, string color)
280 {
281 int selectionIdx = GetHiddenSelectionIndex(selection);
282 SetObjectTexture(selectionIdx, color);
283 //Print("selection: " +selection + ", color: " + color +", selectionIdx: "+ selectionIdx);
284 }
285
291
293 {
294 PlaySoundSet(m_ActivationSound, "UndergroundDoor_PanelActivation_SoundSet", 0, 0);
295 }
296
306
307}
override void OnVariablesSynchronized()
enum ELEDState GREEN
const string SELECTION_NAME_LED_RED
static void UnregisterPanel(Land_Underground_Panel panel)
void ~Land_Underground_Panel()
static void RegisterEntrance(Land_Underground_EntranceBase entrance)
const string COLOR_LED_OFF
enum ELEDState RED
static void RegisterPanel(Land_Underground_Panel panel)
void ResetPanelUsed()
ELEDState m_LedStateRed
void Land_Underground_Panel()
void OnPanelUsedSynchronized()
EUndegroundDoorType GetLinkedDoorType()
void ToggleFlipFlop()
void OnDoorStateChangedClient(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
const string SELECTION_NAME_LED_GREEN
const string COLOR_LED_GREEN
static ref set< Land_Underground_Panel > m_Panels
void SetBlinkingTimer(bool enable)
bool m_PanelWasUsed bool m_PanelWasUsedPrev
enum ELEDState m_Entrances
bool CanInteract()
void UpdateLED(string selection, string color)
void Interact()
ELEDState m_LedStateGreen
EffectSound m_ActivationSound
Land_Underground_EntranceBase m_LinkedDoor
Land_Underground_EntranceBase GetClosestDoor()
static void UnregisterEntrance(Land_Underground_EntranceBase entrance)
void OnLEDStateChanged()
void SetLEDState(ELEDColors color, ELEDState state)
Land_Underground_EntranceBase GetLinkedDoor()
const string COLOR_LED_RED
ref Timer m_FlipFlopTimer
bool m_BlinkingFlipFlop
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
enum ShapeType ErrorEx
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8