12 protected ref set<SCR_EditorRestrictionZoneEntity>
m_aRestrictionZones =
new set<SCR_EditorRestrictionZoneEntity>();
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++)
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)
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 = {};
355 foreach (
int player: players)
361 playerEntityPosition = playerEntity.
GetOrigin();
362 distanceSqrXZ =
vector.DistanceSqXZ(playerEntityPosition, restrictionZonePosition);
365 if (distanceSqrXZ <=
zone.GetRestrictionZoneRadiusSq())
366 playersInZone.Insert(player);
388 SetPlayerZoneData(instigatorContextData.GetVictimPlayerID(), null,
false,
false, -1);
407 if (!editableEntityCore)
446 if (editableEntityCore)
451class SCR_PlayerRestrictionZoneData
455 bool m_bInWarningZone;
461 void SCR_PlayerRestrictionZoneData(
IEntity playerEntity)
463 m_PlayerEntity = playerEntity;
ERestrictionZoneWarningType
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
override void DelayedInit(IEntity owner)
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
override void DelayedInit()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
it takes to automatically cancel a task when no enemy has been killed in the zone
PlayerManager m_PlayerManager
void OnEntityTransformChanged(SCR_EditableEntityComponent editableEntity, vector prevTransfom[4])
ref set< SCR_EditorRestrictionZoneEntity > m_aRestrictionZones
const int ZONE_CHECK_FREQUENCY
const int ZONE_CHECK_PLAYER_BATCH_AMOUNT
The amount of players the manager checks each update. The leftovers will be done next update etc.
void ZoneMovedOrDeleted(SCR_EditorRestrictionZoneEntity zone, array< int > playerIDZoneMoved=null)
ref map< int, ref SCR_PlayerRestrictionZoneData > m_PlayerRestrictionZoneData
void RemoveRestrictionZone(SCR_EditorRestrictionZoneEntity zone)
void ShowWarningUI(int playerID, bool show, ERestrictionZoneWarningType warningIndex, bool centerChanged, vector zoneCenter, float warningRadiusSq, float zoneRadiusSq)
void SetPlayerZoneData(int playerID, IEntity playerEntity, bool inZone, bool inWarningZone, ERestrictionZoneWarningType warningType, vector zoneCenter=vector.Zero, float warningRadiusSq=-1, float zoneRadiusSq=-1)
void KillPlayerOutOfZone(int playerID, IEntity playerEntity)
void ZoneCheckUpdate(bool updateAll, SCR_EditorRestrictionZoneEntity removedZone=null, array< int > playerIDZoneMoved=null)
void AddRestrictionZone(SCR_EditorRestrictionZoneEntity zone)
void OnPlayerDisconnect(int playerID)
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > GetOnPlayerDisconnected()
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
void EOnInit(IEntity owner)
EntityEvent
Various entity events.