Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MenuSpawnLogic.c
Go to the documentation of this file.
1 [BaseContainerProps(category: "Respawn")]
3 {
4  [Attribute("", uiwidget: UIWidgets.EditBox, category: "Respawn", desc: "Default faction for players to spawn with or empty if none.")]
5  protected FactionKey m_sForcedFaction;
6 
7  [Attribute("{A1CE9D1EC16DA9BE}UI/layouts/Menus/MainMenu/SplashScreen.layout", desc: "Layout shown before deploy menu opens on client")]
8  protected ResourceName m_sLoadingLayout;
9 
10  protected Widget m_wLoadingPlaceholder;
11  protected SCR_LoadingSpinner m_LoadingPlaceholder;
12 
13  //------------------------------------------------------------------------------------------------
14  override void OnInit(SCR_RespawnSystemComponent owner)
15  {
16  if (!System.IsConsoleApp())
17  CreateLoadingPlaceholder();
18  }
19 
20  //------------------------------------------------------------------------------------------------
21  override void OnPlayerRegistered_S(int playerId)
22  {
23  super.OnPlayerRegistered_S(playerId);
24 
25  // Probe reconnection component first
26  IEntity returnedEntity;
27  if (ResolveReconnection(playerId, returnedEntity))
28  {
29  // User was reconnected, their entity was returned
30  return;
31  }
32 
33  Faction forcedFaction;
34  if (GetForcedFaction(forcedFaction))
35  {
36  PlayerController pc = GetGame().GetPlayerManager().GetPlayerController(playerId);
38  if (playerFactionComp)
39  playerFactionComp.RequestFaction(forcedFaction);
40  }
41 
42  // Send a notification to registered client:
43  // Always ensure to hook OnLocalPlayer callbacks prior to sending such notification,
44  // otherwise the notification will be disregarded
45  GetPlayerRespawnComponent_S(playerId).NotifyReadyForSpawn_S();
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  override void OnPlayerEntityLost_S(int playerId)
50  {
51  super.OnPlayerEntityLost_S(playerId);
52 
53  GetPlayerRespawnComponent_S(playerId).NotifyReadyForSpawn_S();
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  protected bool GetForcedFaction(out Faction faction)
58  {
59  if (m_sForcedFaction.IsEmpty())
60  return false;
61 
62  faction = GetGame().GetFactionManager().GetFactionByKey(m_sForcedFaction);
63  if (!faction)
64  {
65  Print(string.Format("Auto spawn logic did not find faction by name: %1", m_sForcedFaction), LogLevel.WARNING);
66  return false;
67  }
68 
69  return true;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  protected void CreateLoadingPlaceholder()
74  {
75  m_wLoadingPlaceholder = GetGame().GetWorkspace().CreateWidgets(m_sLoadingLayout);
76  if (!m_wLoadingPlaceholder)
77  return;
78 
79  Widget spinner = m_wLoadingPlaceholder.FindAnyWidget("Spinner");
80  if (!spinner)
81  return;
82 
83  m_LoadingPlaceholder = SCR_LoadingSpinner.Cast(spinner.FindHandler(SCR_LoadingSpinner));
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  bool UpdateLoadingPlaceholder(float dt)
88  {
89  if (!m_wLoadingPlaceholder || !m_LoadingPlaceholder)
90  return true;
91 
92  m_LoadingPlaceholder.Update(dt);
93  return false;
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  void DestroyLoadingPlaceholder()
98  {
99  if (!m_wLoadingPlaceholder)
100  return;
101 
102  m_wLoadingPlaceholder.RemoveFromHierarchy();
103  m_wLoadingPlaceholder = null;
104  m_LoadingPlaceholder = null;
105  }
106 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
Faction
Definition: Faction.c:12
SCR_PlayerFactionAffiliationComponent
Definition: SCR_PlayerFactionAffiliationComponent.c:16
SCR_SpawnLogic
Definition: SCR_SpawnLogic.c:11
SCR_MenuSpawnLogic
Definition: SCR_MenuSpawnLogic.c:2
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180