Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AutomatedWeatherEditorAttribute.c
Go to the documentation of this file.
1 // Script File
4 {
5  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
6  {
7  //If opened in global attributes
8  if (!IsGameMode(item))
9  return null;
10 
11  GenericEntity ent = GenericEntity.Cast(item);
12  ChimeraWorld world = ent.GetWorld();
13  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
14  if (!weatherManager)
15  return null;
16 
17  WeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
18  if (!weatherTransitionManager)
19  return null;
20 
21  array<ref WeatherState> weatherStates = new array<ref WeatherState>;
22 
23  //Get weather states
24  weatherManager.GetWeatherStatesList(weatherStates);
25  if (weatherStates.IsEmpty())
26  return null;
27 
28  WeatherStateTransitionNode currentStateTransition = weatherTransitionManager.GetCurrentStateTransitionNode();
29 
30  return SCR_BaseEditorAttributeVar.CreateBool(!currentStateTransition.IsLooping());
31  }
32 
33  override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
34  {
35  //Set sub labels
36  if (isInit)
37  manager.SetAttributeAsSubAttribute(SCR_WeatherInstantEditorAttribute);
38 
39  manager.SetAttributeEnabled(SCR_WeatherInstantEditorAttribute, var && !var.GetBool());
40  }
41 
42  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
43  {
44  //~ Ignore previews (!item)
45  if (!var || !item)
46  return;
47 
48  GenericEntity ent = GenericEntity.Cast(item);
49  ChimeraWorld world = ent.GetWorld();
50  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
51  if (!weatherManager)
52  return;
53 
54  WeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
55  if (!weatherTransitionManager)
56  return;
57 
58  if (!manager)
59  return;
60 
61  WeatherStateTransitionNode currentStateTransition = weatherTransitionManager.GetCurrentStateTransitionNode();
62 
63  bool setAutomatic = var.GetBool();
64 
65  //Remove preview if any was set
66  if (weatherTransitionManager.IsPreviewingState())
67  weatherManager.SetWeatherStatePreview(false);
68 
69  //~ Set looping false
70  if (setAutomatic)
71  {
72  weatherManager.ForceWeatherTo(!setAutomatic, string.Empty, 0, 0.001, playerID);
73  }
74  //~ Set looping true
75  else
76  {
77  float transitionTime = 0;
78 
79  SCR_BaseEditorAttributeVar transitionVar;
80  if (manager.GetAttributeVariable(SCR_WeatherInstantTransitionTimeEditorAttribute, transitionVar))
81  transitionTime = transitionVar.GetInt();
82 
83  weatherManager.ForceWeatherTo(!setAutomatic, string.Empty, transitionTime / 3600, 0.001, playerID);
84  }
85  }
86 
87  override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
88  {
89  if (!GetVariable())
90  return;
91 
92  bool SetAutomatic = GetVariable().GetBool();
93 
94  if (SetAutomatic || !setPreview)
95  {
96  ChimeraWorld world = GetGame().GetWorld();
97  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
98  if (!weatherManager)
99  return;
100 
101  WeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
102  if (!weatherTransitionManager)
103  return;
104 
105  //Remove preview if any was set
106  if (weatherTransitionManager.IsPreviewingState())
107  weatherManager.SetWeatherStatePreview(false);
108  }
109  else
110  {
111  SCR_BaseEditorAttribute weatherInstantAttribute = manager.GetAttributeRef(SCR_WeatherInstantEditorAttribute);
112  if (!weatherInstantAttribute)
113  return;
114 
115  weatherInstantAttribute.PreviewVariable(setPreview, manager);
116  }
117  }
118 };
WeatherStateTransitionManager
Definition: WeatherStateTransitionManager.c:7
ChimeraWorld
Definition: ChimeraWorld.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WeatherInstantTransitionTimeEditorAttribute
Definition: SCR_WeatherInstantTransitionTimeEditorAttribute.c:7
SCR_WeatherInstantEditorAttribute
Definition: SCR_WeatherInstantEditorAttribute.c:5
SCR_AutomatedWeatherEditorAttribute
Definition: SCR_AutomatedWeatherEditorAttribute.c:3
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
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
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