Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DaytimeEditorAttribute.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  GenericEntity ent = GenericEntity.Cast(item);
14  ChimeraWorld world = ent.GetWorld();
15  TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
16  if (!timeManager) return null;
17 
18  return SCR_BaseEditorAttributeVar.CreateFloat(timeManager.GetTimeOfTheDay() * 3600);
19  }
20 
21  override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
22  {
23  if (!var || isInit)
24  return;
25 
26  //If slider moved set all deselected
27  manager.SetAttributeSelected(SCR_TimePresetsEditorAttribute, false, -1);
28  }
29 
30  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
31  {
32  if (!var)
33  return;
34 
35  BaseGameMode gameMode = GetGame().GetGameMode();
36  if (!gameMode)
37  return;
38 
39  ChimeraWorld world = ChimeraWorld.CastFrom(gameMode.GetWorld());
40  if (!world)
41  return;
42 
43  TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
44  if (!timeManager)
45  return;
46 
47  WeatherStateTransitionManager weatherTransitionManager = timeManager.GetTransitionManager();
48  if (!weatherTransitionManager)
49  return;
50 
51  float daytime = var.GetFloat() / 3600;
52 
53  //Preview
54  if (!item)
55  {
56  if (!manager)
57  return;
58 
59  SCR_DateEditorAttribute dateAttribute = SCR_DateEditorAttribute.Cast(manager.GetAttributeRef(SCR_DateEditorAttribute));
60  if (!dateAttribute)
61  return;
62 
63  SCR_BaseEditorAttributeVar dateVar = dateAttribute.GetVariable();
64  if (!dateVar)
65  return;
66 
67  vector date = dateVar.GetVector();
68  timeManager.SetDateTimePreview(true, dateAttribute.GetYearByIndex(date[2]), date[1] +1, date[0] +1, daytime / 24);
69 
70  return;
71  }
72 
73  if (weatherTransitionManager.IsPreviewingDateTime())
74  timeManager.SetDateTimePreview(false);
75 
76  timeManager.SetTimeOfTheDay(daytime);
77 
78  string time = SCR_FormatHelper.GetTimeFormatting(var.GetFloat(), (ETimeFormatParam.DAYS | ETimeFormatParam.SECONDS));
79 
80  //Notification
81  if (item)
82  SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(ENotification.EDITOR_ATTRIBUTES_TIME_CHANGED, playerID, time[0].ToInt(), time[1].ToInt(), time[3].ToInt(), time[4].ToInt());
83  }
84 
85  override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
86  {
87  if (setPreview)
88  {
89  WriteVariable(null, GetVariable(), manager, -1);
90  }
91  else
92  {
93  ChimeraWorld world = GetGame().GetWorld();
94  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
95  if (!weatherManager)
96  return;
97 
98  WeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
99  if (!weatherTransitionManager)
100  return;
101 
102  //Remove preview
103  if (weatherTransitionManager.IsPreviewingDateTime())
104  weatherManager.SetDateTimePreview(false);
105  }
106  }
107 
108  override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
109  {
110  outEntries.Insert(new SCR_BaseEditorAttributeEntryTimeSlider(1, true));
111  return super.GetEntries(outEntries);
112  }
113 };
WeatherStateTransitionManager
Definition: WeatherStateTransitionManager.c:7
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_DaytimeEditorAttribute
Definition: SCR_DaytimeEditorAttribute.c:5
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_DateEditorAttribute
Definition: SCR_DateEditorAttribute.c:2
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_TimePresetsEditorAttribute
Definition: SCR_TimePresetsEditorAttribute.c:5
ENotification
ENotification
Definition: ENotification.c:4
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
ETimeFormatParam
ETimeFormatParam
Definition: ETimeFormatParam.c:4
SCR_BaseValueListEditorAttribute
Definition: SCR_BaseValueListEditorAttribute.c:5
SCR_BaseEditorAttributeEntryTimeSlider
Definition: SCR_BaseEditorAttribute.c:597
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