8 class SCR_RestrictedDeployableSpawnPointComponent : SCR_BaseDeployableSpawnPointComponent
11 protected int m_iMaxSpawnPointsPerGroup;
14 protected int m_iMaxRespawns;
16 [
Attribute(defvalue:
"1",
desc:
"Check if bases are nearby before deploying")]
17 protected bool m_bQueryBases;
19 [
Attribute(defvalue:
"0",
desc:
"Check if spawn points are nearby before deploying")]
20 protected bool m_bQuerySpawnPoints;
22 [
Attribute(defvalue:
"0",
desc:
"Check if characters are nearby before deploying")]
23 protected bool m_bQueryCharacters;
25 [
Attribute(defvalue:
"300.0",
desc:
"Query radius for military bases")]
26 protected float m_fQueryRadiusBases;
28 [
Attribute(defvalue:
"250.0",
desc:
"Query radius for other existing spawn points")]
29 protected float m_fQueryRadiusSpawnPoints;
31 [
Attribute(defvalue:
"100.0",
desc:
"Query radius for enemy characters")]
32 protected float m_fQueryRadiusCharacters;
34 [
Attribute(defvalue:
"0",
desc:
"Query all military bases, not just Main Operating Bases")]
35 protected bool m_bQueryAllBases;
38 protected bool m_bIgnoreEnemyBases;
41 protected bool m_bIgnoreEnemySpawnPoints;
44 protected bool m_bIgnoreEnemyCharacters;
47 protected bool m_bUnlockActionsForEnemyFactions;
50 protected bool m_bAllowAllGroupsToSpawn;
53 protected bool m_bUnlockActionsForAllGroups;
55 [
Attribute(defvalue:
"1",
desc:
"Play audio cue once spawn point can/cannot be deployed")]
56 protected bool m_bPlaySoundOnZoneEntered;
58 [
Attribute(defvalue:
"1",
desc:
"Show notification once spawn point can/cannot be deployed")]
59 protected bool m_bShowNotificationOnZoneEntered;
61 [
Attribute(defvalue:
"1.0",
desc:
"Rate at which spawn point will check if it can be deployed or not")]
62 protected float m_fUpdateRate;
64 [
Attribute(defvalue:
"#AR-DeployableSpawnPoints_UserAction_OutsideDeployArea")]
65 protected string m_sOutsideDeployAreaMessage;
67 [
Attribute(defvalue:
"#AR-DeployableSpawnPoints_UserAction_DeployLimitReached")]
68 protected string m_sDeployLimitReachedMessage;
70 [
Attribute(defvalue:
"#AR-DeployableSpawnPoints_UserAction_NoGroupJoined")]
71 protected string m_sNoGroupJoinedMessage;
77 protected bool m_bIsOutsideExclusionZone;
79 protected bool m_bIsGroupLimitReached;
80 protected bool m_bNoGroupJoined;
82 protected static ref array<int> s_aActiveDeployedSpawnPointGroupIDs = {};
92 protected static ref array<ref Shape> s_aDebugShapes = {};
96 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
99 s_aActiveDeployedSpawnPointGroupIDs.Insert(groupID);
103 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
106 s_aActiveDeployedSpawnPointGroupIDs.RemoveItem(groupID);
110 [
RplRpc(RplChannel.Unreliable, RplRcver.Broadcast)]
113 SoundComponent soundComp = SoundComponent.Cast(
GetOwner().FindComponent(SoundComponent));
118 soundComp.SoundEvent(
SCR_SoundEvent.SOUND_DEPLOYED_RADIO_ENTER_ZONE);
120 soundComp.SoundEvent(
SCR_SoundEvent.SOUND_DEPLOYED_RADIO_EXIT_ZONE);
125 protected bool EntityQuery(notnull array<IEntity> entities, notnull
Faction spawnPointFaction, vector spawnPointOrigin)
127 if (entities.IsEmpty())
130 float queryRadius = 100;
131 bool isBase, isSpawnPoint, isCharacter;
133 if (SCR_MilitaryBaseComponent.Cast(entities[0].FindComponent(SCR_MilitaryBaseComponent)))
135 queryRadius = m_fQueryRadiusBases;
140 queryRadius = m_fQueryRadiusSpawnPoints;
143 else if (SCR_ChimeraCharacter.Cast(entities[0]))
145 queryRadius = m_fQueryRadiusCharacters;
149 float radiusSq = queryRadius * queryRadius;
151 foreach (IEntity e : entities)
153 vector origin = e.GetOrigin();
156 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS_ENABLE_DIAG))
157 s_aDebugShapes.Insert(Shape.CreateSphere(Color.RED, ShapeFlags.WIREFRAME, origin, queryRadius));
160 float distanceToItemSq = vector.DistanceSq(spawnPointOrigin, origin);
161 bool isWithinRadius = distanceToItemSq < radiusSq;
170 bool isFriendlyFaction = faction.DoCheckIfFactionFriendly(spawnPointFaction);
174 if (isFriendlyFaction)
177 if (!isFriendlyFaction && !m_bIgnoreEnemyBases)
180 else if (isSpawnPoint)
182 if (isFriendlyFaction)
185 if (!isFriendlyFaction && !m_bIgnoreEnemySpawnPoints)
188 else if (isCharacter)
190 if (!isFriendlyFaction && !m_bIgnoreEnemyCharacters)
199 protected bool CanActionBeShown(notnull IEntity userEntity,
bool checkCanDeploy,
bool checkFaction =
true,
bool checkGroupID =
true)
201 if (!s_bDeployableSpawnPointsEnabled)
204 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(userEntity.FindComponent(FactionAffiliationComponent));
205 if (!factionAffiliation)
208 Faction affiliatedFaction = factionAffiliation.GetAffiliatedFaction();
209 if (!affiliatedFaction)
212 FactionKey userFactionKey = affiliatedFaction.GetFactionKey();
216 if (userFactionKey !=
m_FactionKey && !m_bUnlockActionsForEnemyFactions && checkFaction)
219 SCR_PossessingManagerComponent possessingManagerComp = SCR_PossessingManagerComponent.GetInstance();
220 if (!possessingManagerComp)
223 int userID = possessingManagerComp.GetIdFromControlledEntity(userEntity);
225 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
226 if (!playerControllerGroupComp)
229 int userGroupID = playerControllerGroupComp.GetGroupID();
231 if (userFactionKey ==
m_FactionKey && userGroupID !=
m_iGroupID && !m_bUnlockActionsForAllGroups && checkGroupID)
240 array<IEntity> entities = {};
242 FactionManager factionManager =
GetGame().GetFactionManager();
255 array<SCR_MilitaryBaseComponent> baseComponents = {};
257 baseManager.GetBases(baseComponents);
259 foreach (SCR_MilitaryBaseComponent baseComponent : baseComponents)
261 if (m_bQueryAllBases)
263 entities.Insert(baseComponent.GetOwner());
268 if (!campaignBaseComponent || !campaignBaseComponent.IsHQ())
271 entities.Insert(baseComponent.GetOwner());
276 notification =
ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
282 if (m_bQuerySpawnPoints)
286 array<SCR_SpawnPoint> spawnPoints =
SCR_SpawnPoint.GetSpawnPoints();
290 if (!SCR_PlayerRadioSpawnPoint.Cast(spawnPoint))
291 entities.Insert(spawnPoint);
296 notification =
ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
302 if (m_bQueryCharacters)
310 foreach (SCR_ChimeraCharacter character : characters)
312 if (character == userEntity || character.GetCharacterController().IsDead())
315 entities.Insert(character);
320 notification =
ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
325 notification =
ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_ENTERED;
339 m_bNoGroupJoined =
true;
343 m_bNoGroupJoined =
false;
344 return group.GetDeployedRadioCount() >= m_iMaxSpawnPointsPerGroup;
354 int userID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(userEntity);
356 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
357 if (!playerControllerGroupComp)
360 m_iGroupID = playerControllerGroupComp.GetGroupID();
361 Replication.BumpMe();
371 playerGroup.IncreaseDeployedRadioCount();
373 super.Deploy(userEntity);
379 if (!restrictedSpawnPoint)
383 restrictedSpawnPoint.SetMaxRespawns(m_iMaxRespawns);
385 restrictedSpawnPoint.SetAllowAllGroupsToSpawn(m_bAllowAllGroupsToSpawn);
397 if (!restrictedSpawnPoint)
410 playerGroup.DecreaseDeployedRadioCount();
413 Replication.BumpMe();
415 super.Dismantle(userEntity);
422 SCR_PossessingManagerComponent possessingManagerComp = SCR_PossessingManagerComponent.GetInstance();
423 if (!possessingManagerComp)
426 int userID = possessingManagerComp.GetIdFromControlledEntity(userEntity);
431 SCR_NotificationsComponent.SendToPlayer(userID,
ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_RESPAWN_COUNT, respawnsLeft, m_iMaxRespawns);
435 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
436 if (!playerControllerGroupComp)
439 int userGroupID = playerControllerGroupComp.GetGroupID();
443 SCR_NotificationsComponent.SendToPlayer(userID,
ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_GROUP,
m_iGroupID);
447 SCR_NotificationsComponent.SendToPlayer(userID,
ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_RESPAWN_COUNT, respawnsLeft, m_iMaxRespawns);
455 if (m_bNoGroupJoined)
456 reason = m_sNoGroupJoinedMessage;
457 else if (m_bIsGroupLimitReached)
458 reason = m_sDeployLimitReachedMessage;
459 else if (!m_bIsOutsideExclusionZone)
460 reason = m_sOutsideDeployAreaMessage;
462 return m_bIsOutsideExclusionZone && !m_bIsGroupLimitReached && !m_bNoGroupJoined;
495 return m_bAllowAllGroupsToSpawn;
502 return m_bIgnoreEnemyCharacters;
516 return m_fQueryRadiusCharacters;
535 if (group == itemGroup)
542 super.Update(owner, timeSlice);
556 s_aDebugShapes.Clear();
559 if (!s_bDeployableSpawnPointsEnabled)
580 IEntity parentEntity;
583 parentEntity = parentSlot.GetStorage().GetOwner();
584 parentSlot = parentSlot.GetStorage().GetParentSlot();
587 if (!parentEntity || !SCR_ChimeraCharacter.Cast(parentEntity))
593 int userID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(parentEntity);
600 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(parentEntity.FindComponent(FactionAffiliationComponent));
601 if (!factionAffiliation)
604 Faction affiliatedFaction = factionAffiliation.GetAffiliatedFaction();
605 if (!affiliatedFaction)
608 FactionKey userFactionKey = affiliatedFaction.GetFactionKey();
623 if (m_bIsOutsideExclusionZone == canBeDeployedAtPos)
626 m_bIsOutsideExclusionZone = canBeDeployedAtPos;
627 Replication.BumpMe();
629 if (m_bShowNotificationOnZoneEntered && notification > -1)
630 SCR_NotificationsComponent.SendToPlayer(userID, notification);
642 super.EOnInit(owner);
654 int dummyNotification;
656 Replication.BumpMe();
678 playerGroup.DecreaseDeployedRadioCount();
683 s_aDebugShapes.Clear();
686 super.OnDelete(owner);