DayZ 1.24
Loading...
Searching...
No Matches
Land_Underground_Panel.c File Reference

Go to the source code of this file.

Enumerations

enum  ELEDState { OFF , BLINKING , ON }
 

Functions

void Land_Underground_Panel ()
 
void ~Land_Underground_Panel ()
 
bool CanInteract ()
 
void Interact ()
 
static void RegisterEntrance (Land_Underground_EntranceBase entrance)
 
static void UnregisterEntrance (Land_Underground_EntranceBase entrance)
 
static void RegisterPanel (Land_Underground_Panel panel)
 
static void UnregisterPanel (Land_Underground_Panel panel)
 
EUndegroundDoorType GetLinkedDoorType ()
 
Land_Underground_EntranceBase GetLinkedDoor ()
 
Land_Underground_EntranceBase GetClosestDoor ()
 
void SetLEDState (ELEDColors color, ELEDState state)
 
void SetBlinkingTimer (bool enable)
 
void OnLEDStateChanged ()
 
void ResetPanelUsed ()
 
void OnDoorStateChangedClient (EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
 
void UpdateLED (string selection, string color)
 
void ToggleFlipFlop ()
 
void OnPanelUsedSynchronized ()
 
override void OnVariablesSynchronized ()
 

Variables

enum ELEDState RED
 
enum ELEDState GREEN
 
enum ELEDState m_Entrances
 
static ref set< Land_Underground_Panelm_Panels
 
Land_Underground_EntranceBase m_LinkedDoor
 
const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)"
 
const string COLOR_LED_GREEN = "#(argb,8,8,3)color(0,1,0,1.0,co)"
 
const string COLOR_LED_RED = "#(argb,8,8,3)color(1,0,0,1.0,co)"
 
const string SELECTION_NAME_LED_RED = "LED_Red"
 
const string SELECTION_NAME_LED_GREEN = "LED_Green"
 
bool m_PanelWasUsed bool m_PanelWasUsedPrev
 
bool m_BlinkingFlipFlop
 
ref Timer m_FlipFlopTimer
 
EffectSound m_ActivationSound
 
ELEDState m_LedStateRed
 
ELEDState m_LedStateGreen
 

Enumeration Type Documentation

◆ ELEDState

Enumerator
OFF 
BLINKING 
ON 

Definition at line 1 of file Land_Underground_Panel.c.

2{
3 OFF,
5 ON,
6}

Function Documentation

◆ CanInteract()

bool CanInteract ( )

◆ GetClosestDoor()

Land_Underground_EntranceBase GetClosestDoor ( )

Definition at line 124 of file Land_Underground_Panel.c.

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 }
enum ELEDState m_Entrances
class JsonUndergroundAreaTriggerData GetPosition
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.

References vector::DistanceSq(), GetPosition, and m_Entrances.

Referenced by GetLinkedDoor().

◆ GetLinkedDoor()

Land_Underground_EntranceBase GetLinkedDoor ( )

Definition at line 117 of file Land_Underground_Panel.c.

118 {
119 if (!m_LinkedDoor)
121 return m_LinkedDoor;
122 }
Land_Underground_EntranceBase m_LinkedDoor
Land_Underground_EntranceBase GetClosestDoor()

References GetClosestDoor(), and m_LinkedDoor.

Referenced by CanInteract(), GetLinkedDoorType(), Interact(), and Land_Underground_Panel_Lever::Interact().

◆ GetLinkedDoorType()

EUndegroundDoorType GetLinkedDoorType ( )

Definition at line 112 of file Land_Underground_Panel.c.

113 {
114 return GetLinkedDoor().m_DoorType;
115 }

References GetLinkedDoor(), and Land_Underground_EntranceBase::m_DoorType.

Referenced by OnDoorStateChangedClient().

◆ Interact()

void Interact ( )

