Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AmbientInsectsComponent.c
Go to the documentation of this file.
2 {
8  Seed,
10 }
11 
12 [EntityEditorProps(category: "GameScripted/Sound", description: "Component handling ambient Insects", color: "0 0 255 255")]
13 class SCR_AmbientInsectsComponentClass : ScriptComponentClass
14 {
15 }
16 
17 //------------------------------------------------------------------------------------------------
19 {
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
27  protected SignalsManagerComponent m_LocalSignalsManager;
28  protected GameSignalsManager m_GlobalSignalsManager;
29  protected SCR_AmbientSoundsComponent m_AmbientSoundsComponent;
30 
31  // Misc
32  protected int m_iEnvironmentTypeSignalValue;
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;
42  protected int m_iRainIntensitySignalIdx;
43  protected int m_iWindSpeedSignalIdx;
44 
45  //------------------------------------------------------------------------------------------------
47  int GetEnvironmentType()
48  {
49  return m_iEnvironmentTypeSignalValue;
50  }
51 
52  //------------------------------------------------------------------------------------------------
54  float GetTimeOfDay()
55  {
56  return m_fTimeOfDay;
57  }
58 
59  //------------------------------------------------------------------------------------------------
61  float GetRainIntensity()
62  {
63  return m_fRainIntensity;
64  }
65 
66  //------------------------------------------------------------------------------------------------
68  float GetWindSpeed()
69  {
70  return m_fWindSpeed;
71  }
72 
73  //------------------------------------------------------------------------------------------------
76  void RemoveInsectEffect(SCR_AmbientInsectsEffect effect)
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)
89  m_iEnvironmentTypeSignalValue = m_LocalSignalsManager.GetSignalValue(m_aLocalAmbientSignalIndex[ELocalAmbientSignal.EnvironmentType]);
90 
91  // Get time of day based on sun position
92  m_fTimeOfDay = m_LocalSignalsManager.GetSignalValue(m_iSunAngleSignalIdx) / 360;
93  m_fRainIntensity = m_GlobalSignalsManager.GetSignalValue(m_iRainIntensitySignalIdx);
94  m_fWindSpeed = m_GlobalSignalsManager.GetSignalValue(m_iWindSpeedSignalIdx);
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
113  m_LocalSignalsManager = SignalsManagerComponent.Cast(owner.FindComponent(SignalsManagerComponent));
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 
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
157  void SCR_AmbientInsectsComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
158  {
159  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_AMBIENT_LIFE, "", "Ambient Life", "World");
160  }
161 #endif
162 }
Distance
Distance
Definition: SCR_AmbientInsectsComponent.c:9
EnvironmentType
EnvironmentType
Definition: SCR_AmbientInsectsComponent.c:6
SCR_AmbientInsectsComponent
Definition: SCR_AmbientInsectsComponent.c:18
m_iUpdateRate
protected int m_iUpdateRate
Definition: SCR_GameModeSFManager.c:53
EntityEditorProps
enum ELocalAmbientSignal EntityEditorProps(category:"GameScripted/Sound", description:"Component handling ambient Insects", color:"0 0 255 255")
Definition: SCR_AmbientInsectsComponent.c:12
Seed
Seed
Definition: SCR_AmbientInsectsComponent.c:7
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_AmbientSoundsComponent
protected SCR_AmbientSoundsComponent m_AmbientSoundsComponent
Definition: SCR_PositionalInsectType.c:14
ELocalAmbientSignal
ELocalAmbientSignal
Definition: SCR_AmbientInsectsComponent.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
AboveTerrain
AboveTerrain
Definition: SCR_AmbientInsectsComponent.c:4
EntitySize
EntitySize
Definition: SCR_AmbientInsectsComponent.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_LocalSignalsManager
protected SignalsManagerComponent m_LocalSignalsManager
Definition: SCR_PositionalInsectType.c:15
SCR_AmbientSoundsComponent
Definition: SCR_AmbientSoundsComponent.c:17
SoundName
SoundName
Definition: SCR_AmbientInsectsComponent.c:2
SCR_AmbientInsectsEffect
Definition: SCR_AmbientInsectEffect.c:2
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SunAngle
SunAngle
Definition: SCR_AmbientInsectsComponent.c:5
GameSignalsManager
Definition: GameSignalsManager.c:7
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180