Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AutomatedWeatherEditorAttribute.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))
9 return null;
10
11 GenericEntity ent = GenericEntity.Cast(item);
12 ChimeraWorld world = ent.GetWorld();
13 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
14 if (!weatherManager)
15 return null;
16
17 BaseWeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
18 if (!weatherTransitionManager)
19 return null;
20
21 array<ref WeatherState> weatherStates = new array<ref WeatherState>;
22
23 //Get weather states
24 weatherManager.GetWeatherStatesList(weatherStates);
25 if (weatherStates.IsEmpty())
26 return null;
27
28 WeatherStateTransitionNode currentStateTransition = weatherTransitionManager.GetCurrentStateTransitionNode();
29
30 return SCR_BaseEditorAttributeVar.CreateBool(!currentStateTransition.IsLooping());
31 }
32
33 override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
34 {
35 //Set sub labels
36 if (isInit)
37 manager.SetAttributeAsSubAttribute(SCR_WeatherInstantEditorAttribute);
38
39 manager.SetAttributeEnabled(SCR_WeatherInstantEditorAttribute, var && !var.GetBool());
40 }
41
42 //---- REFACTOR NOTE START: Hard coded state duration for ForceWeatherTo() is unclear
43
44 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
45 {
46 //~ Ignore previews (!item)
47 if (!var || !item)
48 return;
49
50 GenericEntity ent = GenericEntity.Cast(item);
51 ChimeraWorld world = ent.GetWorld();
52 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
53 if (!weatherManager)
54 return;
55
56 BaseWeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
57 if (!weatherTransitionManager)
58 return;
59
60 if (!manager)
61 return;
62
63 WeatherStateTransitionNode currentStateTransition = weatherTransitionManager.GetCurrentStateTransitionNode();
64
65 bool setAutomatic = var.GetBool();
66
67 //Remove preview if any was set
68 if (weatherTransitionManager.IsPreviewingState())
69 weatherManager.SetWeatherStatePreview(false);
70
71 //~ Set looping false
72 if (setAutomatic)
73 {
74 weatherManager.ForceWeatherTo(!setAutomatic, string.Empty, 0, 0.001, playerID);
75 }
76 //~ Set looping true
77 else
78 {
79 float transitionTime = 0;
80
81 SCR_BaseEditorAttributeVar transitionVar;
82 if (manager.GetAttributeVariable(SCR_WeatherInstantTransitionTimeEditorAttribute, transitionVar))
83 transitionTime = transitionVar.GetInt();
84
85 weatherManager.ForceWeatherTo(!setAutomatic, string.Empty, transitionTime / 3600, 0.001, playerID);
86 }
87 }
88
89 //---- REFACTOR NOTE END ----
90
91 override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
92 {
93 if (!GetVariable())
94 return;
95
96 bool SetAutomatic = GetVariable().GetBool();
97
98 if (SetAutomatic || !setPreview)
99 {
100 ChimeraWorld world = GetGame().GetWorld();
101 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
102 if (!weatherManager)
103 return;
104
105 BaseWeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
106 if (!weatherTransitionManager)
107 return;
108
109 //Remove preview if any was set
110 if (weatherTransitionManager.IsPreviewingState())
111 weatherManager.SetWeatherStatePreview(false);
112 }
113 else
114 {
115 SCR_BaseEditorAttribute weatherInstantAttribute = manager.GetAttributeRef(SCR_WeatherInstantEditorAttribute);
116 if (!weatherInstantAttribute)
117 return;
118
119 weatherInstantAttribute.PreviewVariable(setPreview, manager);
120 }
121 }
122};
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)
sealed SCR_BaseEditorAttributeVar GetVariable(bool createWhenNull=false)
static SCR_BaseEditorAttributeVar CreateBool(bool value)
void ForceWeatherTo(bool setLooping, string weatherID=string.Empty, float transitionDuration=0, float stateDuration=0.001, int playerThatChangedWeather=0)
bool SetWeatherStatePreview(bool preview, string stateName="")