Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InitWeatherComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Misc", description: "")]
3 {
4 }
5 
6 class SCR_InitWeatherComponent : SCR_BaseGameModeComponent
7 {
8  [Attribute(defvalue: "", desc: "Weather IDs are the same as used in the TimeAndWeatherManager. This sets the weather as soon as the game has been started. This weather will loop and never change automatically. If this is empty then the automated weather system will run instead")]
9  protected string m_sInitialStartingWeatherId;
10 
11  [Attribute(defvalue: "0", desc: "If true it will make sure that the set weather will stay that weather state until the GM changes this")]
12  protected bool m_iSetWeatherConstant;
13 
14  [Attribute(defvalue: "0.8", desc: "Takes float up to 24 (hours) and is used to randomize the inital weather duration. Must be lower then m_initialWeatherDurationMax. Is ignored if weather is constant.", params: "0.1 24")]
15  protected float m_initialWeatherDurationMin;
16 
17  [Attribute(defvalue: "1.2", desc: "Takes float up to 24 (hours) and is used to randomize the inital weather duration. Must be higher then m_initialWeatherDurationMin. Is ignored if weather is constant.", params: "0.1 24")]
18  protected float m_initialWeatherDurationMax;
19 
20  //------------------------------------------------------------------------------------------------
22  protected void InitWeatherServer()
23  {
24  if (!Replication.IsServer())
25  return;
26 
27  if (m_sInitialStartingWeatherId.IsEmpty())
28  return;
29 
30  ChimeraWorld world = ChimeraWorld.CastFrom(GetOwner().GetWorld());
31  if (!world)
32  {
33  Print("SCR_InitWeatherComponent is not inside a ChimeraWorld", LogLevel.WARNING);
34  return;
35  }
36 
37  TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
38  if (!weatherManager)
39  {
40  Print("SCR_InitWeatherComponent could not find TimeAndWeatherManagerEntity", LogLevel.WARNING);
41  return;
42  }
43 
44  float weatherDuration = 0;
45  if (!m_iSetWeatherConstant)
46  {
47  if (m_initialWeatherDurationMin > m_initialWeatherDurationMax)
48  m_initialWeatherDurationMin = m_initialWeatherDurationMax;
49 
50  weatherDuration = Math.RandomFloat(m_initialWeatherDurationMin, m_initialWeatherDurationMax);
51  }
52 
53  weatherManager.ForceWeatherTo(m_iSetWeatherConstant, m_sInitialStartingWeatherId, weatherDuration * 0.5, weatherDuration * 0.5);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  override void EOnInit(IEntity owner)
58  {
59  InitWeatherServer();
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override void OnPostInit(IEntity owner)
64  {
65  SetEventMask(owner, EntityEvent.INIT);
66  }
67 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
ChimeraWorld
Definition: ChimeraWorld.c:12
Attribute
SCR_InitWeatherComponentClass SCR_BaseGameModeComponentClass Attribute(defvalue:"", desc:"Weather IDs are the same as used in the TimeAndWeatherManager. This sets the weather as soon as the game has been started. This weather will loop and never change automatically. If this is empty then the automated weather system will run instead")
Sets initial weather state when server is first loaded. This state will loop and never change automat...
Definition: SCR_InitWeatherComponent.c:8
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_InitWeatherComponentClass
Definition: SCR_InitWeatherComponent.c:2
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_InitWeatherComponent.c:63
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_InitWeatherComponent.c:57
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_BaseGameModeComponentClass
Definition: SCR_BaseGameModeComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseGameModeComponent.c:199