12 protected ref set<SCR_EditorRestrictionZoneEntity>
m_aRestrictionZones =
new set<SCR_EditorRestrictionZoneEntity>();
44 if (!zone || !Replication.IsServer())
62 array<int> players = {};
66 if (players.IsEmpty())
72 vector playerEntityPosition;
73 vector restrictionZonePosition;
80 int startCheckingIndex;
84 bool ignoreWasTeleported;
95 if (endCheckingIndex > playerCount)
96 endCheckingIndex = playerCount;
102 endCheckingIndex = playerCount;
109 float warningRadiusSq;
111 float prevDistanceSqrXZ;
114 for (
int i = startCheckingIndex; i < endCheckingIndex; i++)
117 zoneCenter = vector.Zero;
118 inWarningZone =
false;
119 prevDistanceSqrXZ = -1;
131 if (zoneData.m_PlayerEntity != playerEntity && playerEntity !=
null)
135 if (playerEntity ==
null)
138 if (zoneData.m_PlayerEntity !=
null)
145 playerEntityPosition = playerEntity.GetOrigin();
153 restrictionZonePosition = zone.GetOrigin();
154 prevDistanceSqrXZ = distanceSqrXZ;
155 distanceSqrXZ = vector.DistanceSqXZ(playerEntityPosition, restrictionZonePosition);
157 if (distanceSqrXZ <= zone.GetRestrictionZoneRadiusSq())
160 if (zone == removedZone)
162 inRemovedZone =
true;
170 if (distanceSqrXZ > zone.GetWarningZoneRadiusSq() && zone.GetWarningZoneRadius() != zone.GetRestrictionZoneRadius())
172 inWarningZone =
true;
175 if (zoneCenter == vector.Zero || distanceSqrXZ < prevDistanceSqrXZ)
177 warningType = zone.GetWarningType();
178 zoneCenter = zone.GetOrigin();
179 warningRadiusSq = zone.GetWarningZoneRadiusSq();
180 zoneRadiusSq = zone.GetRestrictionZoneRadiusSq();
184 else if (distanceSqrXZ <= zone.GetWarningZoneRadiusSq())
186 inWarningZone =
false;
191 else if (zone == removedZone && playerIDZoneMoved && playerIDZoneMoved.Contains(players[i]))
193 inRemovedZone =
true;
196 else if (!ignoreWasTeleported)
199 if (distanceSqrXZ >= zone.GetTeleportedZoneRadiusSq())
201 wasTeleported =
true;
206 wasTeleported =
false;
207 ignoreWasTeleported =
true;
216 if (inRemovedZone && !inZone)
238 SetPlayerZoneData(players[i], playerEntity, inZone, inWarningZone, warningType, zoneCenter, warningRadiusSq, zoneRadiusSq);
256 if (!inWarningZone && zoneData.m_bInWarningZone)
257 ShowWarningUI(playerID,
false, -1,
false, vector.Zero, -1, -1);
259 else if (inWarningZone && (!zoneData.m_bInWarningZone || zoneCenter != zoneData.m_vZoneCenter))
260 ShowWarningUI(playerID,
true, warningType, zoneCenter != zoneData.m_vZoneCenter, zoneCenter, warningRadiusSq, zoneRadiusSq);
262 zoneData.m_bInWarningZone = inWarningZone;
263 zoneData.m_PlayerEntity = playerEntity;
264 zoneData.m_bInZone = inZone;
265 zoneData.m_vZoneCenter = zoneCenter;
274 PlayerController playerController =
m_PlayerManager.GetPlayerController(playerID);
276 if (!playerController)
279 SCR_PlayerRestrictionZoneWarningComponent warningComponent = SCR_PlayerRestrictionZoneWarningComponent.Cast(playerController.FindComponent(SCR_PlayerRestrictionZoneWarningComponent));
280 if (!warningComponent)
283 warningComponent.ShowWarningServer(show, warningIndex, centerChanged, zoneCenter, warningRadiusSq, zoneRadiusSq);
295 if (!damageManager || damageManager.GetState() ==
EDamageState.DESTROYED)
298 damageManager.SetHealthScaled(0);
309 array<int> players = {};
313 if (players.IsEmpty())
319 foreach (
int playerID: players)
343 vector playerEntityPosition;
344 vector restrictionZonePosition;
348 restrictionZonePosition = prevTransfom[3];
350 array<int> players = {};
351 array<int> playersInZone = {};
353 IEntity playerEntity;
355 foreach (
int player: players)
361 playerEntityPosition = playerEntity.GetOrigin();
362 distanceSqrXZ = vector.DistanceSqXZ(playerEntityPosition, restrictionZonePosition);
365 if (distanceSqrXZ <= zone.GetRestrictionZoneRadiusSq())
366 playersInZone.Insert(player);
408 if (!editableEntityCore)
424 if (!Replication.IsServer())
427 SetEventMask(owner, EntityEvent.INIT);
433 if (!Replication.IsServer())
447 if (editableEntityCore)
454 IEntity m_PlayerEntity;
456 bool m_bInWarningZone;
457 vector m_vZoneCenter;
464 m_PlayerEntity = playerEntity;