1 [
ComponentEditorProps(
category:
"GameScripted/Respawn/Handlers", description:
"Allows the respawn system to utilize spawning on AI(s). Requires a SCR_OnAIRespawnComponent attached to PlayerController.")]
6 class SCR_PossessSpawnHandlerComponent : SCR_SpawnHandlerComponent
8 [
Attribute(
"1",
desc:
"When enabled, conditions like respawn time will not be checked.")]
9 protected bool m_bIgnoreConditions;
14 int playerId = requestComponent.GetPlayerController().GetPlayerId();
15 #ifdef _ENABLE_RESPAWN_LOGS
16 Print(
string.Format(
"%1::SpawnEntity(playerId: %2, data: %3)", Type().ToString(),
18 data), LogLevel.NORMAL);
44 ChimeraCharacter character = ChimeraCharacter.Cast(entity);
49 if (character.GetCharacterController().IsDead())
53 int controllingPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
54 if (controllingPlayerId != 0)
67 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(possessData.GetRplId()));
71 return rplComponent.GetEntity();
86 if (!super.ValidateData_S(requestComponent,
data))
90 if (!possessData || !possessData.GetRplId().IsValid())
93 Managed rplComponent = Replication.FindItem(possessData.GetRplId());
94 return rplComponent !=
null;
100 return m_bIgnoreConditions || super.CanRequestSpawn_S(requestComponent,
data, result);
107 PlayerController pc = requestComponent.GetPlayerController();
110 if (!targetFaction || targetFaction == playerFactionComp.GetAffiliatedFaction())
113 playerFactionComp.SetAffiliatedFaction(targetFaction);
117 factionManager.UpdatePlayerFaction_S(playerFactionComp);
121 gameMode.OnPlayerFactionSet_S(playerFactionComp, targetFaction);
127 Resource res = Resource.Load(prefab);
128 IEntityComponentSource src =
SCR_BaseContainerTools.FindComponentSource(res, FactionAffiliationComponent);
133 src.Get(
"faction affiliation", factionKey);
135 return GetGame().GetFactionManager().GetFactionByKey(factionKey);