Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_RewindComponent.c
Go to the documentation of this file.
1
[
ComponentEditorProps
(
category
:
"GameScripted/GameMode/Components"
, description:
""
)]
2
class
SCR_RewindComponentClass
:
SCR_BaseGameModeComponentClass
3
{
4
}
5
6
class
SCR_RewindComponent :
SCR_BaseGameModeComponent
7
{
8
protected
ref
ScriptInvokerVoid
m_OnRewindPointChanged
;
9
protected
const
static
string
s_RewindPointName =
"Rewind"
;
10
protected
SaveGame
m_RewindPoint
;
11
protected
bool
m_bWasRewinded
;
12
13
//------------------------------------------------------------------------------------------------
15
static
SCR_RewindComponent GetInstance()
16
{
17
BaseGameMode gameMode =
GetGame
().GetGameMode();
18
if
(!gameMode)
19
return
null;
20
21
return
SCR_RewindComponent.Cast(gameMode.FindComponent(SCR_RewindComponent));
22
}
23
24
//------------------------------------------------------------------------------------------------
25
ScriptInvokerVoid
GetOnRewindPointChanged
()
26
{
27
if
(!
m_OnRewindPointChanged
)
28
m_OnRewindPointChanged
=
new
ScriptInvokerVoid
();
29
30
return
m_OnRewindPointChanged
;
31
}
32
33
//------------------------------------------------------------------------------------------------
35
bool
CanRewind
()
36
{
37
return
GetGame
().GetSaveGameManager().IsSavingEnabled();
38
}
39
40
//------------------------------------------------------------------------------------------------
42
bool
HasRewindPoint
()
43
{
44
return
m_RewindPoint
!= null;
45
}
46
47
//------------------------------------------------------------------------------------------------
49
bool
WasRewinded
()
50
{
51
return
m_bWasRewinded
;
52
}
53
54
//------------------------------------------------------------------------------------------------
56
void
CreateRewindPoint
()
57
{
58
if
(!
Replication
.IsServer() ||
HasRewindPoint
())
59
return
;
60
61
GetGame
().GetSaveGameManager().RequestSavePoint(
ESaveGameType
.AUTO, s_RewindPointName,
ESaveGameRequestFlags
.BLOCKING,
new
SaveGameOperationCallback
(
OnRewindPointCreated
));
62
}
63
64
//------------------------------------------------------------------------------------------------
65
protected
void
OnRewindPointCreated
(
bool
success)
66
{
67
if
(!success)
68
return
;
69
70
m_RewindPoint
=
GetGame
().GetSaveGameManager().GetActiveSave();
71
m_OnRewindPointChanged
.Invoke();
72
73
RemoveUnusedRewindPoints
();
74
}
75
76
//------------------------------------------------------------------------------------------------
78
void
DeleteRewindPoint
()
79
{
80
if
(!
m_RewindPoint
)
81
return
;
82
83
GetGame
().GetSaveGameManager().Delete(
m_RewindPoint
);
84
}
85
86
//------------------------------------------------------------------------------------------------
87
protected
void
OnRewindDeleted
()
88
{
89
if
(!
m_RewindPoint
)
90
return
;
91
92
m_RewindPoint
= null;
93
m_OnRewindPointChanged
.Invoke();
94
95
RemoveUnusedRewindPoints
();
96
}
97
98
//------------------------------------------------------------------------------------------------
100
void
Rewind
()
101
{
102
if
(!
m_RewindPoint
)
103
return
;
104
105
GetGame
().GetSaveGameManager().Load(
m_RewindPoint
);
106
}
107
108
//------------------------------------------------------------------------------------------------
109
override
void
OnPostInit
(
IEntity
owner)
110
{
111
if
(
SCR_Global
.
IsEditMode
(owner))
112
return
;
113
114
const
SaveGameManager
manager =
GetGame
().GetSaveGameManager();
115
EventProvider
.
ConnectEvent
(manager.OnSaveCreated,
OnSavedCreated
);
116
EventProvider
.
ConnectEvent
(manager.OnSaveDeleted,
OnSaveDeleted
);
117
118
// When loading a rewind we remember it to pause game time later, but delete it anyway. If user hits play again it will make a new rewind point
119
const
SaveGame
save = manager.GetActiveSave();
120
m_bWasRewinded
= save &&
IsRewindPoint
(save);
121
RemoveUnusedRewindPoints
();
122
}
123
124
//------------------------------------------------------------------------------------------------
125
override
void
OnDelete
(
IEntity
owner)
126
{
127
if
(
SCR_Global
.
IsEditMode
(owner))
128
return
;
129
130
EventProvider
.
DisconnectEvent
(
GetGame
().GetSaveGameManager().OnSaveCreated,
OnSavedCreated
);
131
EventProvider
.
DisconnectEvent
(
GetGame
().GetSaveGameManager().
OnSaveDeleted
,
OnSaveDeleted
);
132
RemoveUnusedRewindPoints
();
133
}
134
135
//------------------------------------------------------------------------------------------------
137
protected
void
RemoveUnusedRewindPoints
()
138
{
139
const
SaveGameManager
manager =
GetGame
().GetSaveGameManager();
140
manager.GetSaves(manager.GetCurrentMissionResource(),
new
SaveGameObtainCallback
(
ProcessRemoveUnusedRewindPoints
));
141
}
142
143
//------------------------------------------------------------------------------------------------
144
protected
void
ProcessRemoveUnusedRewindPoints
(
bool
success, array<SaveGame> saves)
145
{
146
const
SaveGameManager
manager =
GetGame
().GetSaveGameManager();
147
const
int
currentPlaythrough = manager.GetCurrentPlaythroughNumber();
148
const
SaveGame
activeSave = manager.GetActiveSave();
149
foreach
(
SaveGame
save : saves)
150
{
151
if
(save != activeSave && (save.GetPlaythroughNumber() == currentPlaythrough) &&
IsRewindPoint
(save))
152
manager.Delete(save);
153
}
154
}
155
156
//------------------------------------------------------------------------------------------------
157
bool
IsRewindPoint
(notnull
const
SaveGame
save)
158
{
159
return
(save ==
m_RewindPoint
) || (save.GetType() ==
ESaveGameType
.AUTO && save.GetSavePointName() == s_RewindPointName);
160
}
161
162
//------------------------------------------------------------------------------------------------
163
[ReceiverAttribute()]
164
protected
void
OnSavedCreated
(
SaveGame
save)
165
{
166
if
(save && save.GetType() ==
ESaveGameType
.MANUAL)
167
DeleteRewindPoint
();
168
}
169
170
//------------------------------------------------------------------------------------------------
171
[ReceiverAttribute()]
172
protected
void
OnSaveDeleted
(
SaveGame
save)
173
{
174
if
(save ==
m_RewindPoint
)
175
OnRewindDeleted
();
176
}
177
}
178
179
class
SCR_RewindDialog :
SCR_ConfigurableDialogUi
180
{
181
//------------------------------------------------------------------------------------------------
182
void
SCR_RewindDialog()
183
{
184
SCR_ConfigurableDialogUi
.
CreateFromPreset
(
SCR_CommonDialogs
.DIALOGS_CONFIG,
"rewind"
,
this
);
185
}
186
187
//------------------------------------------------------------------------------------------------
188
override
void
OnConfirm
()
189
{
190
SCR_RewindComponent.GetInstance().Rewind();
191
}
192
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ComponentEditorProps
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
Definition
SCR_AIGroupUtilityComponent.c:12
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_BaseGameModeComponent.c:171
m_RewindPoint
SaveGame m_RewindPoint
Definition
SCR_RewindComponent.c:10
IsRewindPoint
bool IsRewindPoint(notnull const SaveGame save)
Definition
SCR_RewindComponent.c:157
CreateRewindPoint
void CreateRewindPoint()
Create a rewind point for this session.
Definition
SCR_RewindComponent.c:56
OnSavedCreated
void OnSavedCreated(SaveGame save)
Definition
SCR_RewindComponent.c:164
RemoveUnusedRewindPoints
void RemoveUnusedRewindPoints()
Remove any rewind points that were not cleaned up from last playthrough.
Definition
SCR_RewindComponent.c:137
Rewind
void Rewind()
Rewind to existing rewind point of this session.
Definition
SCR_RewindComponent.c:100
OnRewindDeleted
void OnRewindDeleted()
Definition
SCR_RewindComponent.c:87
OnSaveDeleted
void OnSaveDeleted(SaveGame save)
Definition
SCR_RewindComponent.c:172
DeleteRewindPoint
void DeleteRewindPoint()
Remove existing rewind point for this session.
Definition
SCR_RewindComponent.c:78
HasRewindPoint
bool HasRewindPoint()
Definition
SCR_RewindComponent.c:42
m_bWasRewinded
bool m_bWasRewinded
Definition
SCR_RewindComponent.c:11
ProcessRemoveUnusedRewindPoints
void ProcessRemoveUnusedRewindPoints(bool success, array< SaveGame > saves)
Definition
SCR_RewindComponent.c:144
CanRewind
bool CanRewind()
Definition
SCR_RewindComponent.c:35
WasRewinded
bool WasRewinded()
Definition
SCR_RewindComponent.c:49
GetOnRewindPointChanged
ScriptInvokerVoid GetOnRewindPointChanged()
Definition
SCR_RewindComponent.c:25
m_OnRewindPointChanged
SCR_RewindComponentClass m_OnRewindPointChanged
OnRewindPointCreated
void OnRewindPointCreated(bool success)
Definition
SCR_RewindComponent.c:65
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition
SCR_ScriptInvokerHelper.c:9
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
EventProvider
Class for broadcasting events to registered receivers.
Definition
EventProvider.c:29
EventProvider::ConnectEvent
static proto bool ConnectEvent(func eventSender, func eventReceiver)
EventProvider::DisconnectEvent
static proto bool DisconnectEvent(func eventSender, func eventReceiver)
IEntity
Definition
IEntity.c:13
Replication
Main replication API.
Definition
Replication.c:14
SCR_BaseGameModeComponentClass
Definition
SCR_BaseGameModeComponent.c:3
SCR_CommonDialogs
Definition
CommonDialogs.c:6
SCR_ConfigurableDialogUi
Definition
SCR_ConfigurableDialogUI.c:17
SCR_ConfigurableDialogUi::CreateFromPreset
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
Definition
SCR_ConfigurableDialogUI.c:94
SCR_ConfigurableDialogUi::OnConfirm
void OnConfirm()
Definition
SCR_ConfigurableDialogUI.c:436
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_RewindComponentClass
Definition
SCR_RewindComponent.c:3
SaveGame
Definition
SaveGame.c:13
SaveGameManager
Definition
SaveGameManager.c:13
SaveGameObtainCallback
Definition
SaveGameObtainCallback.c:14
SaveGameOperationCallback
Definition
SaveGameOperationCallback.c:14
ESaveGameRequestFlags
ESaveGameRequestFlags
Definition
ESaveGameRequestFlags.c:13
ESaveGameType
ESaveGameType
Definition
ESaveGameType.c:13
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
scripts
Game
GameMode
SCR_RewindComponent.c
Generated by
1.17.0