4 [
Attribute(
"", uiwidget: UIWidgets.EditBox,
category:
"Respawn",
desc:
"Default faction for players to spawn with or empty if none.")]
5 protected FactionKey m_sForcedFaction;
7 [
Attribute(
"{A1CE9D1EC16DA9BE}UI/layouts/Menus/MainMenu/SplashScreen.layout",
desc:
"Layout shown before deploy menu opens on client")]
8 protected ResourceName m_sLoadingLayout;
10 protected Widget m_wLoadingPlaceholder;
11 protected SCR_LoadingSpinner m_LoadingPlaceholder;
14 override void OnInit(SCR_RespawnSystemComponent owner)
16 if (!System.IsConsoleApp())
17 CreateLoadingPlaceholder();
21 override void OnPlayerRegistered_S(
int playerId)
23 super.OnPlayerRegistered_S(playerId);
26 IEntity returnedEntity;
27 if (ResolveReconnection(playerId, returnedEntity))
34 if (GetForcedFaction(forcedFaction))
36 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
38 if (playerFactionComp)
39 playerFactionComp.RequestFaction(forcedFaction);
45 GetPlayerRespawnComponent_S(playerId).NotifyReadyForSpawn_S();
49 override void OnPlayerEntityLost_S(
int playerId)
51 super.OnPlayerEntityLost_S(playerId);
53 GetPlayerRespawnComponent_S(playerId).NotifyReadyForSpawn_S();
57 protected bool GetForcedFaction(out
Faction faction)
59 if (m_sForcedFaction.IsEmpty())
62 faction =
GetGame().GetFactionManager().GetFactionByKey(m_sForcedFaction);
65 Print(
string.Format(
"Auto spawn logic did not find faction by name: %1", m_sForcedFaction), LogLevel.WARNING);
73 protected void CreateLoadingPlaceholder()
75 m_wLoadingPlaceholder =
GetGame().GetWorkspace().CreateWidgets(m_sLoadingLayout);
76 if (!m_wLoadingPlaceholder)
79 Widget spinner = m_wLoadingPlaceholder.FindAnyWidget(
"Spinner");
83 m_LoadingPlaceholder = SCR_LoadingSpinner.Cast(spinner.FindHandler(SCR_LoadingSpinner));
87 bool UpdateLoadingPlaceholder(
float dt)
89 if (!m_wLoadingPlaceholder || !m_LoadingPlaceholder)
92 m_LoadingPlaceholder.Update(dt);
97 void DestroyLoadingPlaceholder()
99 if (!m_wLoadingPlaceholder)
102 m_wLoadingPlaceholder.RemoveFromHierarchy();
103 m_wLoadingPlaceholder =
null;
104 m_LoadingPlaceholder =
null;