DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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}
19
21{
23 {
24 return Vector(Position[0],Position[1],Position[2]);
25 }
26
28 {
30 }
32 {
33 return Vector(Size[0],Size[1],Size[2]);
34 }
35
41
43
44};
45
46
48{
49 private static string m_Path = "$mission:cfgundergroundtriggers.json";
50
52
53
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
73 JsonFileLoader<JsonUndergroundTriggers>.JsonLoadFile( m_Path, data );
74
75 return data;
76 }
77
78
80 {
81 if (!m_JsonData)
82 {
84 }
85
87 {
88 return;
89 }
90
91 foreach (int i, auto data:m_JsonData.Triggers)
92 {
93 SpawnTriggerCarrier(i, data);
94 }
95 }
96
98 {
99
100 UndergroundTriggerCarrierBase carrier = UndergroundTriggerCarrierBase.Cast(GetGame().CreateObjectEx( "UndergroundTriggerCarrier", data.GetPosition(), ECE_NONE ));
101 //Print("spawning trigger carrier at pos :" +data.GetPosition());
102 if (carrier)
103 {
104 carrier.SetIndex(index);
105 carrier.SetOrientation(data.GetOrientation());
106 }
107 }
108
109 //---------------------------------------------------------------------------------------
110 static void SyncDataSend(PlayerIdentity identity)
111 {
112 GetGame().RPCSingleParam(null, ERPCs.RPC_UNDERGROUND_SYNC, new Param1<JsonUndergroundTriggers>(m_JsonData), true, identity);
113 }
114
115 //---------------------------------------------------------------------------------------
116
117 static void OnRPC(ParamsReadContext ctx)
118 {
119 Param1<JsonUndergroundTriggers> data = new Param1< JsonUndergroundTriggers>(null);
120
121 if ( ctx.Read(data) )
122 {
123 m_JsonData = data.param1;
124 }
125 else
126 {
127 ErrorEx("UndergroundAreaLoader datasynced - failed to read");
128 }
129 }
130
131}
const int ECE_NONE
ERPCs
Definition ERPCs.c:2
float EyeAccommodation
float Radius
bool UseRaycast
class JsonUndergroundAreaTriggerData GetPosition
ref array< float > Position
proto void GetWorldName(out string world_name)
void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
Definition Game.c:882
ref array< ref JsonUndergroundAreaBreadcrumb > Breadcrumbs
ref array< ref JsonUndergroundAreaTriggerData > Triggers
The class that will be instanced (moddable)
Definition gameplay.c:378
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Read(void value_in)
static private string m_Path
static void SpawnAllTriggerCarriers()
static void SpawnTriggerCarrier(int index, JsonUndergroundAreaTriggerData data)
static ref JsonUndergroundTriggers m_JsonData
static void SyncDataSend(PlayerIdentity identity)
static JsonUndergroundTriggers GetData()
static void OnRPC(ParamsReadContext ctx)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.