Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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")]
5
8
22class SCR_EditorModeEntity : SCR_EditorBaseEntity
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")]
41 [Attribute("0", UIWidgets.ComboBox, "Mode remove notification", "", ParamEnumArray.FromEnum(ENotification), category: "Notification")]
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")]
46
47 [Attribute("false", UIWidgets.Auto, "True - Mode can't be closed", category: "Editor Mode")]
48 protected bool m_bPreventClose;
49
50 private SCR_EditorManagerEntity m_EditorManager;
51
52 private ref ScriptInvoker Event_OnInit = new ScriptInvoker();
53 private ref ScriptInvoker Event_OnPreActivate = new ScriptInvoker();
54 private ref ScriptInvoker Event_OnActivate = new ScriptInvoker();
55 private ref ScriptInvoker Event_OnPostActivate = new ScriptInvoker();
56 private ref ScriptInvoker Event_OnDeactivate = new ScriptInvoker();
57
58 private ref ScriptInvoker Event_OnActivateServer = new ScriptInvoker();
59 private ref ScriptInvoker Event_OnDeactivateServer = new ScriptInvoker();
60
62 //--- Getters
67 EEditorMode GetModeType()
68 {
69 return m_ModeType;
70 }
75 int GetOrder()
76 {
77 return m_iOrder;
78 }
83 SCR_UIInfo GetInfo()
84 {
85 return m_UIInfo;
86 }
91 bool IsLimited()
92 {
93 return m_bIsLimited;
94 }
98 bool ShouldCloseAfterRemoval()
99 {
100 return m_bCloseAfterRemoval;
101 }
106 bool IsCurrent()
107 {
108 return m_EditorManager && m_EditorManager.GetCurrentModeEntity() == this;
109 }
114 static SCR_EditorModeEntity GetInstance()
115 {
116 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
117 if (!editorManager) return null;
118
119 return editorManager.GetCurrentModeEntity();
120 }
121
123 //--- Event bases
124 void PreActivateMode()
125 {
126 if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
127 return;
128
129 Event_OnPreActivate.Invoke();
130 }
131 void ActivateMode(bool isInit = false)
132 {
133 if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
134 return;
135
136 SetFlags(EntityFlags.ACTIVE);
137 Event_OnActivate.Invoke();
138 }
139 void PostActivateMode()
140 {
141 if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
142 return;
143
144 Event_OnPostActivate.Invoke();
145 }
146 void DeactivateMode()
147 {
148 if (!m_EditorManager.IsOpened() && !m_EditorManager.IsInTransition())
149 return;
150
151 Event_OnDeactivate.Invoke();
152 ClearFlags(EntityFlags.ACTIVE);
153 }
154
155 //------------------------------------------------------------------------------------------------
156 void ActivateModeServer()
157 {
158 int playerId = m_EditorManager.GetPlayerID();
159 IEntity character = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
160 string additionalInfo;
161 if (character)
162 additionalInfo = string.Format(" while being at %1", character.GetOrigin());
163
164 PrintFormat("INFO: Editor %1: Player %2 opened the editor%3.", typename.EnumToString(EEditorMode, GetModeType()), SCR_PlayerIdentityUtils.GetPlayerLogInfo(playerId), additionalInfo, level: LogLevel.NORMAL);
165 Event_OnActivateServer.Invoke();
166 }
167
168 void DeactivateModeServer()
169 {
170 Event_OnDeactivateServer.Invoke();
171 }
173 //--- Notification
178 bool SendNotificationLocalOnly()
179 {
181 }
182
183 //----------------------------------------------------------------------------------------
184 bool GetPreventClose()
185 {
186 return m_bPreventClose;
187 }
188
193 ENotification GetOnAddNotification()
194 {
196 }
197
202 ENotification GetOnRemoveNotification()
203 {
205 }
206
208 //--- Default functions
209 override ScriptInvoker GetOnInit()
210 {
211 return Event_OnInit;
212 }
213
214 override ref ScriptInvoker GetOnRequest()
215 {
216 if (!GetManager()) return null;
217 ScriptInvoker invoker = GetManager().GetOnRequest();
218 return invoker;
219 }
220 override ref ScriptInvoker GetOnOpened()
221 {
222 if (!GetManager()) return null;
223 ScriptInvoker invoker = GetManager().GetOnOpened();
224 return invoker;
225 }
226 override ref ScriptInvoker GetOnOpenedServer()
227 {
228 if (!GetManager()) return null;
229 ScriptInvoker invoker = GetManager().GetOnOpenedServer();
230 return invoker;
231 }
233 {
234 if (!GetManager()) return null;
235 ScriptInvoker invoker = GetManager().GetOnOpenedServerCallback();
236 return invoker;
237 }
239 {
240 return Event_OnPreActivate;
241 }
243 {
244 return Event_OnActivate;
245 }
247 {
248 return Event_OnPostActivate;
249 }
251 {
252 return Event_OnDeactivate;
253 }
254 override ScriptInvoker GetOnClosed()
255 {
256 if (!GetManager()) return null;
257 ScriptInvoker invoker = GetManager().GetOnClosed();
258 return invoker;
259 }
260 override ref ScriptInvoker GetOnClosedServer()
261 {
262 if (!GetManager()) return null;
263 ScriptInvoker invoker = GetManager().GetOnClosedServer();
264 return invoker;
265 }
267 {
268 if (!GetManager()) return null;
269 ScriptInvoker invoker = GetManager().GetOnClosedServerCallback();
270 return invoker;
271 }
273 {
274 return Event_OnActivateServer;
275 }
277 {
278 return Event_OnDeactivateServer;
279 }
280 override ScriptInvoker GetOnDebug()
281 {
282 if (!GetManager()) return null;
283 ScriptInvoker invoker = GetManager().GetOnDebug();
284 return invoker;
285 }
286 override bool IsOpened()
287 {
288 return m_EditorManager && m_EditorManager.IsOpened();
289 }
291 {
292 return m_EditorManager;
293 }
294 void InitServer(SCR_EditorManagerEntity editorManager)
295 {
296 RplComponent rplEditor = RplComponent.Cast(editorManager.FindComponent(RplComponent));
297 RplComponent rplMode = RplComponent.Cast(FindComponent(RplComponent));
298 if (!rplEditor || !rplMode) return;
299
300 rplMode.Give(Replication.FindOwner(rplEditor.Id()));
301
302 m_EditorManager = editorManager;
303 InitComponents(true);
304 //Rpc(InitOwner);
305 }
306 [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
307 void InitOwner()
308 {
309 //--- Activate to allow events in components
310 SetFlags(EntityFlags.ACTIVE);
311
312 m_EditorManager = SCR_EditorManagerEntity.GetInstance();
313 if (!m_EditorManager)
314 {
315 Print("Error when initialized editor mode!", LogLevel.ERROR);
316 return;
317 }
318
319 InitComponents(false);
320 Event_OnInit.Invoke();
321 }
322 void SCR_EditorModeEntity(IEntitySource src, IEntity parent)
323 {
324 ChimeraWorld world = GetGame().GetWorld();
325 if (world)
326 {
327 world.RegisterEntityToBeUpdatedWhileGameIsPaused(this);
328 }
329
330 SetFlags(EntityFlags.NO_TREE | EntityFlags.NO_LINK);
331 }
332 void ~SCR_EditorModeEntity()
333 {
334 if (m_EditorManager) m_EditorManager.RemoveMode(this, false);
335 Event_OnDeactivate.Invoke();
336
337 ChimeraWorld world = GetGame().GetWorld();
338 if (world)
339 {
340 world.UnregisterEntityToBeUpdatedWhileGameIsPaused(this);
341 }
342 }
343};
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
override ScriptInvoker GetOnPreActivate()
override ScriptInvoker GetOnActivate()
override ScriptInvoker GetOnRequest()
override ScriptInvoker GetOnOpenedServerCallback()
override ScriptInvoker GetOnClosedServerCallback()
bool IsLimited()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
override SCR_EditorManagerEntity GetManager()
override ScriptInvoker GetOnClosedServer()
override ScriptInvoker GetOnDeactivateServer()
override ScriptInvoker GetOnOpened()
override ScriptInvoker GetOnActivateServer()
override ScriptInvoker GetOnPostActivate()
override ScriptInvoker GetOnDebug()
override ScriptInvoker GetOnDeactivate()
override ScriptInvoker GetOnClosed()
override ScriptInvoker GetOnOpenedServer()
override ScriptInvoker GetOnInit()
override SCR_UIInfo GetInfo()
int GetOrder()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
void InitComponents(bool isServer)
ENotification m_ModeRemovedNotification
ENotification m_ModeAddedNotification
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
EntityFlags
Various entity flags.
Definition EntityFlags.c:14
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134