Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
land_warheadstorage_bunker_facility.c
Go to the documentation of this file.
2{
3 protected const float DOOR_AUTOCLOSE_TIME = 12; //how long before the door auto-close after being opened
4
6
7 override void DeferredInit()
8 {
9 g_Game.RegisterNetworkStaticObject(this);
10
11 if (g_Game.IsServer())
12 {
13 for (int i = 0; i < GetDoorCount(); ++i)
15
17 }
18 }
19
20 override bool CanDoorBeOpened(int doorIndex, bool checkIfLocked = false)
21 {
22 if (!super.CanDoorBeOpened(doorIndex, checkIfLocked))
23 return false;
24
25 switch (doorIndex)
26 {
27 case 7:
28 return IsDoorClosed(8);
29 case 8:
30 return IsDoorClosed(7);
31 }
32
33 return true;
34 }
35
36 override bool CanDoorBeClosed(int doorIndex)
37 {
38 if (IsPressureDoor(doorIndex))
39 return IsDoorOpen(doorIndex) && !IsDoorOpening(doorIndex);
40
41 return super.CanDoorBeClosed(doorIndex);
42 }
43
44 override void OnDoorOpenStart(DoorStartParams params)
45 {
48
49 if (IsPressureDoor(params.param1))
50 {
51 Timer doorTimer = new Timer();
52 doorTimer.Run(DOOR_AUTOCLOSE_TIME, this, "AutoCloseDoor", new Param1<int>(params.param1));
53 m_AutoCloseTimers.Set(params.param1, doorTimer);
54 }
55 }
56
57 override void OnDoorCloseStart(DoorStartParams params)
58 {
59 RemoveDoorTimer(params.param1);
60 }
61
63 {
64 super.OnSpawnByObjectSpawner(item);
65
66 if (item.customString == string.Empty)
67 return;
68
70 if (jsonData && jsonData.Triggers)
71 {
72 foreach (int index, auto triggerData : jsonData.Triggers)
73 {
74 if (triggerData.CustomSpawn)
75 {
76 //JSON: "customString": "undergroundTriggerTag=TAG_NAME"
77 TStringArray customStringData = new TStringArray();
78 item.customString.Split(";", customStringData);
79
80 foreach (string entry : customStringData)
81 {
82 TStringArray optionValuePair = new TStringArray();
83 entry.Split("=", optionValuePair);
84 if (optionValuePair[0] == "undergroundTriggerTag")
85 {
86 if (optionValuePair[1] == triggerData.Tag)
87 JsonUndergroundTriggers.SpawnTriggerCarrier(this, index, triggerData);
88 }
89 }
90 }
91 }
92 }
93 }
94
95 private void AutoCloseDoor(int doorIndex)
96 {
97 CloseDoor(doorIndex);
98 RemoveDoorTimer(doorIndex);
99 }
100
101 private void RemoveDoorTimer(int doorIndex)
102 {
104 m_AutoCloseTimers.Remove(doorIndex);
105 }
106
107 private bool IsPressureDoor(int doorIndex)
108 {
109 switch (doorIndex)
110 {
111 case 7:
112 case 8:
113 return true;
114 }
115
116 return false;
117 }
118
119}
Param1< int > DoorStartParams
Definition building.c:1
proto native bool IsDoorClosed(int index)
When the phase is at the close phase target (0.0).
proto native int GetDoorCount()
Returns the number of the doors in the building.
proto native bool IsDoorOpening(int index)
When the wanted phase is at the open phase target (1.0).
proto native bool IsDoorOpen(int index)
When the door is requested to be fully open (animation wanted phase is greater than 0....
proto native void CloseDoor(int index)
Attempts to close the door.
void House()
Definition building.c:87
static void SpawnParentedTriggers(EntityAI parent)
static void SpawnTriggerCarrier(EntityAI parent, int index, JsonUndergroundAreaTriggerData data)
ref array< ref JsonUndergroundAreaTriggerData > Triggers
override bool CanDoorBeOpened(int doorIndex, bool checkIfLocked=false)
override void OnSpawnByObjectSpawner(ITEM_SpawnerObject item)
override void OnDoorOpenStart(DoorStartParams params)
override void OnDoorCloseStart(DoorStartParams params)
static JsonUndergroundTriggers GetData()
DayZGame g_Game
Definition dayzgame.c:3942
array< string > TStringArray
Definition enscript.c:712
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Definition enstring.c:396
static const string Empty
Definition enstring.c:7