14 void OnInit(SCR_RespawnSystemComponent owner)
19 void OnPlayerRegistered_S(
int playerId)
21 #ifdef _ENABLE_RESPAWN_LOGS
22 PrintFormat(
"%1::OnPlayerRegistered_S(playerId: %2)", Type().ToString(), playerId);
26 respawnComponent.GetOnRespawnRequestInvoker_S().Insert(OnPlayerSpawnRequest_S);
27 respawnComponent.GetOnRespawnResponseInvoker_S().Insert(OnPlayerSpawnResponse_S);
31 void OnPlayerDisconnected_S(
int playerId,
KickCauseCode cause,
int timeout)
33 #ifdef _ENABLE_RESPAWN_LOGS
34 PrintFormat(
"%1::OnPlayerDisconnected_S(playerId: %2)", Type().ToString(), playerId);
38 respawnComponent.GetOnRespawnRequestInvoker_S().Remove(OnPlayerSpawnRequest_S);
39 respawnComponent.GetOnRespawnResponseInvoker_S().Remove(OnPlayerSpawnResponse_S);
43 void OnPlayerSpawnRequest_S(SCR_SpawnRequestComponent requestComponent)
45 #ifdef _ENABLE_RESPAWN_LOGS
46 PrintFormat(
"%1::OnPlayerSpawnRequest_S(playerId: %2)", Type().ToString(), requestComponent.GetPlayerId());
51 void OnPlayerSpawnResponse_S(SCR_SpawnRequestComponent requestComponent,
SCR_ESpawnResult response)
53 #ifdef _ENABLE_RESPAWN_LOGS
54 PrintFormat(
"%1::OnPlayerSpawnResponse_S(playerId: %2, response: %3)",
55 Type().ToString(), requestComponent.GetPlayerId(),
typename.EnumToString(
SCR_ESpawnResult, response));
59 OnPlayerSpawnFailed_S(requestComponent.GetPlayerId());
63 protected void OnPlayerSpawnFailed_S(
int playerId)
68 void OnPlayerSpawned_S(
int playerId, IEntity entity)
70 #ifdef _ENABLE_RESPAWN_LOGS
71 PrintFormat(
"%1::OnPlayerSpawned_S(playerId: %2, entity: %3)", Type().ToString(), playerId, entity);
76 void OnPlayerEntityChanged_S(
int playerId, IEntity previousEntity, IEntity newEntity)
78 #ifdef _ENABLE_RESPAWN_LOGS
79 PrintFormat(
"%1::OnPlayerEntityChanged_S(playerId: %2, previousEntity: %3, newEntity: %4)",
80 Type().ToString(), playerId, previousEntity, newEntity);
84 OnPlayerEntityLost_S(playerId);
88 void OnPlayerKilled_S(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
90 #ifdef _ENABLE_RESPAWN_LOGS
91 PrintFormat(
"%1::OnPlayerKilled_S(playerId: %2, playerEntity: %3, killerEntity: %4, killerId: %5)",
92 Type().ToString(), playerId, playerEntity, killerEntity, killer.GetInstigatorPlayerID());
95 OnPlayerEntityLost_S(playerId);
99 void OnPlayerDeleted_S(
int playerId)
101 #ifdef _ENABLE_RESPAWN_LOGS
102 PrintFormat(
"%1::OnPlayerDeleted_S(playerId: %2)", Type().ToString(), playerId);
105 OnPlayerEntityLost_S(playerId);
113 protected void OnPlayerEntityLost_S(
int playerId)
115 #ifdef _ENABLE_RESPAWN_LOGS
116 PrintFormat(
"%1::OnPlayerEntityLost_S(playerId: %2)", Type().ToString(), playerId);
125 protected void NotifyPlayerReadyForSpawn(
int playerId)
127 GetPlayerRespawnComponent_S(playerId).NotifyReadyForSpawn_S();
135 bool IsEligibleForReconnection(
int playerId)
138 if (!reconnectComponent || !reconnectComponent.IsReconnectEnabled())
141 SCR_EReconnectState recState = reconnectComponent.IsInReconnectList(playerId);
142 if (recState == SCR_EReconnectState.NOT_RECONNECT)
145 PlayerController controller =
GetGame().GetPlayerManager().GetPlayerController(playerId);
148 SCR_ReconnectSynchronizationComponent syncComp = SCR_ReconnectSynchronizationComponent.Cast(controller.FindComponent(SCR_ReconnectSynchronizationComponent));
150 syncComp.CreateReconnectDialog(recState);
153 return recState == SCR_EReconnectState.ENTITY_AVAILABLE;
164 protected bool ResolveReconnection(
int playerId, out IEntity assignedEntity)
166 if (!IsEligibleForReconnection(playerId))
169 #ifdef _ENABLE_RESPAWN_LOGS
170 PrintFormat(
"%1::ResolveReconnection(playerId: %2)", Type().ToString(), playerId);
174 assignedEntity = reconnectComponent.ReturnControlledEntity(playerId);
175 return assignedEntity !=
null;