Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AmbientInsectsComponent.c
Go to the documentation of this file.
11
12[EntityEditorProps(category: "GameScripted/Sound", description: "Component handling ambient Insects", color: "0 0 255 255")]
13class SCR_AmbientInsectsComponentClass : ScriptComponentClass
17//------------------------------------------------------------------------------------------------
20 [Attribute(defvalue: "4", UIWidgets.Slider, params: "0 60 1", desc: "How frequently are Insects updated around the camera")]
21 protected int m_iUpdateRate;
22
23 [Attribute()]
24 protected ref array<ref SCR_AmbientInsectsEffect> m_aAmbientInsectsEffect;
25
26 // Components
29 protected SCR_AmbientSoundsComponent m_AmbientSoundsComponent;
30
31 // Misc
33
35 protected ref array<int> m_aLocalAmbientSignalIndex = {};
36
37 protected float m_fTimeOfDay;
38 protected float m_fRainIntensity;
39 protected float m_fWindSpeed;
40
41 protected int m_iSunAngleSignalIdx;
43 protected int m_iWindSpeedSignalIdx;
44
45 //------------------------------------------------------------------------------------------------
51
52 //------------------------------------------------------------------------------------------------
55 {
56 return m_fTimeOfDay;
57 }
58
59 //------------------------------------------------------------------------------------------------
62 {
63 return m_fRainIntensity;
64 }
65
66 //------------------------------------------------------------------------------------------------
69 {
70 return m_fWindSpeed;
71 }
72
73 //------------------------------------------------------------------------------------------------
77 {
78 m_aAmbientInsectsEffect.RemoveItem(effect);
79 }
80
81 //------------------------------------------------------------------------------------------------
82 protected void Update(IEntity owner)
83 {
84 float worldTime = owner.GetWorld().GetWorldTime();
85 vector cameraPos = m_AmbientSoundsComponent.GetCameraOrigin();
86
87 // Get spawn preset = EnvironmentType
88 if (m_aLocalAmbientSignalIndex[ELocalAmbientSignal.EnvironmentType] != -1)
90
91 // Get time of day based on sun position
95
96 //We are using for loop because these effects can get removed during run-time from the update loop
97 for (int i = m_aAmbientInsectsEffect.Count() - 1; i >= 0; i--)
98 {
99 if (m_aAmbientInsectsEffect.IsIndexValid(i))
100 m_aAmbientInsectsEffect[i].Update(worldTime, cameraPos, m_fTimeOfDay, m_fRainIntensity);
101 }
102 }
103
104 //------------------------------------------------------------------------------------------------
105 override void OnPostInit(IEntity owner)
106 {
107 super.OnPostInit(owner);
108
109 if (RplSession.Mode() == RplMode.Dedicated)
110 return;
111
112 // Get local signals component
115 {
116 Print("AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing SignalsManagerComponent", LogLevel.WARNING);
117 return;
118 }
119
120 m_GlobalSignalsManager = GetGame().GetSignalsManager();
121
122 // Get Local Ambient Signal Idx
123 typename enumType = ELocalAmbientSignal;
124 int size = enumType.GetVariableCount();
125
126 for (int i = 0; i < size; i++)
127 {
128 m_aLocalAmbientSignalIndex.Insert(m_LocalSignalsManager.AddOrFindSignal(typename.EnumToString(ELocalAmbientSignal, i)));
129 }
130
131 m_iSunAngleSignalIdx = m_LocalSignalsManager.AddOrFindSignal("SunAngle");
132 m_iRainIntensitySignalIdx = m_GlobalSignalsManager.AddOrFindSignal("RainIntensity");
133 m_iWindSpeedSignalIdx = m_GlobalSignalsManager.AddOrFindSignal("WindSpeed");
134
135 m_AmbientSoundsComponent = SCR_AmbientSoundsComponent.Cast(owner.FindComponent(SCR_AmbientSoundsComponent));
137 {
138 Print("AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing SCR_AmbientSoundsComponent", LogLevel.WARNING);
139 return;
140 }
141
142 foreach (SCR_AmbientInsectsEffect ambientInsectsEffect : m_aAmbientInsectsEffect)
143 {
144 ambientInsectsEffect.OnPostInit(m_AmbientSoundsComponent, this, m_LocalSignalsManager);
145 }
146
147 Update(owner);
148 GetGame().GetCallqueue().CallLater(Update, 1000 * m_iUpdateRate, true, owner);
149 }
150
151#ifdef ENABLE_DIAG
152 //------------------------------------------------------------------------------------------------
153 // constructor
158 {
159 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_AMBIENT_LIFE, "", "Ambient Life", "World");
160 }
161#endif
162}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
RplMode
Mode of replication.
Definition RplMode.c:9
enum ELocalAmbientSignal EntityEditorProps(category:"GameScripted/Sound", description:"Component handling ambient Insects", color:"0 0 255 255")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
override void OnPostInit(IEntity owner)
SignalsManagerComponent m_LocalSignalsManager
SCR_AmbientSoundsComponent m_AmbientSoundsComponent
ref array< ref SCR_AmbientInsectsEffect > m_aAmbientInsectsEffect
ref array< int > m_aLocalAmbientSignalIndex
AmbientEntity Signal's manager signals indexes.
void RemoveInsectEffect(SCR_AmbientInsectsEffect effect)
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