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