Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditorModeEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Editor", description: "Editor mode", color: "251 91 0 255", icon: "WBData/EntityEditorProps/entityEditor.png")]
3 {
4 };
5 
23 {
24  [Attribute(SCR_Enum.GetDefault(EEditorMode.EDIT), desc: "Mode this entity controls.", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditorMode), category: "Editor Mode")]
25  private EEditorMode m_ModeType;
26 
27  [Attribute("-1", desc: "Order in which modes are listed. Lower number means earlier place.", category: "Editor Mode")]
28  private int m_iOrder;
29 
30  [Attribute(desc: "Anti-exploit restriction will be in effect when all available modes are marked as limited.", category: "Editor Mode")]
31  private bool m_bIsLimited;
32 
33  [Attribute(desc: "When enabled, removing this mode when it's current will close the editor instead of switching to the next available mode.", category: "Editor Mode")]
34  private bool m_bCloseAfterRemoval;
35 
36  [Attribute(desc: "GUI representation of the mode.", category: "Editor Mode")]
37  private ref SCR_UIInfo m_UIInfo;
38 
39  [Attribute("0", UIWidgets.ComboBox, "Mode add notification", "", ParamEnumArray.FromEnum(ENotification), category: "Notification")]
40  protected ENotification m_ModeAddedNotification;
41  [Attribute("0", UIWidgets.ComboBox, "Mode remove notification", "", ParamEnumArray.FromEnum(ENotification), category: "Notification")]
42  protected ENotification m_ModeRemovedNotification;
43 
44  [Attribute("0", desc: "If true will only notify the local player when the mode is added or removed, if false it sends to to all Game Masters and the local player", category: "Notification")]
45  protected bool m_bSendNotificationLocalOnly;
46 
47  private SCR_EditorManagerEntity m_EditorManager;
48 
49  private ref ScriptInvoker Event_OnInit = new ScriptInvoker();
50  private ref ScriptInvoker Event_OnPreActivate = new ScriptInvoker();
51  private ref ScriptInvoker Event_OnActivate = new ScriptInvoker();
52  private ref ScriptInvoker Event_OnPostActivate = new ScriptInvoker();
53  private ref ScriptInvoker Event_OnDeactivate = new ScriptInvoker();
54 
55  private ref ScriptInvoker Event_OnActivateServer = new ScriptInvoker();
56  private ref ScriptInvoker Event_OnDeactivateServer = new ScriptInvoker();
57 
59  //--- Getters
64  EEditorMode GetModeType()
65  {
66  return m_ModeType;
67  }
72  int GetOrder()
73  {
74  return m_iOrder;
75  }
80  SCR_UIInfo GetInfo()
81  {
82  return m_UIInfo;
83  }
88  bool IsLimited()
89  {
90  return m_bIsLimited;
91  }
95  bool ShouldCloseAfterRemoval()
96  {
97  return m_bCloseAfterRemoval;
98  }
103  bool IsCurrent()
104  {
105  return m_EditorManager && m_EditorManager.GetCurrentModeEntity() == this;
106  }
111  static SCR_EditorModeEntity GetInstance()
112  {
113  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
114  if (!editorManager) return null;
115 
116  return editorManager.GetCurrentModeEntity();
117  }
118 
120  //--- Event bases
121  void PreActivateMode()
122  {
123  if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
124  return;
125 
126  Event_OnPreActivate.Invoke();
127  }
128  void ActivateMode(bool isInit = false)
129  {
130  if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
131  return;
132 
133  SetFlags(EntityFlags.ACTIVE);
134  Event_OnActivate.Invoke();
135  }
136  void PostActivateMode()
137  {
138  if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
139  return;
140 
141  Event_OnPostActivate.Invoke();
142  }
143  void DeactivateMode()
144  {
145  if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
146  return;
147 
148  Event_OnDeactivate.Invoke();
149  ClearFlags(EntityFlags.ACTIVE);
150  }
151  void ActivateModeServer()
152  {
153  Event_OnActivateServer.Invoke();
154  }
155  void DeactivateModeServer()
156  {
157  Event_OnDeactivateServer.Invoke();
158  }
160  //--- Notification
165  bool SendNotificationLocalOnly()
166  {
167  return m_bSendNotificationLocalOnly;
168  }
173  ENotification GetOnAddNotification()
174  {
175  return m_ModeAddedNotification;
176  }
177 
182  ENotification GetOnRemoveNotification()
183  {
184  return m_ModeRemovedNotification;
185  }
186 
188  //--- Default functions
189  override ScriptInvoker GetOnInit()
190  {
191  return Event_OnInit;
192  }
193 
194  override ref ScriptInvoker GetOnRequest()
195  {
196  if (!GetManager()) return null;
197  ScriptInvoker invoker = GetManager().GetOnRequest();
198  return invoker;
199  }
200  override ref ScriptInvoker GetOnOpened()
201  {
202  if (!GetManager()) return null;
203  ScriptInvoker invoker = GetManager().GetOnOpened();
204  return invoker;
205  }
206  override ref ScriptInvoker GetOnOpenedServer()
207  {
208  if (!GetManager()) return null;
209  ScriptInvoker invoker = GetManager().GetOnOpenedServer();
210  return invoker;
211  }
212  override ref ScriptInvoker GetOnOpenedServerCallback()
213  {
214  if (!GetManager()) return null;
215  ScriptInvoker invoker = GetManager().GetOnOpenedServerCallback();
216  return invoker;
217  }
218  override ScriptInvoker GetOnPreActivate()
219  {
220  return Event_OnPreActivate;
221  }
222  override ScriptInvoker GetOnActivate()
223  {
224  return Event_OnActivate;
225  }
226  override ScriptInvoker GetOnPostActivate()
227  {
228  return Event_OnPostActivate;
229  }
230  override ScriptInvoker GetOnDeactivate()
231  {
232  return Event_OnDeactivate;
233  }
234  override ScriptInvoker GetOnClosed()
235  {
236  if (!GetManager()) return null;
237  ScriptInvoker invoker = GetManager().GetOnClosed();
238  return invoker;
239  }
240  override ref ScriptInvoker GetOnClosedServer()
241  {
242  if (!GetManager()) return null;
243  ScriptInvoker invoker = GetManager().GetOnClosedServer();
244  return invoker;
245  }
246  override ref ScriptInvoker GetOnClosedServerCallback()
247  {
248  if (!GetManager()) return null;
249  ScriptInvoker invoker = GetManager().GetOnClosedServerCallback();
250  return invoker;
251  }
252  override ScriptInvoker GetOnActivateServer()
253  {
254  return Event_OnActivateServer;
255  }
256  override ScriptInvoker GetOnDeactivateServer()
257  {
258  return Event_OnDeactivateServer;
259  }
260  override ScriptInvoker GetOnDebug()
261  {
262  if (!GetManager()) return null;
263  ScriptInvoker invoker = GetManager().GetOnDebug();
264  return invoker;
265  }
266  override bool IsOpened()
267  {
268  return m_EditorManager && m_EditorManager.IsOpened();
269  }
270  override SCR_EditorManagerEntity GetManager()
271  {
272  return m_EditorManager;
273  }
274  void InitServer(SCR_EditorManagerEntity editorManager)
275  {
276  RplComponent rplEditor = RplComponent.Cast(editorManager.FindComponent(RplComponent));
277  RplComponent rplMode = RplComponent.Cast(FindComponent(RplComponent));
278  if (!rplEditor || !rplMode) return;
279 
280  rplMode.Give(Replication.FindOwner(rplEditor.Id()));
281 
282  m_EditorManager = editorManager;
283  InitComponents(true);
284  //Rpc(InitOwner);
285  }
286  [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
287  void InitOwner()
288  {
289  //--- Activate to allow events in components
290  SetFlags(EntityFlags.ACTIVE);
291 
293  if (!m_EditorManager)
294  {
295  Print("Error when initialized editor mode!", LogLevel.ERROR);
296  return;
297  }
298 
299  InitComponents(false);
300  Event_OnInit.Invoke();
301  }
302  void SCR_EditorModeEntity(IEntitySource src, IEntity parent)
303  {
304  ChimeraWorld world = GetGame().GetWorld();
305  if (world)
306  {
307  world.RegisterEntityToBeUpdatedWhileGameIsPaused(this);
308  }
309 
310  SetFlags(EntityFlags.NO_TREE | EntityFlags.NO_LINK);
311  }
312  void ~SCR_EditorModeEntity()
313  {
314  if (m_EditorManager) m_EditorManager.RemoveMode(this, false);
315  Event_OnDeactivate.Invoke();
316 
317  ChimeraWorld world = GetGame().GetWorld();
318  if (world)
319  {
320  world.UnregisterEntityToBeUpdatedWhileGameIsPaused(this);
321  }
322  }
323 };
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_EditorBaseEntityClass
Definition: SCR_EditorBaseEntity.c:2
SCR_Enum
Definition: SCR_Enum.c:1
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
m_UIInfo
protected SCR_UIInfo m_UIInfo
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:17
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditorModeEntity
Definition: SCR_EditorModeEntity.c:22
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
m_iOrder
int m_iOrder
Definition: SCR_BaseActionsEditorComponent.c:6
ENotification
ENotification
Definition: ENotification.c:4
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_EditorManager
protected SCR_EditorManagerEntity m_EditorManager
Definition: SCR_VotingEditor.c:5
SCR_UIInfo
Definition: SCR_UIInfo.c:7
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition: EEditorMode.c:5
SCR_EditorBaseEntity
Definition: SCR_EditorBaseEntity.c:14
SCR_EditorModeEntityClass
Definition: SCR_EditorModeEntity.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26