Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WindAutomaticEditorAttribute.c
Go to the documentation of this file.
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  WeatherStateTransitionManager 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  WeatherStateTransitionManager weatherTransitionManager = weatherManager.GetTransitionManager();
116  if (!weatherTransitionManager)
117  return;
118 
119  if (weatherTransitionManager.IsPreviewingWind())
120  weatherManager.SetWindPreview(false);
121  }
122  }
123 }
WeatherStateTransitionManager
Definition: WeatherStateTransitionManager.c:7
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_WindSpeedEditorAttribute
Definition: SCR_WindSpeedEditorAttribute.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_WindDirectionEditorAttribute
Definition: SCR_WindDirectionEditorAttribute.c:5
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_WindAutomaticEditorAttribute
Weather attribute if it should override certain weather values.
Definition: SCR_WindAutomaticEditorAttribute.c:3
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468