Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ToggleLocalEditorNightModeToolbarAction.c
Go to the documentation of this file.
3 {
4  protected SCR_NightModeGameModeComponent m_NightModeComponent;
5 
6  //------------------------------------------------------------------------------------------------
7  protected void OnLocalEditorNightModeEnabledChanged(bool state)
8  {
9  Toggle(state, state)
10  }
11 
12  //------------------------------------------------------------------------------------------------
13  override bool IsServer()
14  {
15  return false;
16  }
17 
18  //------------------------------------------------------------------------------------------------
19  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
20  {
21  if (!m_NightModeComponent)
22  {
23  BaseGameMode gameMode = GetGame().GetGameMode();
24  if (!gameMode)
25  return false;
26 
27  m_NightModeComponent = SCR_NightModeGameModeComponent.Cast(gameMode.FindComponent(SCR_NightModeGameModeComponent));
28  }
29 
30  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
31  if (!editorManager || editorManager.IsLimited())
32  return false;
33 
34  return m_NightModeComponent && m_NightModeComponent.CanEnableNightMode() && !m_NightModeComponent.IsGlobalNightModeEnabled();
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
39  {
40  return true;
41  }
42 
43  //------------------------------------------------------------------------------------------------
44  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,int flags, int param = -1)
45  {
46  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
47  if (!editorManager || editorManager.IsLimited())
48  return;
49 
50  //~ Toggle Local Editor Nightmode
51  m_NightModeComponent.EnableLocalEditorNightMode(!m_NightModeComponent.IsLocalEditorNightModeEnabled(), false);
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  override void Track()
56  {
57  if (!m_NightModeComponent)
58  {
59  BaseGameMode gameMode = GetGame().GetGameMode();
60  if (!gameMode)
61  return;
62 
63  m_NightModeComponent = SCR_NightModeGameModeComponent.Cast(gameMode.FindComponent(SCR_NightModeGameModeComponent));
64 
65  if (!m_NightModeComponent)
66  return;
67  }
68 
69  m_NightModeComponent.GetOnLocalEditorNightModeEnabledChanged().Insert(OnLocalEditorNightModeEnabledChanged);
70  OnLocalEditorNightModeEnabledChanged(m_NightModeComponent.IsLocalEditorNightModeEnabled());
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  override void Untrack()
75  {
76  if (!m_NightModeComponent)
77  return;
78 
79  m_NightModeComponent.GetOnLocalEditorNightModeEnabledChanged().Remove(OnLocalEditorNightModeEnabledChanged);
80  }
81 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ToggleLocalEditorNightModeToolbarAction
Definition: SCR_ToggleLocalEditorNightModeToolbarAction.c:2
Toggle
void Toggle()
Toggle hint. Hide it if it's shown, and open it again if it's hidden.
Definition: SCR_HintManagerComponent.c:216
SCR_BaseToggleToolbarAction
Definition: SCR_BaseToggleToolbarAction.c:3
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26