3 static override bool DependsOn(
string className)
5 if (className ==
"SCR_RespawnComponentClass")
59 protected SCR_SpawnLockComponent
GetLock()
74 return SCR_SpawnHandlerComponent;
102 super.OnPostInit(owner);
110 Print(
string.Format(
"%1 is not attached in %2 hierarchy! (%1 should be a child of %3!)",
115 m_RplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
118 Print(
string.Format(
"%1 could not find %2!",
119 Type().ToString(), RplComponent),
126 Print(
string.Format(
"%1 could not find %2!",
131 m_LockComponent = SCR_SpawnLockComponent.Cast(owner.FindComponent(SCR_SpawnLockComponent));
134 Print(
string.Format(
"%1 could not find %2!",
135 Type().ToString(), SCR_SpawnLockComponent),
139 SCR_RespawnSystemComponent respawnSystem = SCR_RespawnSystemComponent.GetInstance();
142 Print(
string.Format(
"%1 could not find %2!",
143 Type().ToString(), SCR_RespawnSystemComponent),
150 Print(
string.Format(
"%1 could not find %2!",
162 #ifdef _ENABLE_RESPAWN_LOGS
163 Print(
string.Format(
"%1::CanRequestRespawn(data: %2)", Type().ToString(),
data), LogLevel.NORMAL);
166 SCR_SpawnLockComponent lock =
GetLock();
167 if (lock && !lock.TryLock(
this,
false))
200 Debug.Error(
"Not implemented!");
210 #ifdef _ENABLE_RESPAWN_LOGS
211 Print(
string.Format(
"%1::ProcessCanRequest_S(data: %2)", Type().ToString(),
data), LogLevel.NORMAL);
215 SCR_SpawnLockComponent lock =
GetLock();
216 if (lock && !lock.TryLock(
this,
true))
218 Debug.Error(
"Caught request on locked player!");
223 respawnComponent.GetOnCanRespawnRequestInvoker_S().Invoke(
this,
data);
229 Print(
"GameMode does not support this method of spawning!", LogLevel.WARNING);
246 #ifdef _ENABLE_RESPAWN_LOGS
247 Print(
string.Format(
"%1::SendCanResponse_S(resp: %2, data: %3)", Type().ToString(),
typename.EnumToString(
SCR_ESpawnResult, response),
data), LogLevel.NORMAL);
251 SCR_SpawnLockComponent lock =
GetLock();
254 lock.Unlock(
this,
true);
255 lock.Unlock(
this,
false);
260 respawnComponent.GetOnCanRespawnResponseInvoker_S().Invoke(
this, response,
data);
270 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
273 #ifdef _ENABLE_RESPAWN_LOGS
274 Print(
string.Format(
"%1::Rpc_SendCanResponse_O(resp: %2)", Type().ToString(),
typename.EnumToString(
SCR_ESpawnResult, response)), LogLevel.NORMAL);
278 SCR_SpawnLockComponent lock =
GetLock();
280 lock.Unlock(
this,
false);
297 #ifdef _ENABLE_RESPAWN_LOGS
298 Print(
string.Format(
"%1::RequestRespawn(data: %2)", Type().ToString(),
data), LogLevel.NORMAL);
302 SCR_SpawnLockComponent lock =
GetLock();
303 if (lock && !lock.TryLock(
this,
false))
305 Print(
"Caught request spawn on locked player!", LogLevel.WARNING);
333 Debug.Error(
"Not implemented!");
343 #ifdef _ENABLE_RESPAWN_LOGS
344 Print(
string.Format(
"%1::ProcessRequest_S(data: %2)", Type().ToString(),
data), LogLevel.NORMAL);
348 SCR_SpawnLockComponent lock =
GetLock();
349 if (lock && !lock.TryLock(
this,
true))
351 Debug.Error(
"Caught request on locked player!");
359 Print(
"GameMode does not support this method of spawning!", LogLevel.WARNING);
365 IEntity spawnedEntity;
383 SCR_EditableCharacterComponent editorCharacter = SCR_EditableCharacterComponent.Cast(spawnedEntity.FindComponent(SCR_EditableCharacterComponent));
400 #ifdef _ENABLE_RESPAWN_LOGS
401 Print(
string.Format(
"%1::OnFinalizeBegin_S(handler: %1, data: %2, entity: %3)", Type().ToString(),
402 handler,
data, spawnedEntity), LogLevel.NORMAL);
404 handler.OnFinalizeBegin_S(
this,
data, spawnedEntity);
414 #ifdef _ENABLE_RESPAWN_LOGS
415 Print(
string.Format(
"%1::AwaitFinalization_S(handler: %2, data: %3, entity: %4)", Type().ToString(),
416 handler,
data, spawnedEntity), LogLevel.NORMAL);
428 agent.SetPlayerPending_S(0);
440 #ifdef _ENABLE_RESPAWN_LOGS
441 Print(
string.Format(
"%1::CanFinalize_S(handler: %2, data: %3, entity: %4)", Type().ToString(),
442 handler,
data, spawnedEntity), LogLevel.NORMAL);
444 return handler.CanFinalize_S(
this,
data, spawnedEntity);
455 #ifdef _ENABLE_RESPAWN_LOGS
456 Print(
string.Format(
"%1::FinalizeRequest_S(handler: %1, data: %2, entity: %3)", Type().ToString(),
457 handler,
data, spawnedEntity), LogLevel.NORMAL);
476 #ifdef _ENABLE_RESPAWN_LOGS
477 Print(
string.Format(
"%1::SendResponse_S(resp: %2, data: %3)", Type().ToString(),
typename.EnumToString(
SCR_ESpawnResult, response),
data), LogLevel.NORMAL);
481 SCR_SpawnLockComponent lock =
GetLock();
484 lock.Unlock(
this,
true);
485 lock.Unlock(
this,
false);
490 respawnComponent.GetOnRespawnResponseInvoker_S().Invoke(
this, response,
data);
500 #ifdef _ENABLE_RESPAWN_LOGS
501 Print(
string.Format(
"%1::SendFinalizationBegin_S()", Type().ToString()), LogLevel.NORMAL);
507 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
511 respawnComponent.GetOnRespawnFinalizeBeginInvoker_O().Invoke(
this);
544 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
558 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
567 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
579 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
582 #ifdef _ENABLE_RESPAWN_LOGS
583 Print(
string.Format(
"%1::Rpc_SendResponse_O(resp: %2)", Type().ToString(),
typename.EnumToString(
SCR_ESpawnResult, response)), LogLevel.NORMAL);
587 SCR_SpawnLockComponent lock =
GetLock();
589 lock.Unlock(
this,
false);
604 AIControlComponent controlComponent = AIControlComponent.Cast(entity.FindComponent(AIControlComponent));
605 if (controlComponent)
629 m_Diag = CreateDiag();
634 protected ref SCR_BaseRespawnDiag m_Diag;
637 protected ref SCR_BaseRespawnDiag CreateDiag()
645 class SCR_BaseRespawnDiag
651 void DrawDbgUI(PlayerController playerController);
655 class SCR_RespawnDiag<Class TReqComponent> : SCR_BaseRespawnDiag
657 protected TReqComponent m_RequestComponent;
660 override void DrawDbgUI(PlayerController playerController)
662 if (m_RequestComponent ==
null)
663 m_RequestComponent = TReqComponent.Cast(playerController.FindComponent(TReqComponent));
665 if (!m_RequestComponent)
668 int playerId = m_RequestComponent.GetPlayerId();
669 string label =
string.Format(
"%1 [playerId: %2, playerName: %3])",
670 m_RequestComponent.Type().ToString(),
672 GetGame().GetPlayerManager().GetPlayerName(playerId)
683 protected void DrawContent()
685 SCR_SpawnHandlerComponent handlerComponent = m_RequestComponent.GetHandlerComponent();
686 if (handlerComponent !=
null)
687 DbgUI.Text(
string.Format(
"Handler: %1", handlerComponent));
689 DbgUI.Text(
"Handler: Not found!");
691 DbgUI.Text(
string.Format(
"Data: %1", m_RequestComponent.GetDataType()));
693 if (DbgUI.Button(
"Can Request"))
696 if (DbgUI.Button(
"Do Request"))
701 protected void OnAskPressed()
704 m_RequestComponent.CanRequestRespawn(
data);
708 protected void OnRequestPressed()
711 m_RequestComponent.RequestRespawn(
data);
717 Debug.Error(
"Not implemented");