1 [
EntityEditorProps(
category:
"GameScripted/Editor", description:
"Editor mode", color:
"251 91 0 255", icon:
"WBData/EntityEditorProps/entityEditor.png")]
27 [
Attribute(
"-1",
desc:
"Order in which modes are listed. Lower number means earlier place.",
category:
"Editor Mode")]
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;
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;
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;
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();
55 private ref ScriptInvoker Event_OnActivateServer =
new ScriptInvoker();
56 private ref ScriptInvoker Event_OnDeactivateServer =
new ScriptInvoker();
95 bool ShouldCloseAfterRemoval()
97 return m_bCloseAfterRemoval;
114 if (!editorManager)
return null;
116 return editorManager.GetCurrentModeEntity();
121 void PreActivateMode()
126 Event_OnPreActivate.Invoke();
128 void ActivateMode(
bool isInit =
false)
133 SetFlags(EntityFlags.ACTIVE);
134 Event_OnActivate.Invoke();
136 void PostActivateMode()
141 Event_OnPostActivate.Invoke();
143 void DeactivateMode()
148 Event_OnDeactivate.Invoke();
149 ClearFlags(EntityFlags.ACTIVE);
151 void ActivateModeServer()
153 Event_OnActivateServer.Invoke();
155 void DeactivateModeServer()
157 Event_OnDeactivateServer.Invoke();
165 bool SendNotificationLocalOnly()
167 return m_bSendNotificationLocalOnly;
175 return m_ModeAddedNotification;
184 return m_ModeRemovedNotification;
189 override ScriptInvoker GetOnInit()
194 override ref ScriptInvoker GetOnRequest()
196 if (!GetManager())
return null;
197 ScriptInvoker invoker = GetManager().GetOnRequest();
200 override ref ScriptInvoker GetOnOpened()
202 if (!GetManager())
return null;
203 ScriptInvoker invoker = GetManager().GetOnOpened();
206 override ref ScriptInvoker GetOnOpenedServer()
208 if (!GetManager())
return null;
209 ScriptInvoker invoker = GetManager().GetOnOpenedServer();
212 override ref ScriptInvoker GetOnOpenedServerCallback()
214 if (!GetManager())
return null;
215 ScriptInvoker invoker = GetManager().GetOnOpenedServerCallback();
218 override ScriptInvoker GetOnPreActivate()
220 return Event_OnPreActivate;
222 override ScriptInvoker GetOnActivate()
224 return Event_OnActivate;
226 override ScriptInvoker GetOnPostActivate()
228 return Event_OnPostActivate;
230 override ScriptInvoker GetOnDeactivate()
232 return Event_OnDeactivate;
234 override ScriptInvoker GetOnClosed()
236 if (!GetManager())
return null;
237 ScriptInvoker invoker = GetManager().GetOnClosed();
240 override ref ScriptInvoker GetOnClosedServer()
242 if (!GetManager())
return null;
243 ScriptInvoker invoker = GetManager().GetOnClosedServer();
246 override ref ScriptInvoker GetOnClosedServerCallback()
248 if (!GetManager())
return null;
249 ScriptInvoker invoker = GetManager().GetOnClosedServerCallback();
252 override ScriptInvoker GetOnActivateServer()
254 return Event_OnActivateServer;
256 override ScriptInvoker GetOnDeactivateServer()
258 return Event_OnDeactivateServer;
260 override ScriptInvoker GetOnDebug()
262 if (!GetManager())
return null;
263 ScriptInvoker invoker = GetManager().GetOnDebug();
266 override bool IsOpened()
276 RplComponent rplEditor = RplComponent.Cast(editorManager.FindComponent(RplComponent));
277 RplComponent rplMode = RplComponent.Cast(FindComponent(RplComponent));
278 if (!rplEditor || !rplMode)
return;
280 rplMode.Give(Replication.FindOwner(rplEditor.Id()));
283 InitComponents(
true);
286 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
290 SetFlags(EntityFlags.ACTIVE);
295 Print(
"Error when initialized editor mode!", LogLevel.ERROR);
299 InitComponents(
false);
300 Event_OnInit.Invoke();
307 world.RegisterEntityToBeUpdatedWhileGameIsPaused(
this);
310 SetFlags(EntityFlags.NO_TREE | EntityFlags.NO_LINK);
315 Event_OnDeactivate.Invoke();
320 world.UnregisterEntityToBeUpdatedWhileGameIsPaused(
this);