Definition at line 59 of file Land_Underground_Panel.c.

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 }
void ResetPanelUsed()
proto native CGame GetGame()
enum ShapeType ErrorEx
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, ErrorEx, GetGame(), GetLinkedDoor(), Land_Underground_EntranceBase::Manipulate(), and ResetPanelUsed().

◆ Land_Underground_Panel()

void Land_Underground_Panel ( )

Definition at line 38 of file Land_Underground_Panel.c.

39 {
40 RegisterNetSyncVariableBool("m_PanelWasUsed");
41 RegisterPanel(this);
44 }
static void RegisterPanel(Land_Underground_Panel panel)
void SetLEDState(ELEDColors color, ELEDState state)

References RegisterPanel(), and SetLEDState().

◆ OnDoorStateChangedClient()

void OnDoorStateChangedClient ( EUndegroundEntranceState newState,
EUndegroundEntranceState prevState )

Definition at line 230 of file Land_Underground_Panel.c.

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 }
EUndegroundDoorType GetLinkedDoorType()

References GetLinkedDoorType(), and SetLEDState().

◆ OnLEDStateChanged()

void OnLEDStateChanged ( )

Definition at line 185 of file Land_Underground_Panel.c.

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 }
const string SELECTION_NAME_LED_RED
const string COLOR_LED_OFF
ELEDState m_LedStateRed
const string SELECTION_NAME_LED_GREEN
const string COLOR_LED_GREEN
void SetBlinkingTimer(bool enable)
void UpdateLED(string selection, string color)
ELEDState m_LedStateGreen
const string COLOR_LED_RED
bool m_BlinkingFlipFlop

References COLOR_LED_GREEN, COLOR_LED_OFF, COLOR_LED_RED, m_BlinkingFlipFlop, m_LedStateGreen, m_LedStateRed, SELECTION_NAME_LED_GREEN, SELECTION_NAME_LED_RED, SetBlinkingTimer(), and UpdateLED().

Referenced by Land_Underground_Panel_Lever::OnPanelUsedSynchronized(), SetLEDState(), and ToggleFlipFlop().

◆ OnPanelUsedSynchronized()

void OnPanelUsedSynchronized ( )
protected

Definition at line 292 of file Land_Underground_Panel.c.

293 {
294 PlaySoundSet(m_ActivationSound, "UndergroundDoor_PanelActivation_SoundSet", 0, 0);
295 }
EffectSound m_ActivationSound

References m_ActivationSound.

Referenced by OnVariablesSynchronized().

◆ OnVariablesSynchronized()

override void OnVariablesSynchronized ( )
protected

Definition at line 297 of file Land_Underground_Panel.c.

298 {
300 {
301 if (m_PanelWasUsed)
304 }
305 }
void OnPanelUsedSynchronized()
bool m_PanelWasUsed bool m_PanelWasUsedPrev

References m_PanelWasUsedPrev, and OnPanelUsedSynchronized().

◆ RegisterEntrance()

static void RegisterEntrance ( Land_Underground_EntranceBase entrance)
static

Definition at line 74 of file Land_Underground_Panel.c.

References m_Entrances.

◆ RegisterPanel()

static void RegisterPanel ( Land_Underground_Panel panel)
static

Definition at line 93 of file Land_Underground_Panel.c.

94 {
95 if (!m_Panels)
97 m_Panels.Insert(panel);
98 }
static ref set< Land_Underground_Panel > m_Panels

References m_Panels.

Referenced by Land_Underground_Panel().

◆ ResetPanelUsed()

void ResetPanelUsed ( )

Definition at line 224 of file Land_Underground_Panel.c.

225 {
226 m_PanelWasUsed = false;
227 SetSynchDirty();
228 }

Referenced by Interact().

◆ SetBlinkingTimer()

void SetBlinkingTimer ( bool enable)

Definition at line 168 of file Land_Underground_Panel.c.

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 }
ref Timer m_FlipFlopTimer

References m_FlipFlopTimer.

Referenced by OnLEDStateChanged().

