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