Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WindSpeedEditorAttribute.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)) return null;
9 
10  GenericEntity ent = GenericEntity.Cast(item);
11  ChimeraWorld world = ent.GetWorld();
12  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
13  if (!weatherManager) return null;
14 
15  return SCR_BaseEditorAttributeVar.CreateFloat(weatherManager.GetWindSpeed());
16  }
17 
18  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
19  {
20  if (!var)
21  return;
22 
23  GenericEntity ent = GenericEntity.Cast(item);
24  ChimeraWorld world = ent.GetWorld();
25  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
26  if (!weatherManager)
27  return;
28 
29  weatherManager.DelayedOverrideWindSpeed(var.GetFloat(), playerID);
30  }
31 
32  override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
33  {
34  //Make sure max wind speed is set to heighest wind speed in varients
35  ChimeraWorld world = GetGame().GetWorld();
36  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
37  if (weatherManager)
38  {
39  array<ref WeatherState> weatherStates = new array<ref WeatherState>;
40  weatherManager.GetWeatherStatesList(weatherStates);
41 
42  float maxValue = m_baseValues.GetMaxValue();
43  array<ref WeatherVariant> variants = {};
44  float newMax;
45 
46  foreach (WeatherState state: weatherStates)
47  {
48  state.GetVariantsList(variants);
49 
50  foreach (WeatherVariant variant: variants)
51  {
52  WeatherWindPattern windPattern = variant.GetWindPattern();
53 
54  if (!windPattern)
55  continue;
56 
57  newMax = windPattern.GetMaxSpeed();
58 
59  if (newMax > maxValue)
60  maxValue = newMax;
61  }
62  }
63 
64  m_baseValues.SetMaxValue(Math.Ceil(maxValue));
65  }
66 
67  return super.GetEntries(outEntries);
68  }
69 
70  //Call PreviewVariable of SCR_WindAutomaticEditorAttribute
71  override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
72  {
73  if (!setPreview)
74  return;
75 
76  SCR_BaseEditorAttribute overrideAttribute = manager.GetAttributeRef(SCR_WindAutomaticEditorAttribute);
77  if (!overrideAttribute)
78  return;
79 
80  overrideAttribute.PreviewVariable(setPreview, manager);
81  }
82 };
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_WindSpeedEditorAttribute
Definition: SCR_WindSpeedEditorAttribute.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseValueListEditorAttribute
Definition: SCR_BaseValueListEditorAttribute.c:5
SCR_WindAutomaticEditorAttribute
Weather attribute if it should override certain weather values.
Definition: SCR_WindAutomaticEditorAttribute.c:3
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