Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external BaseWorld GetWorld()
Definition Math.c:13
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
static SCR_BaseEditorAttributeVar CreateFloat(float value)
ref SCR_EditorAttributeBaseValues m_baseValues
Weather attribute if it should override certain weather values.
void DelayedOverrideWindSpeed(float windSpeed, int playerChangingWind=-1)