Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PauseGameTimeEditorComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "Game simulation manager. Works only with SCR_EditorManagerEntity!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
5
8class SCR_PauseGameTimeEditorComponent : SCR_BaseEditorComponent
9{
10 [Attribute("0", desc: "When enabled, the editor will be paused when opened.")]
11 protected bool m_bPauseOnOpen;
12
13 //------------------------------------------------------------------------------------------------
18 {
19 const ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
20 SetPause(!world.IsGameTimePaused());
21 }
22
23 //------------------------------------------------------------------------------------------------
28 void SetPause(bool pause)
29 {
30 // Unpausing game, create a rewind point
31 if (!pause)
32 {
33 SCR_RewindComponent rewindManager = SCR_RewindComponent.GetInstance();
34 if (rewindManager && rewindManager.CanRewind() && !rewindManager.HasRewindPoint())
35 rewindManager.CreateRewindPoint();
36 }
37
38 DoPause(pause);
39 }
40
41 //------------------------------------------------------------------------------------------------
42 protected void DoPause(bool pause)
43 {
45 if (gameMode)
46 gameMode.PauseGame(pause, SCR_EPauseReason.EDITOR | SCR_EPauseReason.MUSIC);
47 }
48
49 //------------------------------------------------------------------------------------------------
54 void SetPauseOnOpen(bool pause)
55 {
56 m_bPauseOnOpen = pause;
57 }
58
59 //------------------------------------------------------------------------------------------------
64 {
65 return m_bPauseOnOpen;
66 }
67
68 //------------------------------------------------------------------------------------------------
69 override protected void EOnEditorOpen()
70 {
71 EventProvider.ConnectEvent(GetGame().GetSaveGameManager().OnSaveCreated, OnSaved);
72
73 // Pause game time when the editor is opened (only after a delay, to give player camera chance to iniliazed after rewinding)
74 bool pause = m_bPauseOnOpen;
75
76 // Pause once on first init of if we are loading a save (account for call queue delay with 5 seconds of grace period)
77 if (!pause && SCR_PersistenceSystem.IsLoadInProgress(5000))
78 {
79 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
80 if (editorManagerEntity)
81 {
82 const EEditorMode mode = editorManagerEntity.GetCurrentMode();
83 if (SCR_Enum.HasFlag(mode, EEditorMode.EDIT))
84 pause = true;
85 }
86 }
87
88 if (pause)
89 GetGame().GetCallqueue().Call(SetPause, true);
90 }
91
92 //------------------------------------------------------------------------------------------------
93 override protected void EOnEditorClose()
94 {
95 EventProvider.DisconnectEvent(GetGame().GetSaveGameManager().OnSaveCreated, OnSaved);
96
97 // Always unpause for when returning back to gameplay.
98 const ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
99 if (world.IsGameTimePaused())
100 SetPause(false);
101 }
102
103 //------------------------------------------------------------------------------------------------
104 override protected void EOnEditorInit()
105 {
106 // Don't pause on open when disabled by CLI param in the dev version
107 if (m_bPauseOnOpen && GetGame().IsDev() && System.IsCLIParam("editorDoNotPauseOnOpen"))
108 m_bPauseOnOpen = false;
109 }
110
111 //------------------------------------------------------------------------------------------------
112 [ReceiverAttribute()]
113 protected void OnSaved(SaveGame save)
114 {
115 if (save.GetType() == ESaveGameType.MANUAL)
116 DoPause(true);
117 }
118}
SCR_EPauseReason
Definition EPauseReason.c:2
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
void OnSaved(SaveGame save)
void SetPauseOnOpen(bool pause)
void DoPause(bool pause)
void SetPause(bool pause)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Class for broadcasting events to registered receivers.
static proto bool ConnectEvent(func eventSender, func eventReceiver)
static proto bool DisconnectEvent(func eventSender, func eventReceiver)
void EOnEditorOpen()
When the editor is opened.
void EOnEditorInit()
When the entity is created.
void EOnEditorClose()
When the editor is closed.
bool PauseGame(bool pause, SCR_EPauseReason reason=SCR_EPauseReason.SYSTEM)
static sealed bool IsLoadInProgress(float msSinceLoad=1000.0)
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
ESaveGameType