1[
ComponentEditorProps(
category:
"GameScripted/GameMode", description:
"Communicator for RespawnSystemComponent. Should be attached to PlayerController.")]
7enum ERespawnSelectionResult
37 if (!s_OnLocalPlayerSpawned)
40 return s_OnLocalPlayerSpawned;
143 #ifdef DEBUGUI_RESPAWN_REQUEST_COMPONENT_DIAG
144 static bool s_DebugRegistered;
151 PlayerController playerController =
GetGame().GetPlayerController();
152 if (playerController)
164 PlayerController playerController =
GetGame().GetPlayerController();
165 if (!playerController)
179 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
180 if (!playerController)
194 [
Obsolete(
"Use SCR_PlayerFactionAffiliationComponent instead!")]
198 [
Obsolete(
"Use SCR_PlayerLoadoutComponent instead!")]
202 [
Obsolete(
"Use SCR_RespawnComponent.RequestSpawn directly instead!")]
206 [
Obsolete(
"Use SCR_PlayerLoadoutComponent instead!")]
210 [
Obsolete(
"Use SCR_PlayerFactionAffiliationComponent instead!")]
214 [
Obsolete(
"Use SCR_RespawnComponent.RequestSpawn directly instead!")]
225 if (!controlledEntity)
228 CharacterControllerComponent characterController = CharacterControllerComponent.Cast(controlledEntity.
FindComponent(CharacterControllerComponent));
229 if (characterController)
231 characterController.ForceDeath();
237 [
Obsolete(
"Use SCR_PlayerLoadoutComponent instead!")]
241 [
Obsolete(
"Use SCR_PlayerFactionAffiliationComponent instead!")]
245 [
Obsolete(
"Use SCR_RespawnComponent.RequestSpawn directly instead!")]
260 #ifdef _ENABLE_RESPAWN_LOGS
267 if (Diag_IsCLISpawnEnabled())
268 Diag_RequestCLISpawn();
277 [
Obsolete(
"Use SCR_RespawnComponent.RequestSpawn instead.")]
289 requestComponent.DrawDiag();
298 ConnectToDiagSystem(owner);
300 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_RESPAWN_COMPONENT_TIME,
"",
"Respawn Time Measures",
"GameMode");
306 Print(
"SCR_RespawnComponent must be attached to PlayerController!",
LogLevel.ERROR);
310 SCR_SpawnLockComponent lockComponent = SCR_SpawnLockComponent.Cast(owner.
FindComponent(SCR_SpawnLockComponent));
313 Print(
string.Format(
"%1 does not have a %2 attached!",
324 Print(
"No game mode found in the world, SCR_RespawnComponent will not function correctly!",
LogLevel.ERROR);
332 DisconnectFromDiagSystem(owner);
334 super.OnDelete(owner);
355 if (!requestComponent)
357 Print(
string.Format(
"%1::RequestRespawn(data: %2) could not find associated %3!",
362 return requestComponent.RequestRespawn(
data);
383 if (!requestComponent)
385 Print(
string.Format(
"%1::RequestRespawn(data: %2) could not find associated %3!",
390 return requestComponent.CanRequestRespawn(
data);
398 array<GenericComponent> components = {};
399 FindComponents(SCR_SpawnRequestComponent, components);
402 SCR_SpawnRequestComponent requestComponent = SCR_SpawnRequestComponent.Cast(genericComponent);
403 typename dataType = requestComponent.GetDataType();
406 Debug.Error(
string.Format(
"Cannot register %1! %2 already contains a mapping for %3 data type! (old: %4)",
407 requestComponent.Type().ToString(),
417 #ifdef _ENABLE_RESPAWN_LOGS
418 string typeName =
"null";
419 if (dataType !=
typename.Empty)
420 typeName = dataType.ToString();
421 Print(
string.Format(
"%1::RegisterRespawnRequestComponents() registered %2 component for requests of %3 type.",
Type().
ToString(),
422 requestComponent.Type().ToString(),
437 SCR_SpawnRequestComponent component;
446 static bool Diag_IsCLISpawnEnabled()
448 return System.IsCLIParam(
"autodeployFaction") || System.IsCLIParam(
"autodeployLoadout") ||
449 System.IsCLIParam(
"tdmf") || System.IsCLIParam(
"tdml");
454 void Diag_RequestCLISpawn()
458 if (System.GetCLIParam(
"autodeployFaction", fs) || System.GetCLIParam(
"tdmf", fs))
460 Faction factionFromKey =
GetGame().GetFactionManager().GetFactionByKey(fs);
462 if (factionFromKey != null)
463 factionId =
GetGame().GetFactionManager().GetFactionIndex(factionFromKey);
465 factionId = fs.ToInt();
470 if (System.GetCLIParam(
"autodeployLoadout", fs) || System.GetCLIParam(
"tdml", ls))
472 SCR_BasePlayerLoadout loadoutFromKey =
GetGame().GetLoadoutManager().GetLoadoutByName(ls);
474 if (loadoutFromKey != null)
475 loadoutId =
GetGame().GetLoadoutManager().GetLoadoutIndex(loadoutFromKey);
477 loadoutId = ls.ToInt();
480 Rpc(Rpc_RequestCLISpawn_S, factionId, loadoutId);
485 protected void Rpc_RequestCLISpawn_S(
int factionIdx,
int loadoutIdx)
488 Faction faction =
GetGame().GetFactionManager().GetFactionByIndex(factionIdx);
489 SCR_BasePlayerLoadout
loadout =
GetGame().GetLoadoutManager().GetLoadoutByIndex(loadoutIdx);
494 SCR_FactionPlayerLoadout factionLoadout = SCR_FactionPlayerLoadout.Cast(
loadout);
496 faction =
GetGame().GetFactionManager().GetFactionByKey(factionLoadout.GetFactionKey());
501 loadout =
GetGame().GetLoadoutManager().GetRandomFactionLoadout(faction);
503 SCR_PlayerFactionAffiliationComponent factionComponent = SCR_PlayerFactionAffiliationComponent.Cast(
m_PlayerController.FindComponent(SCR_PlayerFactionAffiliationComponent));
504 if (factionComponent)
510 SCR_PlayerLoadoutComponent loadoutComponent = SCR_PlayerLoadoutComponent.Cast(
m_PlayerController.FindComponent(SCR_PlayerLoadoutComponent));
511 if (loadoutComponent)
519 ResourceName resource =
loadout.GetLoadoutResource();
520 SCR_SpawnPoint spawnPoint = SCR_SpawnPoint.GetSpawnPointsForFaction(faction.GetFactionKey()).GetRandomElement();
521 if (!resource.IsEmpty() && spawnPoint)
523 SCR_SpawnPointSpawnData spsd =
new SCR_SpawnPointSpawnData(resource, spawnPoint.
GetRplId());
529 Rpc(Rpc_ResponseCLISpawn_O, ok);
534 protected void Rpc_ResponseCLISpawn_O(
int response)
536 bool faction = (response & (1 << 1));
537 bool loadout = (response & (1 << 2));
538 bool spawn = (response & (1 << 3));
541 const string msg =
"Server request to spawn using diagnostics mode processed (-autodeployFaction/-autodeployLoadout), result:\n\tFaction: %1, Loadout: %2, Spawn: %3";
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
RplComponent m_RplComponent
Get all prefabs that have the spawner data
Get all prefabs that have the spawner the given labels and are valid in the editor mode param catalogType Type to catalog to get prefabs from param editorMode Editor mode to get valid entries from param faction Faction(Optional)
SCR_FastTravelComponentClass m_PlayerController
bool RequestPlayerSpawnPoint(SCR_SpawnPoint spawnPoint)
void Rpc_NotifyReadyForSpawn_O()
OnRespawnReadyInvoker GetOnRespawnReadyInvoker_O()
OnRespawnRequestInvoker GetOnRespawnRequestInvoker_S()
OnRespawnRequestInvoker GetOnRespawnRequestInvoker_O()
ref OnCanRespawnResponseInvoker m_OnCanRespawnResponseInvoker_O
void RequestRespawn()
Sends a respawn request based on assigned loadout and selected spawn point.
ref OnRespawnResponseInvoker m_OnRespawnResponseInvoker_O
void RequestQuickRespawn()
ref map< typename, SCR_SpawnRequestComponent > m_mRequestComponents
void RequestPlayerFactionIndex(int factionIndex)
OnRespawnResponseInvoker GetOnRespawnResponseInvoker_O()
ref OnRespawnRequestInvoker m_OnRespawnFinalizeBeginInvoker_O
void RequestPlayerSpawnPointIdentity(RplId spawnPointIdentity)
OnRespawnResponseInvoker GetOnRespawnResponseInvoker_S()
OnCanRespawnResponseInvoker GetOnCanRespawnResponseInvoker_O()
void NotifyReadyForSpawn_S()
bool RequestPlayerLoadout(SCR_BasePlayerLoadout loadout)
OnRespawnRequestInvoker GetOnRespawnFinalizeBeginInvoker_O()
SCR_RespawnComponentClass OK
Result code for request/assign response.
void RequestPlayerSuicide()
void RequestClearPlayerSpawnPoint()
bool RequestClearPlayerLoadout()
ref OnRespawnResponseInvoker m_OnRespawnResponseInvoker_S
bool RequestSpawn(SCR_SpawnData data)
SCR_SpawnRequestComponent GetRequestComponent(SCR_SpawnData data)
OnCanRespawnResponseInvoker GetOnCanRespawnResponseInvoker_S()
void RequestPlayerLoadoutIndex(int loadoutIndex)
ref OnCanRespawnRequestInvoker m_OnCanRespawnRequestInvoker_S
OnCanRespawnRequestInvoker GetOnCanRespawnRequestInvoker_O()
bool CanSpawn(SCR_SpawnData data)
bool RequestPlayerFaction(Faction faction)
SCR_RespawnComponentClass ERROR_FORBIDDEN
Can happen if we are setting a loadout from a faction to which we do not belong to or similar.
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ref OnRespawnRequestInvoker m_OnRespawnRequestInvoker_O
OnCanRespawnRequestInvoker GetOnCanRespawnRequestInvoker_S()
ref OnCanRespawnResponseInvoker m_OnCanRespawnResponseInvoker_S
ref OnRespawnRequestInvoker m_OnRespawnRequestInvoker_S
ref OnCanRespawnRequestInvoker m_OnCanRespawnRequestInvoker_O
ref OnRespawnReadyInvoker m_OnRespawnReadyInvoker_O
bool RequestClearPlayerFaction()
void RegisterRespawnRequestComponents(IEntity owner)
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
ScriptInvokerBase< RespawnResponseDelegate > OnRespawnResponseInvoker
ScriptInvokerBase< RespawnReadyDelegate > OnRespawnReadyInvoker
ScriptInvokerBase< CanRespawnRequestDelegate > OnCanRespawnRequestInvoker
ScriptInvokerBase< CanRespawnResponseDelegate > OnCanRespawnResponseInvoker
ScriptInvokerBase< RespawnRequestDelegate > OnRespawnRequestInvoker
proto external Managed FindComponent(typename typeName)
Replication item identifier.
bool RequestFaction(Faction faction)
bool RequestLoadout(SCR_BasePlayerLoadout loadout)
Spawn point entity defines positions on which players can possibly spawn.
void OnDiag(IEntity owner, float timeslice)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
@ ERROR
Same as DELETE, but global error count for OnAfterLoad is affected.
RplComponent GetRplComponent()
Returns the replication component associated to this entity.
proto external PlayerController GetPlayerController()
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.