27 [
Attribute(
desc:
"An ordered array of daytime info. Starting just after midnight and ending at midnight, the daytime must be ordered!")]
30 [
Attribute(
desc:
"An ordered array of winddirection info, starting at north and having set steps between each wind direction. (default 45)")]
33 [
Attribute(
desc:
"An array of monephase naming in order from New moon to Full moon. Check GetMoonPhaseNameForDate before changing this array!")]
36 [
Attribute(
desc:
"Ordered days of the weeks, Monday (Start), Tuesday, Wednesday, ect. to Sunday (Last)")]
46 protected ref ScriptInvokerBase<SCR_TimeAndWeatherManager_OnWindPreview>
m_OnWindPreview;
54 [
RplProp(onRplName:
"OnWindOverrideStateChanged")]
89 if (!rplComp || rplComp.Role() !=
RplRole.Authority)
128 if (!weatherStateTransitionManager)
131 if (!weatherStateTransitionManager.SetStatePreview(preview, stateName))
147 bool SetWindPreview(
bool preview,
float windSpeed = -1,
float windAngleDegrees = -1)
150 if (!weatherStateTransitionManager)
153 if (!weatherStateTransitionManager.SetWindPreview(preview, windSpeed, windAngleDegrees))
171 bool SetDateTimePreview(
bool preview,
int year = -1,
int month = -1,
int day = -1,
float timeOfTheDay = -1)
174 if (!weatherStateTransitionManager)
177 if (!weatherStateTransitionManager.SetDateTimePreview(preview, year, month, day, timeOfTheDay))
202 float sunSetTime, sunRiseTime;
213 return (timeToCheck >= sunSetTime || timeToCheck < sunRiseTime);
253 ForceWeatherTo(setLooping, playerThatChangedWeather: playerChangedLooping);
265 void ForceWeatherTo(
bool setLooping,
string weatherID =
string.Empty,
float transitionDuration = 0,
float stateDuration = 0.001,
int playerThatChangedWeather = 0)
269 Print(
"'ForceWeatherTo' was called in 'TimeAndWeatherManagerEntity' but only server has authority to change weather!",
LogLevel.WARNING);
274 if (!transitionManager)
276 Print(
"'ForceWeatherTo' was called in 'TimeAndWeatherManagerEntity' but TransitionManager was not found!",
LogLevel.WARNING);
280 if (weatherID.IsEmpty())
282 WeatherState currentWeather = transitionManager.GetCurrentState();
283 weatherID = currentWeather.GetStateName();
286 WeatherStateTransitionNode transitionNode = transitionManager.CreateStateTransition(weatherID, transitionDuration, stateDuration);
289 Print(
"'ForceWeatherTo' in 'TimeAndWeatherManagerEntity' could not create a new WeatherStateTransitionNode",
LogLevel.WARNING);
293 transitionNode.SetLooping(setLooping);
296 if (transitionManager.IsPreviewingState())
299 transitionManager.EnqueueStateTransition(transitionNode,
false);
300 transitionManager.RequestStateTransitionImmediately(transitionNode);
310 if (playerThatChangedWeather > 0)
314 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(
ENotification.EDITOR_ATTRIBUTES_WEATHER_AUTO, playerThatChangedWeather);
318 BaseGameMode gameMode =
GetGame().GetGameMode();
321 SCR_NotificationSenderComponent notificationSender = SCR_NotificationSenderComponent.Cast(gameMode.FindComponent(SCR_NotificationSenderComponent));
323 if (notificationSender)
324 notificationSender.OnWeatherChangedNotification(playerThatChangedWeather);
353 int day, month, year;
371 Print(
"Could not get moon phase name as m_aMoonPhasesInfo is empty!",
LogLevel.ERROR);
375 float moonPhaseAmount =
GetMoonPhaseForDate(year, month, day, timeOfTheDay24, timezone, dstOffset);
377 int nextPhaseYearCheck = year;
378 int nextPhaseMonthCheck = month;
379 int nextPhaseDayCheck = day + 1;
382 if (!
CheckValidDate(nextPhaseYearCheck, nextPhaseMonthCheck, nextPhaseDayCheck))
384 if (nextPhaseMonthCheck != 12)
386 nextPhaseMonthCheck += 1;
390 nextPhaseMonthCheck = 1;
391 nextPhaseYearCheck += 1;
394 nextPhaseDayCheck = 1;
398 float nextPhaseAmount =
GetMoonPhaseForDate(nextPhaseYearCheck, nextPhaseMonthCheck, nextPhaseDayCheck, timeOfTheDay24, timezone, dstOffset);
402 if (nextPhaseAmount > moonPhaseAmount)
411 for(
int i = 0; i < count; i++)
503 EDayTimeEnums dayTimePhase;
516 int GetDayTimeUIInfo(
float TimeOfDay, out
SCR_UIInfo uiInfo, out EDayTimeEnums dayTimePhase = -1,
int year = -1,
int month = -1,
int day = -1)
530 for (
int i = 0; i < count -1; i++)
553 int GetDayTimeInfoArray(out notnull array<SCR_DayTimeInfoBase> dayTimeInfoArray,
int year = -1,
int month = -1,
int day = -1)
557 dayTimeInfoArray.Clear();
560 dayTimeInfoArray.Insert(info);
562 return dayTimeInfoArray.Count();
577 orderedWindDirectionInfo.Insert(windInfo);
623 for (
int i = 0; i < count; i++)
630 firstCheck = firstCheck + 360;
639 else if (secondCheck > 360)
641 secondCheck = secondCheck - 360;
651 if (windDirectionFloat >= firstCheck && windDirectionFloat < secondCheck)
676 if (playerChangingWind > -1)
696 if (playerChangingWind > -1)
716 if (playerChangingWind > -1)
773 if (changingPlayerId < 0)
778 int windDirectionIndex;
780 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.EDITOR_ATTRIBUTES_WIND_CHANGED, changingPlayerId, speed * 1000, windDirectionIndex);
784 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.EDITOR_ATTRIBUTES_WIND_DEFAULT, changingPlayerId);
834 m_OnWindPreview =
new ScriptInvokerBase<SCR_TimeAndWeatherManager_OnWindPreview>();
849 m_OnDateTimePreview =
new ScriptInvokerBase<SCR_TimeAndWeatherManager_OnDateTimePreview>();
868 reader.ReadBool(isLooping);
964 static TimeContainer FromHoursMinutesSeconds(
int hours,
int minutes,
int seconds)
980 TimeAndWeatherManagerEntity.TimeToHoursMinutesSeconds(hours24, h, m, s);
1000 [
Attribute(
"0",
UIWidgets.ComboBox,
"Day Time Enum",
"", ParamEnumArray.FromEnum(EDayTimeEnums))]
1046 SetDayTime(daytimeInfo, timeAndWeatherEntity);
1060 Print(
string.Format(
"%1 Uses the SCR_DayTimeInfoBase use one of the inherited classes instead!",
typename.EnumToString(EDayTimeEnums,
m_DayTimeEnum)),
LogLevel.WARNING);
1067 [
Attribute(
desc:
"Hour which this daytime starts, is a value of 0 to 24.0")]
1068 protected int m_iHour;
1084 override void SetDayTime(notnull array<ref SCR_DayTimeInfoBase> daytimeInfo,
TimeAndWeatherManagerEntity timeAndWeatherEntity,
int year = -1,
int month = -1,
int day = -1)
1091 timeAndWeatherEntity.GetDate(year, month, day);
1094 bool hasSunSetandRise;
1099 case EDayTimeEnums.DAYTIME_DAWN:
1101 hasSunSetandRise = timeAndWeatherEntity.GetSunriseHourForDate(year, month, day, timeAndWeatherEntity.GetCurrentLatitude(), timeAndWeatherEntity.GetCurrentLongitude(), timeAndWeatherEntity.GetTimeZoneOffset(), timeAndWeatherEntity.GetDSTOffset(),
m_fTimeOfDay);
1104 if (!hasSunSetandRise)
1110 case EDayTimeEnums.DAYTIME_DUSK:
1112 hasSunSetandRise = timeAndWeatherEntity.GetSunsetHourForDate(year, month, day, timeAndWeatherEntity.GetCurrentLatitude(), timeAndWeatherEntity.GetCurrentLongitude(), timeAndWeatherEntity.GetTimeZoneOffset(), timeAndWeatherEntity.GetDSTOffset(),
m_fTimeOfDay);
1115 if (!hasSunSetandRise)
1122 Print(
string.Format(
"%1 is not supported with autoTime!",
typename.EnumToString(EDayTimeEnums,
m_DayTimeEnum)),
LogLevel.WARNING);
1129 [
Attribute(
"0",
UIWidgets.ComboBox,
"Day Time X",
"", ParamEnumArray.FromEnum(EDayTimeEnums))]
1130 protected EDayTimeEnums m_DaytimeAfter;
1132 [
Attribute(
"0",
UIWidgets.ComboBox,
"Day Time Y",
"", ParamEnumArray.FromEnum(EDayTimeEnums))]
1133 protected EDayTimeEnums m_DaytimeBefore;
1140 Print(
string.Format(
"SCR_DayTimeInfoBetween %1 has a reference to itself!",
typename.EnumToString(EDayTimeEnums,
m_DayTimeEnum)),
LogLevel.WARNING);
1147 float dayTimeAfterSeconds, DayTimeBeforeSeconds;
1148 bool dayTimeAfterSet =
false;
1149 bool dayTimeBeforeSet =
false;
1151 foreach (SCR_DayTimeInfoBase daytime: daytimeInfo)
1153 if (daytime.GetDaytimeEnum() == m_DaytimeAfter)
1155 dayTimeAfterSeconds = daytime.GetDayTime(daytimeInfo, timeAndWeatherEntity);
1156 dayTimeAfterSet =
true;
1158 if (dayTimeAfterSeconds == 24)
1159 dayTimeAfterSeconds = 0;
1161 if (dayTimeAfterSet && dayTimeBeforeSet)
1164 else if (daytime.GetDaytimeEnum() == m_DaytimeBefore)
1166 DayTimeBeforeSeconds = daytime.GetDayTime(daytimeInfo, timeAndWeatherEntity);
1167 dayTimeBeforeSet =
true;
1169 if (DayTimeBeforeSeconds == 0)
1170 DayTimeBeforeSeconds = 24;
1172 if (dayTimeAfterSet && dayTimeBeforeSet)
1177 if (dayTimeAfterSeconds < 0 || !dayTimeAfterSet)
1179 Print(
string.Format(
"Could not set %1 as %2 daytime after was not correctly found! This might be because %2 is also depened on %1 or that it doesn't exist in the array!",
typename.EnumToString(EDayTimeEnums,
m_DayTimeEnum),
typename.EnumToString(EDayTimeEnums, m_DaytimeAfter)),
LogLevel.WARNING);
1184 if (DayTimeBeforeSeconds < 0 || !dayTimeBeforeSet)
1186 Print(
string.Format(
"Could not set %1 as %2 daytime before was not correctly found! This might be because %2 is also depened on %1 or that it doesn't exist in the array!",
typename.EnumToString(EDayTimeEnums,
m_DayTimeEnum),
typename.EnumToString(EDayTimeEnums, m_DaytimeBefore)),
LogLevel.WARNING);
1191 m_fTimeOfDay = (dayTimeAfterSeconds + DayTimeBeforeSeconds) / 2;
1220class SCR_MoonPhaseInfo
1225 [
Attribute(
desc:
"IsMoonPhase will return true if moonPhaseAmount is equal or greater then m_fPhaseEqualOrGreater and less then m_fPhaseLessThen")]
1226 protected float m_fPhaseEqualOrGreater;
1228 [
Attribute(
desc:
"IsMoonPhase will return true if moonPhaseAmount is equal or greater then m_fPhaseEqualOrGreater and less then m_fPhaseLessThen")]
1229 protected float m_fPhaseLessThen;
1248 bool IsMoonPhase(
float moonPhaseAmount,
EMoonPhaseEnums beforeOrAfterFullMoon)
1252 if (m_iBeforeOrAfterFullMoon != beforeOrAfterFullMoon)
1256 return moonPhaseAmount >= m_fPhaseEqualOrGreater && moonPhaseAmount < m_fPhaseLessThen;
ArmaReforgerScripted GetGame()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_WristwatchComponentClass m_iSeconds
func SCR_TimeAndWeatherManager_OnWeatherStatePreview
enum EMoonPhaseEnums DAYTIME_DAWN
enum EMoonPhaseEnums DAYTIME_AFTERNOON
ScriptInvokerBase< ScriptInvokerOnWeatherChangedMethod > ScriptInvokerOnWeatherChanged
SCR_UIInfo GetDayTimeUIInfo()
ScriptInvokerBase< ScriptInvokerOnWindOverrideDataChangedMethod > ScriptInvokerOnWindOverrideDataChanged
EDayTimeEnums m_DayTimeEnum
enum EMoonPhaseEnums DAYTIME_EVENING
func ScriptInvokerOnWindOverrideDataChangedMethod
func ScriptInvokerOnWeatherChangedMethod
int GetWindDirectionValue()
class SCR_WindDirectionInfo SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
class SCR_DayTimeInfoBase BaseContainerProps()
void TimeContainer(int hours=0, int minutes=0, int seconds=0)
class SCR_DayTimeInfoBase SCR_BaseContainerCustomTitleEnum(EDayTimeEnums, "m_dayTimeEnum")
enum EMoonPhaseEnums DAYTIME_DUSK
func SCR_TimeAndWeatherManager_OnWindPreview
enum EMoonPhaseEnums DAYTIME_MORNING
func SCR_TimeAndWeatherManager_OnDateTimePreview
EDayTimeEnums m_DayTimeEnum
void SetDayTime(notnull array< ref SCR_DayTimeInfoBase > daytimeInfo, TimeAndWeatherManagerEntity timeAndWeatherEntity, int year=-1, int month=-1, int day=-1)
SCR_UIInfo GetDayTimeUIInfo()
float GetDayTime(notnull array< ref SCR_DayTimeInfoBase > daytimeInfo, TimeAndWeatherManagerEntity timeAndWeatherEntity)
void Clear()
Clear the data.
EDayTimeEnums GetDaytimeEnum()
static RplComponent GetEntityRplComponent(notnull IEntity entity)
void SetMoonphaseImageRotation(bool northernHemisphere)
int GetWindDirectionValue()
void ForceWeatherTo(bool setLooping, string weatherID=string.Empty, float transitionDuration=0, float stateDuration=0.001, int playerThatChangedWeather=0)
bool SetTime(TimeContainer cont)
void UpdateWeatherLooping(bool isLooping)
SCR_MoonPhaseUIInfo GetCurrentMoonPhaseInfoForDate()
float m_fDelayedWindDirectionOverride
float m_fDelayedWindSpeedOverride
bool SetWindPreview(bool preview, float windSpeed=-1, float windAngleDegrees=-1)
string GetWeekDayStringForDate(int year, int month, int day)
bool SetWeatherStatePreview(bool preview, string stateName="")
int m_iDelayedPlayerChangingWind
bool GetWindDirectionInfoFromIndex(int index, out SCR_WindDirectionInfo windDirectionInfo)
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWindPreview > GetOnWindPreview()
ScriptInvokerOnWeatherChanged GetOnWeatherChanged()
int GetCurrentDayTimeUIInfo(out SCR_UIInfo uiInfo)
void OnWeatherChanged_S(bool transitioning=true)
void CreateDayTimeInfoArray(int year=-1, int month=-1, int day=-1)
ref array< ref SCR_WindDirectionInfo > m_OrderedWindDirectionInfo
ref ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWindPreview > m_OnWindPreview
bool IsAutomatedWindDisabled()
Proxies should use this instead of IsWindDirectionOverridden and IsWindSpeedOverridden as for them wi...
int GetOrderedWindDirectionInfoArray(notnull array< SCR_WindDirectionInfo > orderedWindDirectionInfo)
ref ScriptInvokerOnWeatherChanged m_OnWeatherChanged
void RpcDo_OnWindDataUpdated(bool currentState, int changingPlayerId)
void ClearDelayedWindOverrideVars()
Reset all changed wind variables.
ref array< ref SCR_MoonPhaseInfo > m_aMoonPhasesInfo
bool SetDateTimePreview(bool preview, int year=-1, int month=-1, int day=-1, float timeOfTheDay=-1)
int GetDayTimeUIInfo(float TimeOfDay, out SCR_UIInfo uiInfo, out EDayTimeEnums dayTimePhase=-1, int year=-1, int month=-1, int day=-1)
void DelayedApplyWindOverride()
ref array< ref SCR_DayTimeInfoBase > m_aOrderedDaytimeInfo
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWeatherStatePreview > GetOnWeatherStatePreview()
ScriptInvokerOnWindOverrideDataChanged GetOnWindOverrideDataChanged()
string GetWeekDayString()
ref ScriptInvokerBase< SCR_TimeAndWeatherManager_OnWeatherStatePreview > m_OnWeatherStatePreview
void RpcDo_OnWeatherChanged(int currentStateId, int nextStateId, bool transitioning)
ref ScriptInvokerBase< SCR_TimeAndWeatherManager_OnDateTimePreview > m_OnDateTimePreview
override bool RplSave(ScriptBitWriter writer)
ref ScriptInvokerOnWindOverrideDataChanged m_OnWindOverrideDataChanged
bool m_bListiningToWindOverrideDelay
void StartListeningToWindApplyDelay()
void DelayedSetWindOverride(bool overrideWind, int playerChangingWind=-1)
ScriptInvokerBase< SCR_TimeAndWeatherManager_OnDateTimePreview > GetOnDateTimePreview()
bool m_bDelayedWindOverride
SCR_MoonPhaseUIInfo GetMoonPhaseInfoForDate(int year, int month, int day, float timeOfTheDay24, float timezone, float dstOffset, float Latitude)
bool GetWindDirectionInfoFromFloat(float windDirectionFloat, out int index, out SCR_WindDirectionInfo windDirectionInfo)
override bool RplLoad(ScriptBitReader reader)
int GetDayTimeInfoArray(out notnull array< SCR_DayTimeInfoBase > dayTimeInfoArray, int year=-1, int month=-1, int day=-1)
void DelayedOverrideWindSpeed(float windSpeed, int playerChangingWind=-1)
EDayTimeEnums GetCurrentDayTimeUIInfoAndPhase(out SCR_UIInfo uiInfo)
bool IsSunSet(float timeToCheck)
void DelayedOverrideWindDirection(float windDirection, int playerChangingWind=-1)
void SetCurrentWeatherLooping(bool setLooping, int playerChangedLooping=0)
void OnWindOverrideStateChanged()
ref array< LocalizedString > m_aOrderedDaysOfWeek
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
proto external bool CheckValidDate(int year, int month, int day)
proto external int GetWeekDayForDate(int year, int month, int day)
proto external bool SetWindDirectionOverride(bool doOverride, float windDirection=0)
proto float GetMoonPhaseForDate(int year, int month, int day, float timeOfTheDay24, float timezone, float dstOffset)
BaseWeatherManagerEntityClass GenericEntityClass GetCurrentWeatherState()
proto external float GetDSTOffset()
proto external bool SetHoursMinutesSeconds(int hours, int minutes, int seconds, bool immediateChange=false)
proto BaseWeatherStateTransitionManager GetTransitionManager()
proto external float GetTimeZoneOffset()
proto external float GetWindDirection()
proto external int GetWeekDay()
proto external float GetTimeOfTheDay()
proto void GetDate(out int year, out int month, out int day)
proto bool GetSunriseHour(out float hour24)
proto void GetHoursMinutesSeconds(out int hours, out int minutes, out int seconds)
proto external bool SetWindSpeedOverride(bool doOverride, float windSpeed=0)
proto external float GetCurrentLatitude()
proto external bool IsWindDirectionOverridden()
proto bool GetSunsetHour(out float hour24)
proto external float GetWindSpeed()
proto external bool IsWindSpeedOverridden()
@ IGNORE
Ignore any parent and always create root record.
RplRole
Role of replicated node (and all items in it) within the replication system.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.