Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RestoreEditorModesComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "Restore editor modes when world changes in multiplayer.")]
5
6class SCR_RestoreEditorModesComponent : SCR_BaseGameModeComponent
7{
8 [Attribute(desc: "When enabled, the system will remember and restore also modes of limited editor managers (e.g., those with only PHOTO mode, not EDIT).")]
9 protected bool m_bRestoreLimitedEditors;
10
11 protected static const string GAME_SESSION_STORAGE_MODES = "SCR_RestoreEditorModesComponent_ModesMap";
12 protected static const string DELIMITER_PLAYERS = " ";
13 protected static const string DELIMITER_VALUES = ":";
14
16
17 //------------------------------------------------------------------------------------------------
19 {
20 const int playerID = editorManager.GetPlayerID();
21 const UUID playerUID = SCR_PlayerIdentityUtils.GetPlayerIdentityId(playerID);
22 EEditorMode modes;
23 if (m_mModes.Find(playerUID, modes))
24 {
25 Print(string.Format("SCR_RestoreEditorModesComponent: Restoring editor modes %1 for playerId=%2 ('%3')", SCR_Enum.FlagsToString(EEditorMode, modes), playerID, GetGame().GetPlayerManager().GetPlayerName(playerID)), LogLevel.NORMAL);
26 editorManager.AddEditorModes(EEditorModeAccess.BASE, modes);
27 }
28 }
29
30 //------------------------------------------------------------------------------------------------
31 override void OnGameEnd()
32 {
33 if (!Replication.IsRunning() || !Replication.IsServer())
34 return;
35
37 if (!core)
38 return;
39
40 BackendApi backendApi = GetGame().GetBackendApi();
41
42 string modes;
43 array<SCR_EditorManagerEntity> managers = {};
44 core.GetEditorEntities(managers);
45 foreach (SCR_EditorManagerEntity editorManager: managers)
46 {
47 if (m_bRestoreLimitedEditors || !editorManager.IsLimited())
48 modes += SCR_PlayerIdentityUtils.GetPlayerIdentityId(editorManager.GetPlayerID()) + DELIMITER_VALUES + editorManager.GetEditorModes() + DELIMITER_PLAYERS;
49 }
50
51 GameSessionStorage.s_Data.Insert(GAME_SESSION_STORAGE_MODES, modes);
52
53 core.Event_OnEditorManagerCreatedServer.Remove(OnEditorManagerCreatedServer);
54 }
55
56 //------------------------------------------------------------------------------------------------
57 override void OnPostInit(IEntity owner)
58 {
59 if (!Replication.IsRunning() || !Replication.IsServer())
60 return;
61
62 string modesMap;
63 if (!GameSessionStorage.s_Data.Find(GAME_SESSION_STORAGE_MODES, modesMap))
64 return;
65
67 if (!core)
68 return;
69
70 array<string> players = {};
71 array<string> values = {};
72 modesMap.Split(DELIMITER_PLAYERS, players, true);
73 for (int i = 0, count = players.Count(); i < count; i++)
74 {
75 players[i].Split(DELIMITER_VALUES, values, false);
76 m_mModes.Insert(values[0], values[1].ToInt());
77 }
78
79 GameSessionStorage.s_Data.Remove(GAME_SESSION_STORAGE_MODES);
80
81 core.Event_OnEditorManagerCreatedServer.Insert(OnEditorManagerCreatedServer);
82 }
83}
EEditorModeAccess
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override void OnGameEnd()
Called on all machines when the world ends.
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ref map< string, EEditorMode > m_mModes
void OnEditorManagerCreatedServer(SCR_EditorManagerEntity editorManager)
Backend Api instance.
Definition BackendApi.c:14
GameSessionStorage is used to store data for whole lifetime of game executable run....
Main replication API.
Definition Replication.c:14
Core component to manage SCR_EditorManagerEntity.
int GetEditorEntities(out notnull array< SCR_EditorManagerEntity > outEditorEntities)
Definition UUID.c:28
Definition Types.c:486
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
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6