8 [
Attribute(
"0",
desc:
"Set true if you want the GM to be able to set global nightmode. Do not change in runtime",
category:
"Settings")]
9 protected bool m_bAllowGlobalNightMode;
11 [
Attribute(
"0.1",
desc:
"0 means the sun is setting, 1 means the max value the sun is under (though in reality max value is around 0.5 and the sun is fully set around 0.1) this value dictates when the max nightmode EV value is reached if the sun is at the current state",
params:
"0.001 1",
category:
"Settings")]
12 protected float m_fSunStateMaxNightMode;
15 protected int m_iEVValueNormalMode;
18 protected int m_iEVValueNightMode;
20 [
Attribute(
"SOUND_E_TOGGLE_FLASHLIGHT",
desc:
"SFX when local editor nightMode is enabled/disabled",
category:
"Sound")]
21 protected string m_sLocalEditorNightModeToggledSound;
23 [
Attribute(
"ManualCameraLight",
desc:
"Local nightmode shortcut. Toggle On and off")]
24 protected string m_sToggleLocalNightModeShortcut;
27 protected bool m_bLocalEditorNightModeEnabled;
28 protected bool m_bLocalEditorNightModeOnEditorClose;
29 protected bool m_bUnlimitedEditorIsOpen;
30 protected bool m_bGlobalNightModeEnabled;
31 protected bool m_IsPreviewingTimeOrWeather;
32 protected float m_fNightModeAlpha = 0;
35 protected bool m_bUpdateEachFrame;
36 protected float m_fCurrentUpdateTickInSeconds;
37 protected static const float UPDATE_TICK_IN_SECONDS = 1;
55 if (!m_bUpdateEachFrame)
57 m_fCurrentUpdateTickInSeconds += timeSlice;
59 if (m_fCurrentUpdateTickInSeconds < UPDATE_TICK_IN_SECONDS)
62 m_fCurrentUpdateTickInSeconds = 0;
66 vector Sundirection, moondirection;
68 m_TimeAndWeatherManager.GetCurrentSunMoonDirAndPhase(Sundirection, moondirection, moonphase);
71 float normalizedSun = Math.Clamp(Sundirection[1] / m_fSunStateMaxNightMode, 0, 1);
74 m_bUpdateEachFrame = (normalizedSun != 0);
77 if (normalizedSun != m_fNightModeAlpha)
79 m_fNightModeAlpha = normalizedSun;
80 m_World.AdjustCameraEV(0, Math.Lerp(m_iEVValueNormalMode, m_iEVValueNightMode, m_fNightModeAlpha));
88 return m_bLocalEditorNightModeEnabled;
104 if (m_bLocalEditorNightModeEnabled == enable)
111 m_bLocalEditorNightModeEnabled = enable;
119 if (m_OnLocalEditorNightModeEnabledChanged)
120 m_OnLocalEditorNightModeEnabledChanged.Invoke(enable);
127 return m_bAllowGlobalNightMode;
134 return m_bGlobalNightModeEnabled;
164 m_bGlobalNightModeEnabled = enable;
170 if (m_OnGlobalNightModeEnabledChanged)
171 m_OnGlobalNightModeEnabledChanged.Invoke(enable);
174 if (nightModeChangerPlayerID > 0)
177 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_GLOBAL_NIGHTMODE_ENABLED, nightModeChangerPlayerID);
179 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_GLOBAL_NIGHTMODE_DISABLED, nightModeChangerPlayerID);
194 return m_TimeAndWeatherManager != null;
217 if (m_fNightModeAlpha != 0)
219 m_fNightModeAlpha = 0;
220 m_World.AdjustCameraEV(0, m_iEVValueNormalMode);
231 m_bUpdateEachFrame =
true;
232 m_fCurrentUpdateTickInSeconds = 0;
236 if (m_OnNightModeEnabledChanged)
237 m_OnNightModeEnabledChanged.Invoke(enable);
248 if (m_bUnlimitedEditorIsOpen)
255 m_bUnlimitedEditorIsOpen =
false;
277 bool newIsPreviewing = m_WeatherStateTransitionManager.IsPreviewingWind() || m_WeatherStateTransitionManager.IsPreviewingState() || m_WeatherStateTransitionManager.IsPreviewingDateTime();
278 if (m_IsPreviewingTimeOrWeather == newIsPreviewing)
281 m_IsPreviewingTimeOrWeather = newIsPreviewing;
287 if (m_IsPreviewingTimeOrWeather)
294 if (m_fNightModeAlpha != 0)
296 m_fNightModeAlpha = 0;
297 m_World.AdjustCameraEV(0, m_iEVValueNormalMode);
299 SCR_NotificationsComponent.SendLocal(
ENotification.EDITOR_PREVIEWING_IN_NIGHTMODE);
325 protected void OnWindPreview(
bool preview,
float windSpeed = -1,
float windAngleDegrees = -1)
331 protected void OnDateTimePreview(
bool preview,
int year = -1,
int month = -1,
int day = -1,
float timeOfTheDay = -1)
340 if (!m_OnLocalEditorNightModeEnabledChanged)
343 return m_OnLocalEditorNightModeEnabledChanged;
350 if (!m_OnGlobalNightModeEnabledChanged)
353 return m_OnGlobalNightModeEnabledChanged;
360 if (!m_OnNightModeEnabledChanged)
363 return m_OnNightModeEnabledChanged;
400 m_World =
GetGame().GetWorld();
402 Print(
"'SCR_NightModeGameModeComponent' could not find World this means nightmode can never be enabled!",
LogLevel.ERROR);
412 m_TimeAndWeatherManager = world.GetTimeAndWeatherManager();
413 if (!m_TimeAndWeatherManager)
415 Print(
"'SCR_NightModeGameModeComponent' could not find TimeAndWeatherEntity this means nightmode can never be enabled!",
LogLevel.ERROR);
420 m_WeatherStateTransitionManager = m_TimeAndWeatherManager.GetTransitionManager();
421 if (m_WeatherStateTransitionManager)
456 super.OnDelete(owner);
465 if (m_TimeAndWeatherManager && m_WeatherStateTransitionManager)
479 writer.WriteBool(m_bGlobalNightModeEnabled);
487 bool globalNightModeEnabled;
491 reader.ReadBool(globalNightModeEnabled);
ArmaReforgerScripted GetGame()
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override bool RplSave(ScriptBitWriter writer)
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
bool IsGlobalNightModeAllowed()
void OnWeatherStatePreview(bool preview, string stateName)
bool IsNightModeEnabled()
bool IsLocalEditorNightModeEnabled()
bool CanEnableNightMode()
ScriptInvokerBool GetOnNightModeEnabledChanged()
void OnEditorLimitedChanged(bool isLimited)
void OnEditorManagerCreated(SCR_EditorManagerEntity editorManager)
ScriptInvokerBool GetOnGlobalNightModeEnabledChanged()
void UpdatePreviewingTimeOrWeather()
ScriptInvokerBool GetOnLocalEditorNightModeEnabledChanged()
void ToggleLocalNightModeShortcut()
void EnableLocalEditorNightMode(bool enable, bool playSound=true)
void EnableNightMode(bool enable)
void OnDateTimePreview(bool preview, int year=-1, int month=-1, int day=-1, float timeOfTheDay=-1)
bool IsGlobalNightModeEnabled()
void OnWindPreview(bool preview, float windSpeed=-1, float windAngleDegrees=-1)
void RPC_EnableGlobalNightMode(bool enable, int nightModeChangerPlayerID)
void EnableGlobalNightMode(bool enable, int nightModeChangerPlayerID=-1)
override void EOnFrame(IEntity owner, float timeSlice)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
SCR_EditorManagerEntity m_EditorManager
proto external BaseWorld GetWorld()
Core component to manage SCR_EditorManagerEntity.
static bool IsEmptyOrWhiteSpace(string input)
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWindPreview > GetOnWindPreview()
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWeatherStatePreview > GetOnWeatherStatePreview()
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnDateTimePreview > GetOnDateTimePreview()
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.