◆ SetLEDState()

void SetLEDState ( ELEDColors color,
ELEDState state )

Definition at line 146 of file Land_Underground_Panel.c.

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 }
void OnLEDStateChanged()

References m_LedStateGreen, m_LedStateRed, and OnLEDStateChanged().

Referenced by Land_Underground_Panel(), and OnDoorStateChangedClient().

◆ ToggleFlipFlop()

void ToggleFlipFlop ( )
protected

Definition at line 286 of file Land_Underground_Panel.c.

References m_BlinkingFlipFlop, and OnLEDStateChanged().

◆ UnregisterEntrance()

static void UnregisterEntrance ( Land_Underground_EntranceBase entrance)
static

Definition at line 81 of file Land_Underground_Panel.c.

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 }

References ErrorEx, and m_Entrances.

◆ UnregisterPanel()

static void UnregisterPanel ( Land_Underground_Panel panel)
static

Definition at line 100 of file Land_Underground_Panel.c.

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 }

References ErrorEx, and m_Panels.

Referenced by ~Land_Underground_Panel().

◆ UpdateLED()

void UpdateLED ( string selection,
string color )
protected

Definition at line 279 of file Land_Underground_Panel.c.

280 {
281 int selectionIdx = GetHiddenSelectionIndex(selection);
282 SetObjectTexture(selectionIdx, color);
283 //Print("selection: " +selection + ", color: " + color +", selectionIdx: "+ selectionIdx);
284 }

Referenced by EEKilled(), OnCEUpdate(), OnLEDStateChanged(), and OnWasDetached().

◆ ~Land_Underground_Panel()

Definition at line 46 of file Land_Underground_Panel.c.

47 {
48 UnregisterPanel(this);
49 }
static void UnregisterPanel(Land_Underground_Panel panel)

References UnregisterPanel().

Variable Documentation

◆ COLOR_LED_GREEN

const string COLOR_LED_GREEN = "#(argb,8,8,3)color(0,1,0,1.0,co)"

Definition at line 22 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged().

◆ COLOR_LED_OFF

const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)"

Definition at line 21 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged(), and UpdateLED().

◆ COLOR_LED_RED

const string COLOR_LED_RED = "#(argb,8,8,3)color(1,0,0,1.0,co)"

Definition at line 23 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged().

◆ GREEN

enum ELEDState GREEN

◆ m_ActivationSound

EffectSound m_ActivationSound

Definition at line 33 of file Land_Underground_Panel.c.

Referenced by OnPanelUsedSynchronized().

◆ m_BlinkingFlipFlop

bool m_BlinkingFlipFlop

Definition at line 30 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged(), and ToggleFlipFlop().

◆ m_Entrances

◆ m_FlipFlopTimer

ref Timer m_FlipFlopTimer

Definition at line 31 of file Land_Underground_Panel.c.

Referenced by SetBlinkingTimer().

◆ m_LedStateGreen

ELEDState m_LedStateGreen

Definition at line 36 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged(), and SetLEDState().

◆ m_LedStateRed

ELEDState m_LedStateRed

Definition at line 35 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged(), and SetLEDState().

◆ m_LinkedDoor

Definition at line 19 of file Land_Underground_Panel.c.

Referenced by GetLinkedDoor().

◆ m_Panels

◆ m_PanelWasUsedPrev

bool m_PanelWasUsed bool m_PanelWasUsedPrev

Definition at line 29 of file Land_Underground_Panel.c.

Referenced by OnVariablesSynchronized().

◆ RED

◆ SELECTION_NAME_LED_GREEN

const string SELECTION_NAME_LED_GREEN = "LED_Green"

Definition at line 26 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged().

◆ SELECTION_NAME_LED_RED

const string SELECTION_NAME_LED_RED = "LED_Red"

Definition at line 25 of file Land_Underground_Panel.c.

Referenced by OnLEDStateChanged().