Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DateAttributeDynamicDescription.c
Go to the documentation of this file.
1 
4 [BaseContainerProps(), BaseContainerCustomStringTitleField("Date description (CUSTOM)")]
6 {
7  [Attribute("#AR-Editor_Attribute_Date_Description_NoSunSetOrRise", desc: "Text shown in description when there is no sunset nor sunrise")]
8  protected string m_sNoSunriseSunSet;
9 
10  protected TimeAndWeatherManagerEntity m_TimeAndWeatherManager;
11  protected SCR_AttributesManagerEditorComponent m_AttributeManager;
12 
13  //------------------------------------------------------------------------------------------------
14  override void InitDynamicDescription(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
15  {
16  super.InitDynamicDescription(attribute);
17 
18  if (!m_TimeAndWeatherManager)
19  {
20  ChimeraWorld world = GetGame().GetWorld();
21  m_TimeAndWeatherManager = world.GetTimeAndWeatherManager();
22  }
23 
24  if (!m_AttributeManager)
25  m_AttributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
26 
27  if (!attribute.IsInherited(SCR_DateEditorAttribute))
28  Print("'SCR_DateAttributeDynamicDescription' is not attached to the 'SCR_DateEditorAttribute'!", LogLevel.ERROR);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  override bool IsValid(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
33  {
34  if (!super.IsValid(attribute, attributeUi) || !attribute.IsInherited(SCR_DateEditorAttribute))
35  return false;
36 
37  return m_TimeAndWeatherManager != null;
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  override void GetDescriptionData(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi, out SCR_EditorAttributeUIInfo uiInfo, out string param1 = string.Empty, out string param2 = string.Empty, out string param3 = string.Empty)
42  {
43  SCR_BaseEditorAttributeVar var = attribute.GetVariableOrCopy();
44  if (!var)
45  return;
46 
47  SCR_DateEditorAttribute dateAttribute = SCR_DateEditorAttribute.Cast(attribute);
48  if (!dateAttribute)
49  return;
50 
51  float daytime = 0;
52 
53  //~ If has daytime var
54  SCR_BaseEditorAttributeVar dayTimeVar;
55  if (m_AttributeManager && m_AttributeManager.GetAttributeVariable(SCR_DaytimeEditorAttribute, dayTimeVar))
56  daytime = dayTimeVar.GetFloat() / 3600;
57 
58  array<int> yearArray = {};
59  dateAttribute.GetYearArray(yearArray);
60 
61  vector date = var.GetVector();
62 
63  int day = date[0] +1;
64  int month = date[1] +1;
65  int year = yearArray[date[2]];
66 
67  float timeZoneOffset = m_TimeAndWeatherManager.GetTimeZoneOffset();
68  float dstOffset = m_TimeAndWeatherManager.GetDSTOffset();
69  float latitude = m_TimeAndWeatherManager.GetCurrentLatitude();
70 
71  SCR_MoonPhaseUIInfo moonPhaseInfo = m_TimeAndWeatherManager.GetMoonPhaseInfoForDate(year, month, day, daytime, timeZoneOffset, dstOffset, latitude);
72 
73  float sunRiseTime, sunSetTime;
74  bool hasSunRise = m_TimeAndWeatherManager.GetSunriseHourForDate(year, month, day, m_TimeAndWeatherManager.GetCurrentLatitude(), m_TimeAndWeatherManager.GetCurrentLongitude(), m_TimeAndWeatherManager.GetTimeZoneOffset(), m_TimeAndWeatherManager.GetDSTOffset(), sunRiseTime);
75  bool hasSunSet = m_TimeAndWeatherManager.GetSunsetHourForDate(year, month, day, m_TimeAndWeatherManager.GetCurrentLatitude(), m_TimeAndWeatherManager.GetCurrentLongitude(), m_TimeAndWeatherManager.GetTimeZoneOffset(), m_TimeAndWeatherManager.GetDSTOffset(), sunSetTime);
76 
77  string sunRiseName, sunSetName;
78 
79  if (!hasSunRise)
80  sunRiseName = m_sNoSunriseSunSet;
81  else
82  sunRiseName = SCR_FormatHelper.GetTimeFormattingHideSeconds(sunRiseTime * 3600, ETimeFormatParam.DAYS);
83  if (!hasSunRise)
84  sunSetName = m_sNoSunriseSunSet;
85  else
86  sunSetName = SCR_FormatHelper.GetTimeFormattingHideSeconds(sunSetTime * 3600, ETimeFormatParam.DAYS);
87 
88  uiInfo = m_DescriptionDisplayInfo;
89  param1 = sunRiseName;
90  param2 = sunSetName;
91  param3 = moonPhaseInfo.GetName();
92  }
93 };
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_BaseAttributeDynamicDescription
Definition: SCR_BaseAttributeDynamicDescription.c:5
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_DaytimeEditorAttribute
Definition: SCR_DaytimeEditorAttribute.c:5
BaseContainerCustomStringTitleField
class SCR_HitZoneGroupNameHolder BaseContainerCustomStringTitleField("USE INHERENT VERSION ONLY!")
Definition: SCR_HitZoneGroupNameHolder.c:27
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditorAttributeUIInfo
UIInfo used by editor attribute system.
Definition: SCR_EditorAttributeUIInfo.c:3
SCR_DateEditorAttribute
Definition: SCR_DateEditorAttribute.c:2
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
ETimeFormatParam
ETimeFormatParam
Definition: ETimeFormatParam.c:4
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_BaseEditorAttributeUIComponent
Definition: SCR_BaseEditorAttributeUIComponent.c:3
SCR_MoonPhaseUIInfo
Definition: SCR_MoonPhaseUIInfo.c:2
SCR_DateAttributeDynamicDescription
Definition: SCR_DateAttributeDynamicDescription.c:5
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