Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TimePresetsEditorAttribute.c
Go to the documentation of this file.
1 
6 {
7  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
8  {
9  //If opened in global attributes
10  if (!IsGameMode(item))
11  return null;
12 
13  BaseGameMode gameMode = GetGame().GetGameMode();
14  if (!gameMode)
15  return null;
16 
17  ChimeraWorld world = ChimeraWorld.CastFrom(gameMode.GetWorld());
18  if (!world)
19  return null;
20 
21  TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
22  if (!timeManager)
23  return null;
24 
25 
26  SCR_UIInfo uiInfo;
27  return SCR_BaseEditorAttributeVar.CreateInt(timeManager.GetCurrentDayTimeUIInfo(uiInfo));
28  }
29 
30  override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
31  {
32  if (!var)
33  return;
34 
35  if (isInit)
36  {
37  manager.SetAttributeAsSubAttribute(SCR_DaytimeEditorAttribute);
38  return;
39  }
40 
41  int index = var.GetInt();
42 
43  if (index < 0 || index >= m_aValues.Count())
44  return;
45 
46  //Recreate presets in case date changed
47  CreatePresets();
48 
49  //Set new time
51  newTime.SetFloat(m_aValues[index].GetFloatValue());
52  manager.SetAttributeVariable(SCR_DaytimeEditorAttribute, newTime);
53  }
54 
55  //The Time preset doesn't actually set anything other then the slider
56  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
57  {
58  return;
59  }
60 
61  override void CreatePresets()
62  {
63  int year = -1;
64  int month = 5;
65  int day = 23;
66 
67  ChimeraWorld world = GetGame().GetWorld();
68  TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
69  if (!timeManager)
70  return;
71 
72  SCR_AttributesManagerEditorComponent manager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
73  if (manager)
74  {
75  SCR_DateEditorAttribute dateAttribute = SCR_DateEditorAttribute.Cast(manager.GetAttributeRef(SCR_DateEditorAttribute));
76  if (dateAttribute)
77  {
78  SCR_BaseEditorAttributeVar dateVar = dateAttribute.GetVariable();
79  if (dateVar)
80  {
81  vector date = dateVar.GetVector();
82  year = dateAttribute.GetYearByIndex(date[2]);
83  month = date[1] +1;
84  day = date[0] +1;
85  }
86  }
87  }
88 
89  if (year < 0)
90  timeManager.GetDate(year, month, day);
91 
92  m_aValues.Clear();
93 
94  array<SCR_DayTimeInfoBase> daytimeInfo = new array<SCR_DayTimeInfoBase>;
95  timeManager.GetDayTimeInfoArray(daytimeInfo, year, month, day);
97  float time;
98 
99  foreach (SCR_DayTimeInfoBase dayTime: daytimeInfo)
100  {
102 
103  time = dayTime.GetDayTime();
104  if (time >= 24)
105  time = 0;
106 
107  value.SetWithUIInfo(dayTime.GetDayTimeUIInfo(), time * 3600);
108  m_aValues.Insert(value);
109  }
110  }
111 
112  override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
113  {
114  if (!manager)
115  return;
116 
117  SCR_BaseEditorAttribute timeAttribute = manager.GetAttributeRef(SCR_DaytimeEditorAttribute);
118  if (timeAttribute)
119  timeAttribute.PreviewVariable(setPreview, manager);
120  }
121 };
ChimeraWorld
Definition: ChimeraWorld.c:12
m_aValues
SCR_BaseEditorAttributeEntryTimeSlider m_aValues
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_DaytimeEditorAttribute
Definition: SCR_DaytimeEditorAttribute.c:5
SCR_DateEditorAttribute
Definition: SCR_DateEditorAttribute.c:2
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_TimePresetsEditorAttribute
Definition: SCR_TimePresetsEditorAttribute.c:5
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
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_UIInfo
Definition: SCR_UIInfo.c:7
SCR_EditorAttributeFloatStringValueHolder
Definition: SCR_BaseFloatValueHolderEditorAttribute.c:17
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_BasePresetsEditorAttribute
Definition: SCR_BasePresetsEditorAttribute.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