Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WindDirectionEditorAttribute.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 weatherManager = world.GetTimeAndWeatherManager();
16 if (!weatherManager)
17 return null;
18
19 int CurrentWindDirectionIndex;
20 SCR_WindDirectionInfo windDirectionInfo;
21
22 weatherManager.GetWindDirectionInfoFromFloat(weatherManager.GetWindDirection(), CurrentWindDirectionIndex, windDirectionInfo);
23 return SCR_BaseEditorAttributeVar.CreateInt(CurrentWindDirectionIndex);
24 }
25
26
27 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
28 {
29 if (!var)
30 return;
31
32 GenericEntity ent = GenericEntity.Cast(item);
33 ChimeraWorld world = ent.GetWorld();
34 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
35 if (!weatherManager)
36 return;
37
38 int windDirectionIndex = var.GetInt();
39 int CurrentWindDirectionIndex;
40 SCR_WindDirectionInfo windDirectionInfo;
41 weatherManager.GetWindDirectionInfoFromFloat(weatherManager.GetWindDirection(), CurrentWindDirectionIndex, windDirectionInfo);
42
43 //Wind did not change
44 if (CurrentWindDirectionIndex == windDirectionIndex)
45 return;
46
47 weatherManager.GetWindDirectionInfoFromIndex(windDirectionIndex, windDirectionInfo);
48 weatherManager.DelayedOverrideWindDirection(windDirectionInfo.GetWindDirectionValue(), playerID);
49 }
50
51 protected void CreatePresets()
52 {
53 ChimeraWorld world = GetGame().GetWorld();
54 TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
55 if (!timeManager)
56 return;
57
58 m_aValues.Clear();
59
60 array<SCR_WindDirectionInfo> orderedWindDirectionInfo = new array<SCR_WindDirectionInfo>;
61 timeManager.GetOrderedWindDirectionInfoArray(orderedWindDirectionInfo);
63
64 foreach (SCR_WindDirectionInfo windDirectionInfo: orderedWindDirectionInfo)
65 {
67 value.SetName(windDirectionInfo.GetUIInfo().GetName());
68 value.SetFloatValue(windDirectionInfo.GetWindDirectionValue());
69
70 m_aValues.Insert(value);
71 }
72 }
73
74 //Call PreviewVariable of SCR_WindAutomaticEditorAttribute
75 override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
76 {
77 if (!setPreview)
78 return;
79
80 SCR_BaseEditorAttribute overrideAttribute = manager.GetAttributeRef(SCR_WindAutomaticEditorAttribute);
81 if (!overrideAttribute)
82 return;
83
84 overrideAttribute.PreviewVariable(setPreview, manager);
85 }
86
87 override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
88 {
90 //outEntries.Insert(new SCR_EditorAttributeEntryOverride(weatherManager.IsWindDirectionOverridden(), SCR_WindDirectionOverrideEditorAttribute));
91 return super.GetEntries(outEntries);
92 }
93};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external BaseWorld GetWorld()
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 CreateInt(int value)
Attribute base for Name, icon and float value for other attributes to inherent from.
ref array< ref SCR_EditorAttributeFloatStringValueHolder > m_aValues
Weather attribute if it should override certain weather values.
override int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
bool GetWindDirectionInfoFromIndex(int index, out SCR_WindDirectionInfo windDirectionInfo)
int GetOrderedWindDirectionInfoArray(notnull array< SCR_WindDirectionInfo > orderedWindDirectionInfo)
bool GetWindDirectionInfoFromFloat(float windDirectionFloat, out int index, out SCR_WindDirectionInfo windDirectionInfo)
void DelayedOverrideWindDirection(float windDirection, int playerChangingWind=-1)