Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
land_underground_panel.c
Go to the documentation of this file.
1
enum
ELEDState
2
{
3
OFF
,
4
BLINKING
,
5
ON
,
6
}
7
8
enum
ELEDColors
9
{
10
RED
,
11
GREEN
,
12
}
13
14
class
Land_Underground_Panel
:
House
15
{
16
static
ref set<Land_Underground_EntranceBase>
m_Entrances
;
17
static
ref set<Land_Underground_Panel>
m_Panels
;
18
19
Land_Underground_EntranceBase
m_LinkedDoor
;
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
28
bool
m_PanelWasUsed
29
bool
m_PanelWasUsedPrev
;
30
bool
m_BlinkingFlipFlop
;
31
ref
Timer
m_FlipFlopTimer
;
32
33
EffectSound
m_ActivationSound
;
34
35
ELEDState
m_LedStateRed
;
36
ELEDState
m_LedStateGreen
;
37
38
void
Land_Underground_Panel
()
39
{
40
RegisterNetSyncVariableBool(
"m_PanelWasUsed"
);
41
RegisterPanel
(
this
);
42
SetLEDState
(ELEDColors.RED,
ELEDState
.ON);
43
SetLEDState
(ELEDColors.GREEN,
ELEDState
.OFF);
44
}
45
46
void
~Land_Underground_Panel
()
47
{
48
UnregisterPanel
(
this
);
49
}
50
51
bool
CanInteract
()
52
{
53
Land_Underground_EntranceBase
door =
GetLinkedDoor
();
54
if
(door)
55
{
56
return
Land_Underground_EntranceBase
.Cast(door).
CanManipulate
();
57
}
58
return
false
;
59
}
60
61
void
Interact
()
62
{
63
Land_Underground_EntranceBase
door =
GetLinkedDoor
();
64
if
(door)
65
{
66
g_Game
.RegisterNetworkStaticObject(
this
);
67
Land_Underground_EntranceBase
.Cast(door).
Manipulate
();
68
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).CallLater(
ResetPanelUsed
, 500);
69
m_PanelWasUsed =
true
;
70
SetSynchDirty();
71
}
72
else
73
{
74
ErrorEx
(
"Can't find the instance of entrance the panel is linkined to"
);
75
}
76
}
77
78
static
void
RegisterEntrance
(
Land_Underground_EntranceBase
entrance)
79
{
80
if
(!
m_Entrances
)
81
{
82
m_Entrances
=
new
set<Land_Underground_EntranceBase>();
83
}
84
m_Entrances
.Insert(entrance);
85
}
86
87
static
void
UnregisterEntrance
(
Land_Underground_EntranceBase
entrance)
88
{
89
if
(
m_Entrances
)
90
{
91
int
index =
m_Entrances
.Find(entrance);
92
if
(index != -1)
93
{
94
m_Entrances
.Remove(index);
95
}
96
else
97
{
98
ErrorEx
(
"Attempted to unregistered non-registered entrance"
);
99
}
100
}
101
}
102
103
static
void
RegisterPanel
(
Land_Underground_Panel
panel)
104
{
105
if
(!
m_Panels
)
106
{
107
m_Panels
=
new
set<Land_Underground_Panel>;
108
}
109
m_Panels
.Insert(panel);
110
}
111
112
static
void
UnregisterPanel
(
Land_Underground_Panel
panel)
113
{
114
if
(
m_Panels
)
115
{
116
int
index =
m_Panels
.Find(panel);
117
if
(index != -1)
118
{
119
m_Panels
.Remove(index);
120
}
121
else
122
{
123
ErrorEx
(
"Attempted to unregistered non-registered panel"
);
124
}
125
}
126
}
127
128
EUndegroundDoorType
GetLinkedDoorType
()
129
{
130
return
GetLinkedDoor
().
m_DoorType
;
131
}
132
133
Land_Underground_EntranceBase
GetLinkedDoor
()
134
{
135
if
(!
m_LinkedDoor
)
136
m_LinkedDoor
=
GetClosestDoor
();
137
return
m_LinkedDoor
;
138
}
139
140
Land_Underground_EntranceBase
GetClosestDoor
()
141
{
142
if
(!
m_Entrances
)
143
{
144
return
null;
145
}
146
147
float
closestDst =
float
.MAX;
148
Land_Underground_EntranceBase
closestObj;
149
vector
thisPos =
GetPosition
();
150
151
foreach
(
Land_Underground_EntranceBase
obj:
m_Entrances
)
152
{
153
float
dist =
vector
.
DistanceSq
(thisPos, obj.GetPosition());
154
if
(dist < closestDst)
155
{
156
closestDst = dist;
157
closestObj = obj;
158
}
159
}
160
161
return
closestObj;
162
}
163
164
void
SetLEDState
(ELEDColors color,
ELEDState
state)
165
{
166
#ifndef SERVER
167
if
(color == ELEDColors.RED)
168
{
169
if
(
m_LedStateRed
!= state)
170
{
171
m_LedStateRed
= state;
172
OnLEDStateChanged
();
173
}
174
}
175
else
176
{
177
if
(
m_LedStateGreen
!= state)
178
{
179
m_LedStateGreen
= state;
180
OnLEDStateChanged
();
181
}
182
}
183
#endif
184
}
185
186
void
SetBlinkingTimer
(
bool
enable)
187
{
188
if
(enable)
189
{
190
if
(!
m_FlipFlopTimer
)
191
{
192
m_FlipFlopTimer
=
new
Timer
();
193
m_FlipFlopTimer
.Run(0.1,
this
,
"ToggleFlipFlop"
, NULL,
true
);
194
}
195
}
196
else
197
{
198
if
(
m_FlipFlopTimer
)
199
{
200
m_FlipFlopTimer
= null;
201
}
202
}
203
}
204
205
void
OnLEDStateChanged
()
206
{
207
/*
208
Print("OnLEDStateChanged()");
209
Print("m_LedStateRed: " + m_LedStateRed);
210
Print("m_LedStateGreen: " + m_LedStateGreen);
211
*/
212
if
(
m_LedStateRed
==
ELEDState
.BLINKING ||
m_LedStateGreen
==
ELEDState
.BLINKING)
213
{
214
SetBlinkingTimer
(
true
);
215
}
216
else
217
{
218
SetBlinkingTimer
(
false
);
219
}
220
//red
221
if
(
m_LedStateRed
==
ELEDState
.ON)
222
{
223
UpdateLED
(
SELECTION_NAME_LED_RED
,
COLOR_LED_RED
);
224
}
225
else
if
(
m_LedStateRed
==
ELEDState
.OFF)
226
{
227
UpdateLED
(
SELECTION_NAME_LED_RED
,
COLOR_LED_OFF
);
228
}
229
else
if
(
m_LedStateRed
==
ELEDState
.BLINKING)
230
{
231
if
(
m_BlinkingFlipFlop
)
232
{
233
UpdateLED
(
SELECTION_NAME_LED_RED
,
COLOR_LED_RED
);
234
}
235
else
236
{
237
UpdateLED
(
SELECTION_NAME_LED_RED
,
COLOR_LED_OFF
);
238
}
239
240
//green
241
}
242
if
(
m_LedStateGreen
==
ELEDState
.ON)
243
{
244
UpdateLED
(
SELECTION_NAME_LED_GREEN
,
COLOR_LED_GREEN
);
245
}
246
else
if
(
m_LedStateGreen
==
ELEDState
.OFF)
247
{
248
UpdateLED
(
SELECTION_NAME_LED_GREEN
,
COLOR_LED_OFF
);
249
}
250
else
if
(
m_LedStateGreen
==
ELEDState
.BLINKING)
251
{
252
if
(
m_BlinkingFlipFlop
)
253
{
254
UpdateLED
(
SELECTION_NAME_LED_GREEN
,
COLOR_LED_GREEN
);
255
}
256
else
257
{
258
UpdateLED
(
SELECTION_NAME_LED_GREEN
,
COLOR_LED_OFF
);
259
}
260
261
}
262
}
263
264
void
ResetPanelUsed
()
265
{
266
m_PanelWasUsed =
false
;
267
SetSynchDirty();
268
}
269
270
void
OnDoorStateChangedClient
(
EUndegroundEntranceState
newState,
EUndegroundEntranceState
prevState)
271
{
272
switch
(
GetLinkedDoorType
())
273
{
274
case
EUndegroundDoorType.MAIN:
275
{
276
if
(newState >=
EUndegroundEntranceState
.CLOSED && newState <
EUndegroundEntranceState
.OPENING_G)
277
{
278
SetLEDState
(ELEDColors.RED,
ELEDState
.ON);
279
}
280
else
if
(newState ==
EUndegroundEntranceState
.OPENING_G)
281
{
282
SetLEDState
(ELEDColors.RED,
ELEDState
.OFF);
283
}
284
else
if
(newState >=
EUndegroundEntranceState
.CLOSING_A)
285
{
286
SetLEDState
(ELEDColors.RED,
ELEDState
.BLINKING);
287
}
288
289
if
(newState ==
EUndegroundEntranceState
.CLOSED)
290
{
291
SetLEDState
(ELEDColors.GREEN,
ELEDState
.OFF);
292
}
293
else
if
(newState >=
EUndegroundEntranceState
.OPENING_A && newState <
EUndegroundEntranceState
.OPENING_G)
294
{
295
SetLEDState
(ELEDColors.GREEN,
ELEDState
.BLINKING);
296
}
297
else
if
(newState >=
EUndegroundEntranceState
.OPENING_G)
298
{
299
SetLEDState
(ELEDColors.GREEN,
ELEDState
.ON);
300
}
301
}
302
break
;
303
case
EUndegroundDoorType.SMALL:
304
{
305
if
(newState ==
EUndegroundEntranceState
.OPENING_A)
306
{
307
SetLEDState
(ELEDColors.RED,
ELEDState
.ON);
308
SetLEDState
(ELEDColors.GREEN,
ELEDState
.BLINKING);
309
}
310
else
if
(newState ==
EUndegroundEntranceState
.OPENING_B)
311
{
312
SetLEDState
(ELEDColors.RED,
ELEDState
.OFF);
313
SetLEDState
(ELEDColors.GREEN,
ELEDState
.ON);
314
}
315
else
if
(newState ==
EUndegroundEntranceState
.CLOSING_A)
316
{
317
SetLEDState
(ELEDColors.RED,
ELEDState
.BLINKING);
318
SetLEDState
(ELEDColors.GREEN,
ELEDState
.ON);
319
}
320
if
(newState ==
EUndegroundEntranceState
.CLOSING_B || newState ==
EUndegroundEntranceState
.CLOSED)
321
{
322
SetLEDState
(ELEDColors.RED,
ELEDState
.ON);
323
SetLEDState
(ELEDColors.GREEN,
ELEDState
.OFF);
324
}
325
}
326
break
;
327
}
328
}
329
330
331
protected
void
UpdateLED
(
string
selection,
string
color)
332
{
333
int
selectionIdx = GetHiddenSelectionIndex(selection);
334
SetObjectTexture(selectionIdx, color);
335
//Print("selection: " +selection + ", color: " + color +", selectionIdx: "+ selectionIdx);
336
}
337
338
void
ToggleFlipFlop
()
339
{
340
m_BlinkingFlipFlop
= !
m_BlinkingFlipFlop
;
341
OnLEDStateChanged
();
342
}
343
344
void
OnPanelUsedSynchronized
()
345
{
346
PlaySoundSet(
m_ActivationSound
,
"UndergroundDoor_PanelActivation_SoundSet"
, 0, 0 );
347
}
348
349
override
void
OnVariablesSynchronized
()
350
{
351
if
(m_PanelWasUsed !=
m_PanelWasUsedPrev
)
352
{
353
if
(m_PanelWasUsed)
354
{
355
OnPanelUsedSynchronized
();
356
}
357
m_PanelWasUsedPrev
= m_PanelWasUsed;
358
}
359
}
360
361
}
OFF
class EconomyOutputStrings OFF
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition
effectsound.c:5
House
Definition
crashbase.c:2
Land_Underground_EntranceBase
Definition
land_underground_entrance.c:52
Land_Underground_EntranceBase::CanManipulate
bool CanManipulate(Param param=null)
Definition
land_underground_entrance.c:113
Land_Underground_EntranceBase::m_DoorType
EUndegroundDoorType m_DoorType
Definition
land_underground_entrance.c:59
Land_Underground_EntranceBase::Manipulate
void Manipulate(Param param=null)
Definition
land_underground_entrance.c:118
Timer
Definition
dayzplayerimplement.c:39
vector
Definition
enconvert.c:119
vector::DistanceSq
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
RED
const int RED
Definition
colors.c:74
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition
contaminatedarea_dynamic.c:94
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
BLINKING
@ BLINKING
Definition
displaystatus.c:6
ErrorEx
enum ShapeType ErrorEx
GetPosition
vector GetPosition()
Get the world position of the Effect.
Definition
effect.c:473
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition
tools.c:8
EUndegroundEntranceState
EUndegroundEntranceState
Definition
land_underground_entrance.c:2
GREEN
enum ELEDState GREEN
SELECTION_NAME_LED_RED
const string SELECTION_NAME_LED_RED
Definition
land_underground_panel.c:25
UnregisterPanel
static void UnregisterPanel(Land_Underground_Panel panel)
Definition
land_underground_panel.c:112
~Land_Underground_Panel
void ~Land_Underground_Panel()
Definition
land_underground_panel.c:46
RegisterEntrance
static void RegisterEntrance(Land_Underground_EntranceBase entrance)
Definition
land_underground_panel.c:78
COLOR_LED_OFF
const string COLOR_LED_OFF
Definition
land_underground_panel.c:21
RegisterPanel
static void RegisterPanel(Land_Underground_Panel panel)
Definition
land_underground_panel.c:103
ResetPanelUsed
void ResetPanelUsed()
Definition
land_underground_panel.c:264
m_LedStateRed
ELEDState m_LedStateRed
Definition
land_underground_panel.c:35
Land_Underground_Panel
void Land_Underground_Panel()
Definition
land_underground_panel.c:38
OnPanelUsedSynchronized
void OnPanelUsedSynchronized()
Definition
land_underground_panel.c:344
GetLinkedDoorType
EUndegroundDoorType GetLinkedDoorType()
Definition
land_underground_panel.c:128
ToggleFlipFlop
void ToggleFlipFlop()
Definition
land_underground_panel.c:338
OnDoorStateChangedClient
void OnDoorStateChangedClient(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
Definition
land_underground_panel.c:270
SELECTION_NAME_LED_GREEN
const string SELECTION_NAME_LED_GREEN
Definition
land_underground_panel.c:26
COLOR_LED_GREEN
const string COLOR_LED_GREEN
Definition
land_underground_panel.c:22
ELEDState
ELEDState
Definition
land_underground_panel.c:2
ON
@ ON
Definition
land_underground_panel.c:5
m_Panels
static ref set< Land_Underground_Panel > m_Panels
Definition
land_underground_panel.c:17
SetBlinkingTimer
void SetBlinkingTimer(bool enable)
Definition
land_underground_panel.c:186
m_PanelWasUsedPrev
bool m_PanelWasUsed bool m_PanelWasUsedPrev
Definition
land_underground_panel.c:29
m_Entrances
enum ELEDState m_Entrances
CanInteract
bool CanInteract()
Definition
land_underground_panel.c:51
UpdateLED
void UpdateLED(string selection, string color)
Definition
land_underground_panel.c:331
Interact
void Interact()
Definition
land_underground_panel.c:61
m_LedStateGreen
ELEDState m_LedStateGreen
Definition
land_underground_panel.c:36
m_ActivationSound
EffectSound m_ActivationSound
Definition
land_underground_panel.c:33
m_LinkedDoor
Land_Underground_EntranceBase m_LinkedDoor
Definition
land_underground_panel.c:19
GetClosestDoor
Land_Underground_EntranceBase GetClosestDoor()
Definition
land_underground_panel.c:140
UnregisterEntrance
static void UnregisterEntrance(Land_Underground_EntranceBase entrance)
Definition
land_underground_panel.c:87
OnLEDStateChanged
void OnLEDStateChanged()
Definition
land_underground_panel.c:205
SetLEDState
void SetLEDState(ELEDColors color, ELEDState state)
Definition
land_underground_panel.c:164
GetLinkedDoor
Land_Underground_EntranceBase GetLinkedDoor()
Definition
land_underground_panel.c:133
COLOR_LED_RED
const string COLOR_LED_RED
Definition
land_underground_panel.c:23
m_FlipFlopTimer
ref Timer m_FlipFlopTimer
Definition
land_underground_panel.c:31
m_BlinkingFlipFlop
bool m_BlinkingFlipFlop
Definition
land_underground_panel.c:30
Games
Dayz
scripts
4_world
entities
building
underground
entrance
land_underground_panel.c
Generated by
1.17.0