5 protected SCR_SpawnerAIGroupManagerComponent m_GroupSpawningManager;
8 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
10 if (!m_DefenderSpawner)
13 PlayerController playerController =
GetGame().GetPlayerController();
14 if (!playerController)
17 SCR_SpawnerRequestComponent playerReqComponent = SCR_SpawnerRequestComponent.Cast(playerController.FindComponent(SCR_SpawnerRequestComponent));
18 if (!playerReqComponent)
21 playerReqComponent.EnableSpawning(m_DefenderSpawner, !m_DefenderSpawner.IsSpawningEnabled(), playerController.GetPlayerId());
25 override bool CanBePerformedScript(IEntity user)
27 if (m_GroupSpawningManager.IsAtAILimit())
29 SetCannotPerformReason(
"#AR-Campaign_Action_BuildBlocked-UC");
33 if (!m_DefenderSpawner.UserRankCheck(user))
36 FactionAffiliationComponent factionAffiliationComp = FactionAffiliationComponent.Cast(user.FindComponent(FactionAffiliationComponent));
37 if (!factionAffiliationComp)
44 rankName = faction.GetRankName(m_DefenderSpawner.GetMinimumRank());
46 SetCannotPerformReason(rankName);
54 override bool CanBeShownScript(IEntity user)
56 if (!m_DefenderSpawner)
60 if (!playerController)
63 SCR_ChimeraCharacter chimeraCharacter = SCR_ChimeraCharacter.Cast(playerController.GetControlledEntity());
64 if (!chimeraCharacter || chimeraCharacter.GetFaction() != m_DefenderSpawner.GetFaction())
71 protected override bool HasLocalEffectOnlyScript()
77 override bool GetActionNameScript(out
string outName)
79 if (m_DefenderSpawner.IsSpawningEnabled())
80 outName =
"#AR-DefenderSpawner_DisableSpawning";
82 outName =
"#AR-DefenderSpawner_EnableSpawning";
88 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
92 BaseGameMode gameMode =
GetGame().GetGameMode();
96 m_GroupSpawningManager = SCR_SpawnerAIGroupManagerComponent.Cast(gameMode.FindComponent(SCR_SpawnerAIGroupManagerComponent));
97 if (!m_GroupSpawningManager)
99 Print(
"SCR_DefenderSpawnerComponent requires SCR_SpawnerAIGroupManagerComponent attached to gamemode to work properly!", LogLevel.ERROR);