DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CfgPlayerRestrictedAreaJsonData.c
См. документацию.
2{
5
7 {
8 m_ValidatedAreas.Clear();
9
10 foreach (PlayerRestrictedAreaInstance instance : m_Areas)
11 {
12 instance.Initialize();
13 if (instance.IsValid())
14 m_ValidatedAreas.Insert(instance);
15 }
16
17 m_Areas.Clear();
18
19 return m_ValidatedAreas.Count() > 0;
20 }
21};
22
24{
25 void PRAShapeDataBase(array<ref array<float>> shapeDataArray)
26 {
27 InitPRAShapeData(shapeDataArray);
28 }
29
30 void InitPRAShapeData(array<ref array<float>> shapeDataArray)
31 {
32 }
33}
34
35class PRAShapeBoxData : PRAShapeDataBase
36{
40
41 override void InitPRAShapeData(array<ref array<float>> shapeDataArray)
42 {
43 vector sizes = Vector(shapeDataArray[0][0],shapeDataArray[0][1],shapeDataArray[0][2]);
44 vector angle = Vector(shapeDataArray[1][0],shapeDataArray[1][1],shapeDataArray[1][2]);
45 vector targetPoint = Vector(shapeDataArray[2][0],shapeDataArray[2][1],shapeDataArray[2][2]);
46
47 m_Mins = Vector(-sizes[0]/2,-sizes[1]/2,-sizes[2]/2);
48 m_Maxs = Vector(sizes[0]/2,sizes[1]/2,sizes[2]/2);
49
50 vector mat3[3];
51 Math3D.YawPitchRollMatrix(angle,mat3);
52
53 m_Mat4[0] = mat3[0];
54 m_Mat4[1] = mat3[1];
55 m_Mat4[2] = mat3[2];
56 m_Mat4[3] = targetPoint;
57 }
58}
59
61{
62 //private
63 private bool m_IsValid = false;
64 private int m_LastUsedSafePosIdx = -1;
67 //private ref map<vector,int> m_TimeIndexedSafePositions;
68 private vector m_CenterPos2D; //averaged center position, used for initial filtering
69
70 //public
71 string areaName = ""; //optional
76
78
80 {
81 if (m_IsValid)
82 return;
83
84 m_IsValid = false;
87 }
88
90 {
91 if (PRABoxes.Count() == 0 && PRAPolygons.Count() == 0)
92 {
93 Debug.Log("No valid coordinates in 'PRABoxes' or 'PRAPolygons' for area: " + areaName,"n/a","n/a","","PlayerRestrictedAreaInstance");
94 return false;
95 }
96
97 float xMin,zMin = float.MAX;
98 float xMax,zMax = float.MIN;
99
100 foreach (array<ref array<float>> boxFloatsData : PRABoxes)
101 {
102 if (boxFloatsData.Count() != 3)
103 {
104 Debug.Log("Invalid box defined in " + areaName + ". Box needs to have sizes, rotation, and position defined!","n/a","n/a","","PlayerRestrictedAreaInstance");
105 return false;
106 }
107
108 array<float> boxVectors;
109 //sizes
110 boxVectors = boxFloatsData[0];
111 if (boxVectors.Count() != 3)
112 {
113 Debug.Log("Invalid box defined in " + areaName + ". Box size needs to be in an XYZ format!","n/a","n/a","","PlayerRestrictedAreaInstance");
114 return false;
115 }
116
117 //rotation
118 boxVectors = boxFloatsData[1];
119 if (boxVectors.Count() != 3)
120 {
121 Debug.Log("Invalid box defined in " + areaName + ". Box rotation needs to be in an XYZ format!","n/a","n/a","","PlayerRestrictedAreaInstance");
122 return false;
123 }
124
125 //position
126 boxVectors = boxFloatsData[2];
127 if (boxVectors.Count() != 3)
128 {
129 Debug.Log("Invalid box defined in " + areaName + ". Box position needs to be in an XYZ format!","n/a","n/a","","PlayerRestrictedAreaInstance");
130 return false;
131 }
132
133 //translate to data
134 PRAShapeBoxData dta = new PRAShapeBoxData(boxFloatsData);
135 if (dta)
136 {
137 m_PRABoxDataTranslated.Insert(dta);
138
139 xMin = Math.Min(xMin,dta.m_Mins[0]);
140 zMin = Math.Min(zMin,dta.m_Mins[2]);
141 xMax = Math.Max(xMax,dta.m_Maxs[0]);
142 zMax = Math.Max(zMax,dta.m_Maxs[2]);
143 }
144 }
145
146 foreach (array<ref array<float>> polygonData : PRAPolygons)
147 {
148 if (polygonData.Count() < 3)
149 {
150 Debug.Log("Invalid polygon defined in " + areaName + ". At least 3 points necessary!","n/a","n/a","","PlayerRestrictedAreaInstance");
151 return false;
152 }
153
154 foreach (array<float> polygonCoords : polygonData)
155 {
156 if (polygonCoords.Count() != 2)
157 {
158 Debug.Log("Invalid polygon defined in " + areaName + ". Polygon coordinates need to be in a XZ format!","n/a","n/a","","PlayerRestrictedAreaInstance");
159 return false;
160 }
161
162 xMin = Math.Min(xMin,polygonCoords[0]);
163 zMin = Math.Min(zMin,polygonCoords[1]);
164 xMax = Math.Max(xMax,polygonCoords[0]);
165 zMax = Math.Max(zMax,polygonCoords[1]);
166 }
167 }
168
169 m_CenterPos2D = Vector(((xMin + xMax) / 2), 0, ((zMin + zMax) / 2));
170
171 return true;
172 }
173
175 {
176 if (safePositions2D.Count() == 0 && safePositions3D.Count() == 0)
177 {
178 Debug.Log("Undefined safe positions for area: " + areaName,"n/a","n/a","","PlayerRestrictedAreaInstance");
179 return false;
180 }
181
183
184 foreach (array<float> arr2d : safePositions2D)
185 {
186 m_TranslatedSafePositions3D.Insert(Vector(arr2d[0],GetGame().SurfaceY(arr2d[0],arr2d[1]),arr2d[1]));
187 }
188
189 foreach (array<float> arr3d : safePositions3D)
190 {
191 m_TranslatedSafePositions3D.Insert(Vector(arr3d[0],arr3d[1],arr3d[2]));
192 }
193
194 return true;
195 }
196
197 bool IsValid()
198 {
199 return m_IsValid;
200 }
201
203 {
204 return m_CenterPos2D;
205 }
206
207 //----------------------------------------------------------
208 //getters
209
211 {
212 vector closestPos = targetPos;
213 float smallestDist = float.MAX;
214 float dist;
215
216 foreach (vector pos : m_TranslatedSafePositions3D)
217 {
218 dist = vector.DistanceSq(targetPos, pos);
219 if (dist < smallestDist)
220 {
221 smallestDist = dist;
222 closestPos = pos;
223 }
224 }
225 return closestPos;
226 }
227
248}
vector m_Mat4[4]
vector m_Maxs
class PRAShapeDataBase m_Mins
ref array< ref PlayerRestrictedAreaInstance > m_Areas
ref array< ref PlayerRestrictedAreaInstance > m_ValidatedAreas
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения Debug.c:122
Определения Debug.c:2
Определения EnMath3D.c:28
Определения EnMath.c:7
void PRAShapeDataBase(array< ref array< float > > shapeDataArray)
void InitPRAShapeData(array< ref array< float > > shapeDataArray)
ref array< ref array< ref array< float > > > PRABoxes
ref array< ref array< float > > safePositions2D
vector GetClosestSafePos3D(vector targetPos)
ref array< ref PRAShapeBoxData > m_PRABoxDataTranslated
ref array< vector > m_TranslatedSafePositions3D
ref array< ref array< ref array< float > > > PRAPolygons
3D, not used directly!
vector GetRandomSafePos3D(vector targetPos)
ref array< ref array< float > > safePositions3D
ref array< vector > m_RandomizedSafePositions3D
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
Определения EnConvert.c:106
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Min(float x, float y)
Returns smaller of two given values.