18 if (
g_Game.ServerConfigGetInt(
"enableCfgGameplayFile" ))
27 g_Game.GetWorldName(worldName);
33 string errorMessage,
path;
35 path =
string.Format(
"$mission:%1", filename);
36 if (!JsonFileLoader<PlayerRestrictedAreaInstance>.LoadFile(
path, area, errorMessage))
39 path =
string.Format(
"dz/worlds/%1/ce/%2", worldName, filename);
41 if (!JsonFileLoader<PlayerRestrictedAreaInstance>.LoadFile(
path, area, errorMessage))
49 m_Data.m_Areas.Insert(area);
67 g_Game.RPCSingleParam(null,
ERPCs.RPC_PLAYERRESTRICTEDAREAS_SYNC,
new Param1<CfgPlayerRestrictedAreaJsonData>(
m_Data),
true, identity);
72 Param1<CfgPlayerRestrictedAreaJsonData> data =
new Param1<CfgPlayerRestrictedAreaJsonData>(null);
81 ErrorEx(
"CfgPlayerRestrictedAreaHandler - client failed to read incoming data");
125 float closestDist =
float.MAX;
131 if (currentDist < closestDist)
134 closestDist = currentDist;
144 foreach (PRAShapeBoxData boxData : area.m_PRABoxDataTranslated)
148 matPlayer4[3] = point;
161 translatedDta.Clear();
165 translatedDta.Insert(vertexPos[0]);
166 translatedDta.Insert(vertexPos[1]);
169 if (
Math2D.IsPointInPolygon(translatedDta,point[0],point[2]))
197 shp.SetMatrix(boxData.m_Mat4);
234 polygonVectors.Insert(
Vector(vertexPos[0],
g_Game.SurfaceY(vertexPos[0],vertexPos[1]) + 2,vertexPos[1]));
237 int count = polygonVectors.Count();
238 for (
int i = 0; i < count; ++i)
240 current = polygonVectors[i];
243 first = polygonVectors[i];
252 polygonVectors.Clear();
static TStringArray GetPlayerRestrictedAreaFiles()
static ref TStringArray m_PRAFiles
static bool IsPointInPlayerRestrictedArea(vector point, out PlayerRestrictedAreaInstance hitArea)
static bool IsPointInAreaPolygon(notnull PlayerRestrictedAreaInstance area, vector point)
static PlayerRestrictedAreaInstance GetClosestArea(vector point)
static bool m_Initialized
static bool IsPointInPlayerRestrictedAreaClosest(vector point, out PlayerRestrictedAreaInstance hitArea)
static void DrawBoxesDebug(bool draw)
ref array< Shape > m_DbgShapesPolygonLines
static bool IsCylinderInAreaBox(notnull PlayerRestrictedAreaInstance area, vector point, float cylinderRadius=0.25, float cylinderHeight=1)
default cylinder values sufficient for player detection
static void SyncDataSend(notnull PlayerIdentity identity)
static bool IsInitialized()
static ref CfgPlayerRestrictedAreaJsonData m_Data
static void DrawPolygonLinesDebug(bool draw)
ref array< Shape > m_DbgShapesBoxes
static void OnRPC(ParamsReadContext ctx)
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
DrawLine \nFlags: ShapeFlags.NOZBUFFER ShapeFlags.NOZUPDATE ShapeFlags.DOUBLESIDE ShapeFlags....
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
The class that will be instanced (moddable).
ref array< ref PRAShapeBoxData > m_PRABoxDataTranslated
ref array< ref array< ref array< float > > > PRAPolygons
3D, not used directly!
proto bool Read(void value_in)
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.
Serializer ParamsReadContext
array< string > TStringArray
proto bool FileExist(string name)
Check existence of file.
enum WindingOrder Math2D()
static proto bool IntersectCylinderOBB(vector mins, vector maxs, vector obbMat[4], vector cylMat[4], float cylinderRadius, float cylinderHeight)
Tests whether cylinder is intersecting oriented box.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.