3 static override bool DependsOn(
string className)
5 if (className ==
"SCR_RespawnComponent")
24 private SCR_SpawnLockComponent m_LockComponent;
27 private SCR_SpawnHandlerComponent m_HandlerComponent;
28 private bool m_bIsPreloading;
57 return m_HandlerComponent;
62 protected SCR_SpawnLockComponent
GetLock()
64 return m_LockComponent;
70 private ref SCR_SpawnData m_ConfirmationPendingData;
77 return SCR_SpawnHandlerComponent;
105 super.OnPostInit(owner);
113 Print(
string.Format(
"%1 is not attached in %2 hierarchy! (%1 should be a child of %3!)",
121 Print(
string.Format(
"%1 could not find %2!",
129 Print(
string.Format(
"%1 could not find %2!",
134 m_LockComponent = SCR_SpawnLockComponent.Cast(owner.
FindComponent(SCR_SpawnLockComponent));
135 if (!m_LockComponent)
137 Print(
string.Format(
"%1 could not find %2!",
142 SCR_RespawnSystemComponent respawnSystem = SCR_RespawnSystemComponent.GetInstance();
145 Print(
string.Format(
"%1 could not find %2!",
150 m_HandlerComponent = SCR_SpawnHandlerComponent.Cast(respawnSystem.FindComponent(GetHandlerType()));
151 if (!m_HandlerComponent)
153 Print(
string.Format(
"%1 could not find %2!",
165 #ifdef _ENABLE_RESPAWN_LOGS
169 SCR_SpawnLockComponent lock =
GetLock();
170 if (lock && !lock.TryLock(
this,
false))
185 m_ConfirmationPendingData =
data;
203 Debug.Error(
"Not implemented!");
213 #ifdef _ENABLE_RESPAWN_LOGS
218 SCR_SpawnLockComponent lock =
GetLock();
219 if (lock && !lock.TryLock(
this,
true))
221 Print(
"SCR_SpawnRequestComponent::ProcessCanRequest_S - Caught request on locked player!",
LogLevel.DEBUG);
226 respawnComponent.GetOnCanRespawnRequestInvoker_S().Invoke(
this,
data);
232 Print(
"GameMode does not support this method of spawning!",
LogLevel.WARNING);
249 #ifdef _ENABLE_RESPAWN_LOGS
254 SCR_SpawnLockComponent lock =
GetLock();
257 lock.Unlock(
this,
true);
258 lock.Unlock(
this,
false);
263 respawnComponent.GetOnCanRespawnResponseInvoker_S().Invoke(
this, response,
data);
276 #ifdef _ENABLE_RESPAWN_LOGS
281 SCR_SpawnLockComponent lock =
GetLock();
283 lock.Unlock(
this,
false);
287 respawnComponent.GetOnCanRespawnResponseInvoker_O().Invoke(
this, response, m_ConfirmationPendingData);
290 m_ConfirmationPendingData = null;
300 #ifdef _ENABLE_RESPAWN_LOGS
305 SCR_SpawnLockComponent lock =
GetLock();
306 if (lock && !lock.TryLock(
this,
false))
308 Print(
"SCR_SpawnRequestComponent::RequestRespawn - Caught request spawn on locked player!",
LogLevel.DEBUG);
336 Debug.Error(
"Not implemented!");
346 #ifdef _ENABLE_RESPAWN_LOGS
351 SCR_SpawnLockComponent lock =
GetLock();
352 if (lock && !lock.TryLock(
this,
true))
354 Print(
"SCR_SpawnRequestComponent::ProcessRequest_S - Caught request on locked player!",
LogLevel.DEBUG);
362 Print(
"GameMode does not support this method of spawning!",
LogLevel.WARNING);
386 SCR_EditableCharacterComponent editorCharacter = SCR_EditableCharacterComponent.Cast(spawnedEntity.
FindComponent(SCR_EditableCharacterComponent));
403 #ifdef _ENABLE_RESPAWN_LOGS
404 Print(
string.Format(
"%1::OnFinalizeBegin_S(handler: %1, data: %2, entity: %3)",
Type().
ToString(),
407 handler.OnFinalizeBegin_S(
this,
data, spawnedEntity);
417 #ifdef _ENABLE_RESPAWN_LOGS
418 Print(
string.Format(
"%1::AwaitFinalization_S(handler: %2, data: %3, entity: %4)",
Type().
ToString(),
443 #ifdef _ENABLE_RESPAWN_LOGS
444 Print(
string.Format(
"%1::CanFinalize_S(handler: %2, data: %3, entity: %4)",
Type().
ToString(),
447 return handler.CanFinalize_S(
this,
data, spawnedEntity);
458 #ifdef _ENABLE_RESPAWN_LOGS
459 Print(
string.Format(
"%1::FinalizeRequest_S(handler: %1, data: %2, entity: %3)",
Type().
ToString(),
479 #ifdef _ENABLE_RESPAWN_LOGS
484 SCR_SpawnLockComponent lock =
GetLock();
487 lock.Unlock(
this,
true);
488 lock.Unlock(
this,
false);
493 respawnComponent.GetOnRespawnResponseInvoker_S().Invoke(
this, response,
data);
503 #ifdef _ENABLE_RESPAWN_LOGS
514 respawnComponent.GetOnRespawnFinalizeBeginInvoker_O().Invoke(
this);
525 return m_bIsPreloading;
542 m_bIsPreloading =
true;
550 m_bIsPreloading =
true;
556 m_bIsPreloading =
false;
564 m_bIsPreloading =
false;
585 #ifdef _ENABLE_RESPAWN_LOGS
590 SCR_SpawnLockComponent lock =
GetLock();
592 lock.Unlock(
this,
false);
596 respawnComponent.GetOnRespawnResponseInvoker_O().Invoke(
this, response, m_ConfirmationPendingData);
598 auto respawnSystem = SCR_RespawnSystemComponent.GetInstance();
600 respawnSystem.DestroyLoadingPlaceholder();
610 AIControlComponent controlComponent = AIControlComponent.Cast(entity.
FindComponent(AIControlComponent));
611 if (controlComponent)
635 m_Diag = CreateDiag();
640 protected ref SCR_BaseRespawnDiag m_Diag;
643 protected ref SCR_BaseRespawnDiag CreateDiag()
652class SCR_BaseRespawnDiag
657 void DrawDbgUI(PlayerController playerController);
661class SCR_RespawnDiag<
Class TReqComponent> : SCR_BaseRespawnDiag
663 protected TReqComponent m_RequestComponent;
666 override void DrawDbgUI(PlayerController playerController)
668 if (m_RequestComponent == null)
669 m_RequestComponent = TReqComponent.Cast(playerController.FindComponent(TReqComponent));
671 if (!m_RequestComponent)
674 int playerId = m_RequestComponent.GetPlayerId();
675 string label =
string.Format(
"%1 [playerId: %2, playerName: %3])",
676 m_RequestComponent.Type().ToString(),
678 GetGame().GetPlayerManager().GetPlayerName(playerId)
689 protected void DrawContent()
691 SCR_SpawnHandlerComponent handlerComponent = m_RequestComponent.GetHandlerComponent();
692 if (handlerComponent != null)
693 DbgUI.Text(
string.Format(
"Handler: %1", handlerComponent));
695 DbgUI.Text(
"Handler: Not found!");
697 DbgUI.Text(
string.Format(
"Data: %1", m_RequestComponent.GetDataType()));
699 if (DbgUI.Button(
"Can Request"))
702 if (DbgUI.Button(
"Do Request"))
707 protected void OnAskPressed()
709 SCR_SpawnData
data = CreateData();
710 m_RequestComponent.CanRequestRespawn(
data);
714 protected void OnRequestPressed()
716 SCR_SpawnData
data = CreateData();
717 m_RequestComponent.RequestRespawn(
data);
721 protected SCR_SpawnData CreateData()
723 Debug.Error(
"Not implemented");
ArmaReforgerScripted GetGame()
SCR_BaseGameMode GetGameMode()
RplComponent m_RplComponent
Get all prefabs that have the spawner data
SCR_FastTravelComponentClass m_PlayerController
SCR_FreeSpawnRequestComponentClass SCR_SpawnRequestComponentClass GetHandlerType()
SCR_PlayerDeployMenuHandlerComponentClass m_RespawnComponent
Component responsible for deploy menu management.
void RequestRespawn()
Sends a respawn request based on assigned loadout and selected spawn point.
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
bool CanFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnData data, IEntity entity)
SCR_ESpawnResult FinalizeRequest_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnData data, IEntity entity)
void OnFinalizeBegin_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnData data, IEntity entity)
Called when the finalisation process begins.
void SendFinalizationBegin_S()
Send a notification from the authority that the finalisation has started.
void Rpc_StartPreload_O(vector position)
bool DoRequestRespawn(SCR_SpawnData data)
void Rpc_NotifyPreloadFinished_S()
SCR_SpawnLockComponent GetLock()
void Rpc_OnFinalizationBegin_O()
void ProcessRequest_S(SCR_SpawnData data)
void ~SCR_SpawnRequestComponent()
void ProcessCanRequest_S(SCR_SpawnData data)
void StartSpawnPreload(vector position)
void Rpc_SendResponse_O(SCR_ESpawnResult response)
bool DoCanRequestRespawn(SCR_SpawnData data)
void Rpc_SendCanResponse_O(SCR_ESpawnResult response)
SCR_SpawnHandlerComponent GetHandlerComponent()
SCR_ChimeraAIAgent FindAIAgent(IEntity entity)
void NotifyPreloadFinished_S()
void SendResponse_S(SCR_ESpawnResult response, SCR_SpawnData data)
void SendCanResponse_S(SCR_ESpawnResult response, SCR_SpawnData data)
void Rpc_NotifyPreloadStarted_S()
void NotifyPreloadStarted_S()
void AwaitFinalization_S(SCR_SpawnHandlerComponent handler, SCR_SpawnData data, IEntity spawnedEntity)
Super root of all classes in Enforce script.
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
OnPreloadFinishedInvoker GetOnPreloadFinished()
void StartSpawnPreload(vector position)
void SetPlayerPending_S(int playerId)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto external PlayerController GetPlayerController()
proto external bool CanRequestRespawn()
proto external RespawnComponent GetRespawnComponent()
proto external int GetPlayerId()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.