Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
undergroundarealoader.c
Go to the documentation of this file.
2{
4}
5
6
7class JsonUndergroundAreaBreadcrumb
8{
10 {
11 return Vector(Position[0],Position[1],Position[2]);
12 }
13
17 float Radius;
18 bool LightLerp; // only used in LinePointFade
19}
20
22{
23 vector GetPosition()
24 {
25 return Vector(Position[0],Position[1],Position[2]);
26 }
27
28 vector GetOrientation()
29 {
30 return Vector(Orientation[0],Orientation[1],Orientation[2]);
31 }
32 vector GetSize()
33 {
34 return Vector(Size[0],Size[1],Size[2]);
35 }
36
37 ref array<float> Position;
38 ref array<float> Orientation;
39 ref array<float> Size;
40 float EyeAccommodation;
41 float InterpolationSpeed;
42 bool UseLinePointFade; // simple fade between points which are defined using existing breadcrumbs array
43 string AmbientSoundType; // type of ambient sound which will be played by sound controller
44
46
47};
48
49
51{
52 private static string m_Path = "$mission:cfgundergroundtriggers.json";
53
54 static ref JsonUndergroundTriggers m_JsonData;
55
56
57 static JsonUndergroundTriggers GetData()
58 {
59 if (!FileExist(m_Path))
60 {
61 // We fallback to check in data and notify user file was not found in mission
62 PrintToRPT("[WARNING] :: [UndergroundAreaLoader GetData()] :: file not found in MISSION folder, your path is " + m_Path + " Attempting DATA folder");
63
64 string worldName;
65 GetGame().GetWorldName(worldName);
66 m_Path = string.Format("dz/worlds/%1/ce/cfgundergroundtriggers.json", worldName);
67
68 if (!FileExist(m_Path))
69 {
70 PrintToRPT("[WARNING] :: [UndergroundAreaLoader GetData()] ::file not found in DATA folder, your path is " + m_Path);
71 return null; // Nothing could be read, just end here
72 }
73 }
74
75 string errorMessage;
77 if (!JsonFileLoader<JsonUndergroundTriggers>.LoadFile(m_Path, data, errorMessage))
78 ErrorEx(errorMessage);
79
80 return data;
81 }
82
83
84 static void SpawnAllTriggerCarriers()
85 {
86 if (!m_JsonData)
87 {
88 m_JsonData = GetData();
89 }
90
91 if (!m_JsonData || !m_JsonData.Triggers)
92 {
93 return;
94 }
95
96 foreach (int i, auto data:m_JsonData.Triggers)
97 {
98 SpawnTriggerCarrier(i, data);
99 }
100 }
101
102 static void SpawnTriggerCarrier(int index, JsonUndergroundAreaTriggerData data)
103 {
104
105 UndergroundTriggerCarrierBase carrier = UndergroundTriggerCarrierBase.Cast(GetGame().CreateObjectEx( "UndergroundTriggerCarrier", data.GetPosition(), ECE_NONE ));
106 //Print("spawning trigger carrier at pos :" +data.GetPosition());
107 if (carrier)
108 {
109 carrier.SetIndex(index);
110 carrier.SetOrientation(data.GetOrientation());
111 }
112 }
113
114 //---------------------------------------------------------------------------------------
115 static void SyncDataSend(PlayerIdentity identity)
116 {
117 GetGame().RPCSingleParam(null, ERPCs.RPC_UNDERGROUND_SYNC, new Param1<JsonUndergroundTriggers>(m_JsonData), true, identity);
118 }
119
120 //---------------------------------------------------------------------------------------
121
122 static void OnRPC(ParamsReadContext ctx)
123 {
124 Param1<JsonUndergroundTriggers> data = new Param1< JsonUndergroundTriggers>(null);
125
126 if ( ctx.Read(data) )
127 {
128 m_JsonData = data.param1;
129 }
130 else
131 {
132 ErrorEx("UndergroundAreaLoader datasynced - failed to read");
133 }
134 }
135
136}
const int ECE_NONE
The class that will be instanced (moddable)
Definition gameplay.c:389
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ERPCs
Definition erpcs.c:2
proto native CGame GetGame()
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
enum ShapeType ErrorEx
proto bool FileExist(string name)
Check existence of file.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
class JsonUndergroundAreaTriggerData GetPosition
float EyeAccommodation
float Radius
bool LightLerp
bool UseRaycast
ref array< float > Position