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_RestoreEditorModesComponent.c
Go to the documentation of this file.
1
[
ComponentEditorProps
(
category
:
"GameScripted/GameMode/Components"
, description:
"Restore editor modes when world changes in multiplayer."
)]
2
class
SCR_RestoreEditorModesComponentClass
:
SCR_BaseGameModeComponentClass
3
{
4
}
5
6
class
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
15
protected
ref
map<string, EEditorMode>
m_mModes
=
new
map<string, EEditorMode>
();
16
17
//------------------------------------------------------------------------------------------------
18
protected
void
OnEditorManagerCreatedServer
(
SCR_EditorManagerEntity
editorManager)
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
36
SCR_EditorManagerCore
core =
SCR_EditorManagerCore
.Cast(
SCR_EditorManagerCore
.GetInstance(
SCR_EditorManagerCore
));
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
66
SCR_EditorManagerCore
core =
SCR_EditorManagerCore
.Cast(
SCR_EditorManagerCore
.GetInstance(
SCR_EditorManagerCore
));
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
EEditorModeAccess
Definition
EEditorModeAccess.c:2
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
OnGameEnd
override void OnGameEnd()
Called on all machines when the world ends.
Definition
SCR_AnalyticsDataCollectionComponent.c:65
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_BaseGameModeComponent.c:171
SCR_EditorManagerEntity
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Definition
SCR_EditorManagerEntity.c:2211
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
m_mModes
ref map< string, EEditorMode > m_mModes
Definition
SCR_RestoreEditorModesComponent.c:15
OnEditorManagerCreatedServer
void OnEditorManagerCreatedServer(SCR_EditorManagerEntity editorManager)
Definition
SCR_RestoreEditorModesComponent.c:18
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BackendApi
Backend Api instance.
Definition
BackendApi.c:14
GameSessionStorage
GameSessionStorage is used to store data for whole lifetime of game executable run....
Definition
GameSessionStorage.c:14
IEntity
Definition
IEntity.c:13
Replication
Main replication API.
Definition
Replication.c:14
SCR_BaseGameModeComponentClass
Definition
SCR_BaseGameModeComponent.c:3
SCR_EditorManagerCore
Core component to manage SCR_EditorManagerEntity.
Definition
SCR_EditorManagerCore.c:6
SCR_EditorManagerCore::GetEditorEntities
int GetEditorEntities(out notnull array< SCR_EditorManagerEntity > outEditorEntities)
Definition
SCR_EditorManagerCore.c:197
SCR_Enum
Definition
SCR_Enum.c:2
SCR_PlayerIdentityUtils
Definition
SCR_PlayerIdentityUtils.c:2
SCR_RestoreEditorModesComponentClass
Definition
SCR_RestoreEditorModesComponent.c:3
UUID
Definition
UUID.c:28
map
Definition
Types.c:486
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition
EEditorMode.c:6
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
scripts
Game
GameMode
Components
SCR_RestoreEditorModesComponent.c
Generated by
1.17.0