Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GameModeEditor.c
Go to the documentation of this file.
2 {
3 };
4 
8 {
9  [Attribute(defvalue: "1", category: "Game Mode: Editor")]
10  protected bool m_bAutoInitEditor;
11 
12  [Attribute(defvalue: SCR_Enum.GetDefault(EGameModeEditorTarget.VOTE), category: "Game Mode: Editor", desc: "Who will become the Game Master?", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EGameModeEditorTarget))]
13  protected EGameModeEditorTarget m_GameMasterTarget;
14 
16  //--- Variables
17  protected int m_iPersistentGameMasterPlayerID;
18  protected SCR_EditorManagerCore m_Core;
19 
21  //--- Public getters, anywhere
27  EGameModeEditorTarget GetGameMasterTarget()
28  {
29  return m_GameMasterTarget;
30  }
31 
32  protected void OnEditorManagerCreatedServer(SCR_EditorManagerEntity editorManager)
33  {
34  if (editorManager.GetPlayerID() == SCR_PlayerController.GetLocalPlayerId() || m_GameMasterTarget == EGameModeEditorTarget.EVERYBODY)
35  {
36  SCR_VotingManagerComponent votingManager = SCR_VotingManagerComponent.GetInstance();
37  if (votingManager)
38  {
39  votingManager.StartVoting(EVotingType.EDITOR_IN, editorManager.GetPlayerID());
40  votingManager.EndVoting(EVotingType.EDITOR_IN, editorManager.GetPlayerID(), EVotingOutcome.FORCE_WIN);
41  }
42  return;
43  }
44  }
45  protected void OnEditorManagerDeletedServer(SCR_EditorManagerEntity editorManager)
46  {
47  }
48  protected void OnEditorManagerInitOwner(SCR_EditorManagerEntity editorManager)
49  {
50  if (editorManager.IsLimited())
51  {
52  //--- ToDo: Show after spawn?
53  SCR_HintSequenceComponent hintSequence = SCR_HintSequenceComponent.Cast(FindComponent(SCR_HintSequenceComponent));
54  if (hintSequence)
55  GetGame().GetCallqueue().CallLater(hintSequence.StartSequence, 1000); //--- ToDo: Don't hardcode the delay?
56  }
57  //Open editor if the game has not ended
58  else if (GetState() != SCR_EGameModeState.POSTGAME)
59  {
60  editorManager.SetAutoInit(m_bAutoInitEditor);
61  }
62  }
63 
64  //Limited changed, so call notification and show hint
65  protected void OnLimitedChanged(bool isLimited)
66  {
67  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
68  if (!editorManager) return;
69 
70  int playerID = editorManager.GetPlayerID();
71 
72  //Became Player
73  if (isLimited)
74  {
75  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_PLAYER_NO_LONGER_GM, playerID);
76  }
77  //Became GM
78  else
79  {
80  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_PLAYER_BECAME_GM, playerID);
81  }
82  }
83  protected void OnPlayerTerminated(int playerId)
84  {
85  //--- When solo, open the editor after death
86  if (m_Core.GetEditorManager(playerId) == SCR_EditorManagerEntity.GetInstance() && GetGame().GetPlayerManager().GetPlayerCount() == 1)
87  {
89  if (!playerController || !playerController.IsPossessing())
90  SCR_EditorManagerEntity.OpenInstance();
91  }
92  }
93 
95  //--- Override functions
96  override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
97  {
98  OnPlayerTerminated(playerId);
99  super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
100  }
101  override void OnPlayerDeleted(int playerId, IEntity player)
102  {
103  OnPlayerTerminated(playerId);
104  super.OnPlayerDeleted(playerId, player);
105  }
106  override void OnGameStart()
107  {
108  super.OnGameStart();
109 
110  if (RplSession.Mode() == RplMode.Client || !m_Core)
111  return;
112 
113  m_Core.Event_OnEditorManagerCreatedServer.Insert(OnEditorManagerCreatedServer);
114  m_Core.Event_OnEditorManagerDeletedServer.Insert(OnEditorManagerDeletedServer);
115 
116  SCR_EditorManagerEntity localEditorManager = SCR_EditorManagerEntity.GetInstance();
117  if (localEditorManager)
118  OnEditorManagerCreatedServer(localEditorManager);
119 
120  GameStatsApi statsApi = GetGame().GetStatsApi();
121  if (statsApi)
122  statsApi.EditorStart();
123  }
124  override void OnGameEnd()
125  {
126  if (RplSession.Mode() != RplMode.Client)
127  {
128  GameStatsApi statsApi = GetGame().GetStatsApi();
129  if (statsApi)
130  statsApi.EditorClosed();
131  }
132 
133  super.OnGameEnd();
134  }
135  void SCR_GameModeEditor(IEntitySource src, IEntity parent)
136  {
138  if (!m_Core) return;
139 
140  m_Core.Event_OnEditorManagerInitOwner.Insert(OnEditorManagerInitOwner);
141  }
142  void ~SCR_GameModeEditor()
143  {
144  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
145  if (editorManager)
146  editorManager.GetOnLimitedChange().Remove(OnLimitedChanged);
147  }
148 };
149 
151 {
155 };
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
GetState
EEditableEntityState GetState()
Definition: SCR_BaseEntitiesEditorUIEffect.c:7
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_Enum
Definition: SCR_Enum.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
Instigator
Definition: Instigator.c:6
VOTE
@ VOTE
Players will vote their own Game Master.
Definition: SCR_GameModeEditor.c:152
ENotification
ENotification
Definition: ENotification.c:4
NOBODY
@ NOBODY
Nobody is the Game Master.
Definition: SCR_GameModeEditor.c:154
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EditorManagerCore
Core component to manage SCR_EditorManagerEntity.
Definition: SCR_EditorManagerCore.c:5
EVERYBODY
@ EVERYBODY
Everyone is the Game Master.
Definition: SCR_GameModeEditor.c:153
SCR_BaseGameModeClass
Definition: SCR_BaseGameMode.c:12
SCR_GameModeEditorClass
Definition: SCR_GameModeEditor.c:1
EVotingType
EVotingType
Definition: EVotingType.c:1
GameStatsApi
Statistical Api - Analytics.
Definition: GameStatsApi.c:13
SCR_VotingManagerComponent
void SCR_VotingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_VotingManagerComponent.c:878
GetPlayerCount
int GetPlayerCount()
Definition: SCR_Faction.c:365
EGameModeEditorTarget
EGameModeEditorTarget
Definition: SCR_GameModeEditor.c:150
SCR_EGameModeState
SCR_EGameModeState
Definition: SCR_EGameModeState.c:4
EVotingOutcome
EVotingOutcome
Definition: EVotingOutcome.c:1
SCR_GameModeEditor
Definition: SCR_GameModeEditor.c:7
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26