Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InitWeatherComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Misc", description: "")]
5
6class 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}
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Main replication API.
Definition Replication.c:14
void ForceWeatherTo(bool setLooping, string weatherID=string.Empty, float transitionDuration=0, float stateDuration=0.001, int playerThatChangedWeather=0)
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14