Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PersistenceSystem.c
Go to the documentation of this file.
3
6
9
11{
12 protected ref ScriptInvokerBase<SCR_PersistenceSystem_OnStateChanged> m_OnStateChanged = new ScriptInvokerBase<SCR_PersistenceSystem_OnStateChanged>();
13 protected ref ScriptInvokerBase<SCR_PersistenceSystem_OnBeforeSave> m_OnBeforeSave = new ScriptInvokerBase<SCR_PersistenceSystem_OnBeforeSave>();
14 protected ref ScriptInvokerBase<SCR_PersistenceSystem_OnAfterSave> m_OnAfterSave = new ScriptInvokerBase<SCR_PersistenceSystem_OnAfterSave>();
15
16 //------------------------------------------------------------------------------------------------
17 override protected void OnStateChanged(EPersistenceSystemState oldState, EPersistenceSystemState newState)
18 {
19 m_OnStateChanged.Invoke(oldState, newState);
20 }
21
22 //------------------------------------------------------------------------------------------------
23 override protected void OnBeforeSave(ESaveGameType saveType)
24 {
25 m_OnBeforeSave.Invoke(saveType);
26 }
27
28 //------------------------------------------------------------------------------------------------
29 override protected void OnAfterSave(ESaveGameType saveType, bool success)
30 {
31 m_OnAfterSave.Invoke(saveType, success);
32
33 if (success)
34 SCR_NotificationsComponent.SendLocal(ENotification.EDITOR_SESSION_SAVE_SUCCESS);
35 else
36 SCR_NotificationsComponent.SendLocal(ENotification.EDITOR_SESSION_SAVE_FAIL);
37 }
38
39 //------------------------------------------------------------------------------------------------
40 override protected void OnAfterLoad(bool success)
41 {
42 if (System.IsConsoleApp())
43 return;
44
45 if (!success)
46 {
47 GetGame().GetCallqueue().Call(DeferredNotifcation, ENotification.EDITOR_SESSION_LOAD_FAIL);
48 return;
49 }
50
51 const SaveGameManager manager = GetGame().GetSaveGameManager();
52 if (manager && manager.GetActiveSave())
53 GetGame().GetCallqueue().Call(DeferredNotifcation, ENotification.EDITOR_SESSION_LOAD_SUCCESS);
54 }
55
56 //------------------------------------------------------------------------------------------------
57 override protected void HandleDelete(IEntity entity)
58 {
59 SCR_EntityHelper.DeleteBuilding(entity);
60 }
61
62 //------------------------------------------------------------------------------------------------
63 protected void DeferredNotifcation(ENotification notification)
64 {
65 SCR_NotificationsComponent.SendLocal(notification);
66 }
67
68 //------------------------------------------------------------------------------------------------
69 sealed ScriptInvokerBase<SCR_PersistenceSystem_OnStateChanged> GetOnStateChanged()
70 {
71 return m_OnStateChanged;
72 }
73
74 //------------------------------------------------------------------------------------------------
75 sealed ScriptInvokerBase<SCR_PersistenceSystem_OnBeforeSave> GetOnBeforeSave()
76 {
77 return m_OnBeforeSave;
78 }
79
80 //------------------------------------------------------------------------------------------------
81 sealed ScriptInvokerBase<SCR_PersistenceSystem_OnAfterSave> GetOnAfterSave()
82 {
83 return m_OnAfterSave;
84 }
85
86 //------------------------------------------------------------------------------------------------
91 sealed static bool IsLoadInProgress(float msSinceLoad = 1000.0)
92 {
93 // TODO: We need to know if and what data to load ahead of even world systems init. Add pre world load phase.
94 if (!GetGame().GetSaveGameManager().GetActiveSave())
95 return false;
96
97 const PersistenceSystem instance = GetInstance();
98 if (!instance)
99 return false;
100
101 const EPersistenceSystemState state = instance.GetState();
102 if (instance.GetState() < EPersistenceSystemState.ACTIVE)
103 return true;
104
105 return instance.WasDataLoaded() && (GetGame().GetWorld().GetWorldTime() < msSinceLoad);
106 }
107
108 //------------------------------------------------------------------------------------------------
110 {
111 return SCR_PersistenceSystem.Cast(GetInstance());
112 }
113
114 //------------------------------------------------------------------------------------------------
116 {
117 ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
118 if (!world)
119 return null;
120
121 return SCR_PersistenceSystem.Cast(world.FindSystem(SCR_PersistenceSystem));
122 }
123
124 //------------------------------------------------------------------------------------------------
126 {
127 ChimeraWorld world = ChimeraWorld.CastFrom(entity.GetWorld());
128 if (!world)
129 return null;
130
131 return SCR_PersistenceSystem.Cast(world.FindSystem(SCR_PersistenceSystem));
132 }
133}
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
func SCR_PersistenceSystem_OnBeforeSave
func SCR_PersistenceSystem_OnStateChanged
func SCR_PersistenceSystem_OnAfterSave
proto external BaseWorld GetWorld()
static sealed SCR_PersistenceSystem GetByCurrentWorld()
void OnStateChanged(EPersistenceSystemState oldState, EPersistenceSystemState newState)
ref ScriptInvokerBase< SCR_PersistenceSystem_OnBeforeSave > m_OnBeforeSave
static sealed bool IsLoadInProgress(float msSinceLoad=1000.0)
void HandleDelete(IEntity entity)
static sealed SCR_PersistenceSystem GetByEntityWorld(IEntity entity)
static sealed SCR_PersistenceSystem GetScriptedInstance()
void OnAfterLoad(bool success)
void OnAfterSave(ESaveGameType saveType, bool success)
sealed ScriptInvokerBase< SCR_PersistenceSystem_OnAfterSave > GetOnAfterSave()
sealed ScriptInvokerBase< SCR_PersistenceSystem_OnStateChanged > GetOnStateChanged()
void DeferredNotifcation(ENotification notification)
sealed ScriptInvokerBase< SCR_PersistenceSystem_OnBeforeSave > GetOnBeforeSave()
ref ScriptInvokerBase< SCR_PersistenceSystem_OnStateChanged > m_OnStateChanged
ref ScriptInvokerBase< SCR_PersistenceSystem_OnAfterSave > m_OnAfterSave
void OnBeforeSave(ESaveGameType saveType)
ESaveGameType
EPersistenceSystemState