Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
undergroundarealoader.c
Go to the documentation of this file.
2{
4
5 static void SpawnParentedTriggers(EntityAI parent)
6 {
7 int networkIdLow, networkIdHigh;
8 parent.GetNetworkID(networkIdLow, networkIdHigh);
9
11 if (jsonData && jsonData.Triggers)
12 {
13 foreach (int index, auto data : jsonData.Triggers)
14 {
15 if (data.CustomSpawn)
16 {
17 if (data.ParentNetworkId.Count() == 2 && data.ParentNetworkId[0] == networkIdLow && data.ParentNetworkId[1] == networkIdHigh)
18 SpawnTriggerCarrier(parent, index, data);
19 }
20 }
21 }
22 }
23
24 static void SpawnTriggerCarrier(EntityAI parent, int index, JsonUndergroundAreaTriggerData data)
25 {
26 UndergroundTriggerCarrierBase carrier = UndergroundTriggerCarrierBase.Cast(g_Game.CreateObjectEx("UndergroundTriggerCarrier", data.GetPosition(), ECE_NONE));
27 if (carrier)
28 {
29 carrier.SetParent(parent);
30 carrier.SetIndex(index);
31 carrier.SetOrientation(data.GetOrientation());
32 }
33 }
34}
35
36class JsonUndergroundAreaBreadcrumb
37{
39 {
40 return Vector(Position[0],Position[1],Position[2]);
41 }
42
46 float Radius;
47 bool LightLerp; // only used in LinePointFade
48
50}
51
53{
54 string Type;
55 ref TStringArray Params;
56}
57
59{
61
63 {
64 SelectionName = params[0];
65 }
66}
67
69{
71 {
72 return Vector(Position[0],Position[1],Position[2]);
73 }
74
76 {
77 return Vector(Orientation[0],Orientation[1],Orientation[2]);
78 }
80 {
81 return Vector(Size[0],Size[1],Size[2]);
82 }
83
84 bool CustomSpawn;
85 string Tag;
86 ref TIntArray ParentNetworkId;
87
88 ref array<float> Position;
89 ref array<float> Orientation;
90 ref array<float> Size;
91 float EyeAccommodation;
92 float InterpolationSpeed;
93 bool UseLinePointFade; // simple fade between points which are defined using existing breadcrumbs array
94 string AmbientSoundType; // type of ambient sound which will be played by sound controller
95 string AmbientSoundSet; // manual playback of ambient sound
96
98
99};
100
101
103{
104 private static string m_Path = "$mission:cfgundergroundtriggers.json";
105
106 static ref JsonUndergroundTriggers m_JsonData;
107
108 static JsonUndergroundTriggers GetData()
109 {
110 if (!FileExist(m_Path))
111 {
112 // We fallback to check in data and notify user file was not found in mission
113 PrintToRPT("[WARNING] :: [UndergroundAreaLoader GetData()] :: file not found in MISSION folder, your path is " + m_Path + " Attempting DATA folder");
114
115 string worldName;
116 g_Game.GetWorldName(worldName);
117 m_Path = string.Format("dz/worlds/%1/ce/cfgundergroundtriggers.json", worldName);
118
119 if (!FileExist(m_Path))
120 {
121 PrintToRPT("[WARNING] :: [UndergroundAreaLoader GetData()] ::file not found in DATA folder, your path is " + m_Path);
122 return null; // Nothing could be read, just end here
123 }
124 }
125
126 string errorMessage;
128 if (!JsonFileLoader<JsonUndergroundTriggers>.LoadFile(m_Path, data, errorMessage))
129 ErrorEx(errorMessage);
130
131 return data;
132 }
133
134 static void SpawnAllTriggerCarriers()
135 {
136 if (!m_JsonData)
137 {
138 m_JsonData = GetData();
139 }
140
141 if (!m_JsonData || !m_JsonData.Triggers)
142 {
143 return;
144 }
145
146 foreach (int i, auto data:m_JsonData.Triggers)
147 {
148 if (data.CustomSpawn)
149 continue;
150
151 SpawnTriggerCarrierEx(i, data);
152 }
153 }
154
155 static UndergroundTriggerCarrierBase SpawnTriggerCarrierEx(int index, JsonUndergroundAreaTriggerData data)
156 {
157 UndergroundTriggerCarrierBase carrier = UndergroundTriggerCarrierBase.Cast(g_Game.CreateObjectEx("UndergroundTriggerCarrier", data.GetPosition(), ECE_NONE));
158 if (carrier)
159 {
160 carrier.SetIndex(index);
161 carrier.SetOrientation(data.GetOrientation());
162 }
163
164 return carrier;
165 }
166
167 static void SpawnTriggerCarrier(int index, JsonUndergroundAreaTriggerData data)
168 {
169 SpawnTriggerCarrierEx(index, data);
170 }
171
172 //---------------------------------------------------------------------------------------
173 static void SyncDataSend(PlayerIdentity identity)
174 {
175 g_Game.RPCSingleParam(null, ERPCs.RPC_UNDERGROUND_SYNC, new Param1<JsonUndergroundTriggers>(m_JsonData), true, identity);
176 }
177
178 //---------------------------------------------------------------------------------------
179
180 static void OnRPC(ParamsReadContext ctx)
181 {
182 Param1<JsonUndergroundTriggers> data = new Param1< JsonUndergroundTriggers>(null);
183
184 if ( ctx.Read(data) )
185 {
186 m_JsonData = data.param1;
187 }
188 else
189 {
190 ErrorEx("UndergroundAreaLoader datasynced - failed to read");
191 }
192 }
193
194}
vector GetOrientation()
const int ECE_NONE
The class that will be instanced (moddable).
Definition gameplay.c:389
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
ERPCs
Definition erpcs.c:2
Serializer ParamsReadContext
Definition gameplay.c:15
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
enum ShapeType ErrorEx
array< string > TStringArray
Definition enscript.c:712
array< int > TIntArray
Definition enscript.c:714
proto bool FileExist(string name)
Check existence of file.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
int GetSize()
float EyeAccommodation
float Radius
ref BreadcrumbExternalValueController ExternalValueController
bool LightLerp
bool UseRaycast
void BreadcrumbDoorStateController(TStringArray params)
class BreadcrumbExternalValueController SelectionName
ref array< float > Position