Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WindOverrideEditorAttribute.c
Go to the documentation of this file.
1
4// Script File
7{
8 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
9 {
10 //If opened in global attributes
11 if (!IsGameMode(item))
12 return null;
13
14 GenericEntity ent = GenericEntity.Cast(item);
15 ChimeraWorld world = ent.GetWorld();
16 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
17 if (!weatherManager)
18 return null;
19
20 return SCR_BaseEditorAttributeVar.CreateBool(weatherManager.IsWindSpeedOverridden() || weatherManager.IsWindDirectionOverridden());
21 }
22
23 override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
24 {
25 if (!var)
26 return;
27
28 if (isInit)
29 {
30 manager.SetAttributeAsSubAttribute(SCR_WindSpeedEditorAttribute);
31 manager.SetAttributeAsSubAttribute(SCR_WindDirectionEditorAttribute);
32 }
33
34 bool overrideWeather = var && var.GetBool();
35
36 manager.SetAttributeEnabled(SCR_WindSpeedEditorAttribute, overrideWeather);
37 manager.SetAttributeEnabled(SCR_WindDirectionEditorAttribute, overrideWeather);
38 }
39
40 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
41 {
42 if (!var)
43 return;
44
45 GenericEntity ent = GenericEntity.Cast(item);
46 ChimeraWorld world = ent.GetWorld();
47 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
48 if (!weatherManager)
49 return;
50
51 BaseWeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
52
53 //Is preview
54 if (!item)
55 {
56 if (!weatherTransitionManager)
57 return;
58
59 //Has override so show preview
60 if (var.GetBool())
61 {
62 //Set wind override preview
63 SCR_BaseEditorAttributeVar windSpeedVar;
64 if (!manager.GetAttributeVariable(SCR_WindSpeedEditorAttribute, windSpeedVar))
65 return;
66
67 SCR_BaseEditorAttributeVar windDirectionVar;
68 if (!manager.GetAttributeVariable(SCR_WindDirectionEditorAttribute, windDirectionVar))
69 return;
70
71 SCR_WindDirectionInfo windDirectionInfo;
72 if (!weatherManager.GetWindDirectionInfoFromIndex(windDirectionVar.GetInt(), windDirectionInfo))
73 return;
74
75 weatherManager.SetWindPreview(true, windSpeedVar.GetFloat(), windDirectionInfo.GetWindDirectionValue());
76 }
77 //Override false so disable preview
78 else if (weatherTransitionManager.IsPreviewingWind())
79 {
80 weatherManager.SetWindPreview(false);
81 }
82
83 return;
84 }
85
86 //Cancel preview
87 if (weatherTransitionManager && weatherTransitionManager.IsPreviewingWind())
88 weatherManager.SetWindPreview(false);
89
90 weatherManager.DelayedSetWindOverride(var.GetBool(), playerID);
91 }
92
93 override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
94 {
95 //Set preview (Also called from SCR_WindSpeedEditorAttribute and SCR_WindDirectionEditorAttribute)
96 if (setPreview)
97 {
98 WriteVariable(null, GetVariable(), manager, -1);
99 }
100 //Cancel preview (On reset)
101 else
102 {
103 ChimeraWorld world = GetGame().GetWorld();
104 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
105 if (!weatherManager)
106 return;
107
108 BaseWeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
109 if (!weatherTransitionManager)
110 return;
111
112 if (weatherTransitionManager.IsPreviewingWind())
113 weatherManager.SetWindPreview(false);
114 }
115 }
116};
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...
sealed SCR_BaseEditorAttributeVar GetVariable(bool createWhenNull=false)
static SCR_BaseEditorAttributeVar CreateBool(bool value)
bool SetWindPreview(bool preview, float windSpeed=-1, float windAngleDegrees=-1)
bool GetWindDirectionInfoFromIndex(int index, out SCR_WindDirectionInfo windDirectionInfo)
void DelayedSetWindOverride(bool overrideWind, int playerChangingWind=-1)