5 [
Attribute(defvalue:
"900",
UIWidgets.Slider,
params:
"100 100000 1",
desc:
"Random positional insects that exceed this range (squared distance) will be despawned")]
38 override void Update(
float worldTime,
vector cameraPos,
float timeOfDay,
float rainIntensity)
63 float windSpeedScaled =
Math.InverseLerp(SCR_AmbientSoundsComponent.WINDSPEED_MIN, SCR_AmbientSoundsComponent.WINDSPEED_MAX,
m_AmbientInsectsComponent.GetWindSpeed());
75 float modifier = SCR_AmbientSoundsComponent.GetPoint(timeOfDay, spawnDef.m_TimeModifier);
76 modifier = modifier * SCR_AmbientSoundsComponent.GetPoint(rainIntensity, spawnDef.m_RainModifier);
92 if (soundMapType == 0)
94 else if (soundMapType == 1)
95 return m_aSpawnDef[insectGroup].m_iForestDensityMax;
96 else if (soundMapType == 2)
98 else if (soundMapType == 3)
99 return m_aSpawnDef[insectGroup].m_iMeadowDensityMax;
100 else if (soundMapType == 4)
101 return m_aSpawnDef[insectGroup].m_iRiverDensityMax;
102 else if (soundMapType == 5)
103 return m_aSpawnDef[insectGroup].m_iRiverSlopeDensityMax;
104 else if (soundMapType == 6)
107 return m_aSpawnDef[insectGroup].m_iCoastDensityMax;
135 float dayTimeCurve = SCR_AmbientSoundsComponent.GetPoint(timeOfDay,
m_aSpawnDef[
m_aParticles[i].m_iSoundGroup].m_TimeModifier);
136 float rainIntensityCurve = SCR_AmbientSoundsComponent.GetPoint(rainIntensity,
m_aSpawnDef[
m_aParticles[i].m_iSoundGroup].m_RainModifier);
137 if (dayTimeCurve <= 0 || rainIntensityCurve <= 0)
152 AnimationPlayerComponent animComponent = AnimationPlayerComponent.Cast(entity.
FindComponent(AnimationPlayerComponent));
156 ResourceName animationResource = animComponent.GetAnimation();
160 animComponent.Prepare(animationResource,
Math.RandomFloatInclusive(1, 5), 1,
true);
161 animComponent.Play();
186 if (
m_aInsectGroup[insectGroup].m_aInsectType.IsIndexValid(insectType))
192 string particleName = insectDef.m_sParticleEffect;
193 string soundName = insectDef.m_sSoundName;
197 spawnParams.Transform[3] = vPos;
200 particle.m_iSoundGroup = insectGroup;
201 particle.m_vPosition = vPos;
204 if (!soundName.IsEmpty())
207 if (!prefabName.IsEmpty())
213 entitySpawnParams.Transform = spawnParams.Transform;
214 entitySpawnParams.TransformMode = spawnParams.TransformMode;
216 particle.m_InsectEntity =
GetGame().SpawnEntityPrefab(resource,
GetGame().GetWorld(), entitySpawnParams);
217 if (particle.m_InsectEntity)
224 else if (!particleName.IsEmpty())
226 particle.m_ParticleEffect =
ParticleEffectEntity.SpawnParticleEffect(insectDef.m_sParticleEffect, spawnParams);
232 if (!soundName.IsEmpty())
259 return vPos + camPos;
270 int size = insectType.m_aInsectDef.Count();
274 int offset =
Math.RandomIntInclusive(0,
size - 1);
276 for (
int i = 0; i <
size; i++)
278 int idx = i + offset;
283 return insectType.m_aInsectDef[
idx];
299 SoundWorld soundWorld = world.GetSoundWorld();
304 float seaCam, forestCam, cityCam, meadowCam;
305 soundWorld.GetMapValuesAtPos(camPos, seaCam, forestCam, cityCam, meadowCam);
307 float seaPos, forestPos, cityPos, meadowPos;
308 soundWorld.GetMapValuesAtPos(worldPos, seaPos, forestPos, cityPos, meadowPos);
310 float riverCam, riverSlopeCam, lakeCam, coastCam;
311 soundWorld.GetMapValuesAdvAtPos(camPos, riverCam, riverSlopeCam, lakeCam, coastCam);
313 float riverPos, riverSlopePos, lakePos, coastPos;
314 soundWorld.GetMapValuesAdvAtPos(worldPos, riverPos, riverSlopePos, lakePos, coastPos);
316 array<float> valuesPos = {seaPos, forestPos, cityPos, meadowPos, riverPos, riverSlopePos, lakePos, coastPos};
317 array<float> valuesCam = {seaCam, forestCam, cityCam, meadowCam, riverCam, riverSlopeCam, lakeCam, coastCam};
320 for (
int i; i < 8; i++)
322 if (valuesCam[i] > valuesPos[i])
323 valuesPos[i] = valuesCam[i];
327 float v = valuesPos[0];
332 if (valuesPos[i] >= v)
346 float surfaceHeight = world.GetSurfaceY(worldPos[0], worldPos[2]);
347 worldPos[1] = surfaceHeight;
353 if (valuesPos[6] >= 0.75)
356 worldPos[1] =
SCR_WorldTools.GetWaterSurfaceY(world, worldPos, waterSurfaceType, lakeArea);
380 SCR_InsectGroup insectGroup;
381 if (def.m_sInsectGroup !=
string.Empty)
385 insectGroup = SCR_InsectGroup.Cast(
BaseContainerTools.CreateInstanceFromContainer(holder.GetResource().ToBaseContainer()));
390 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing Ambience Sound Gropu Config",
LogLevel.WARNING);
400 if (def.m_sSpawnDef !=
string.Empty)
409 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing Spawn Definition Config",
LogLevel.WARNING);
427 if (!ambientSoundsDayTimeCurveDefinitionConfig)
429 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing Daytime Curve Deffinition Config",
LogLevel.WARNING);
435 m_aDayTimeCurve = ambientSoundsDayTimeCurveDefinitionConfig.m_aDayTimeCurve;
446 if (!ambientSoundsWindDefinitionConfig)
448 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing Wind Curve Definition Config",
LogLevel.WARNING);
461 super.OnPostInit(ambientSoundsComponent, ambientInsectsComponent, signalsManagerComponent);
ArmaReforgerScripted GetGame()
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
enum EAudioSourceFlag m_AudioHandle
Stores valid Audio handle.
const int DAY_TIME_CURVE_COUNT
void ParticleEffectEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
const int WIND_CURVE_COUNT
proto external Managed FindComponent(typename typeName)
proto external int SetVComponentFlags(VCFlags flags)
Sets component flags.
Object holding reference to resource. In destructor release the resource.
SCR_AmbientSoundsComponent m_AmbientSoundsComponent
SCR_AmbientInsectsComponent m_AmbientInsectsComponent
Array size has to have the same count as EDayTimeCurve.
Spawns Insect particles around camera based on define behaviour.
ref array< ref SCR_InsectGroup > m_aInsectGroup
ref array< ref SCR_RandomPositionalInsectsDef > m_aRandomPositionalInsectsDef
vector GenerateRandomPosition(int insectGroup, vector camPos)
ref array< ref SCR_InsectSpawnDef > m_aSpawnDef
int GetDensityMax(int insectGroup, int soundMapType)
ResourceName m_sDayTimeCurve
float m_aWindCurveValue[WIND_CURVE_COUNT]
int GetSoundMapTypeFromTerrain(inout vector worldPos, vector camPos)
void LoadConfigs()
Loads configs where necessary values are stored.
float m_aDayTimeCurveValue[DAY_TIME_CURVE_COUNT]
void RemoveParticlesBasedOnTimeAndWeather(float timeOfDay, float rainIntensity)
ref array< ref SCR_InsectParticle > m_aParticles
void UpdateInsectGroup(float worldTime, vector camPos, int insectGroup)
ref array< int > m_aAngleOffset
ref array< ref SCR_WindCurveDef > m_aWindModifier
void UpdateDensity()
Updates insect density per group and active particles.
int m_iUpdatedInsectGroupIdx
ref array< float > m_aDensityModifier
void RemoveOutOfRangeParticles(vector cameraPos)
override void OnPostInit(SCR_AmbientSoundsComponent ambientSoundsComponent, SCR_AmbientInsectsComponent ambientInsectsComponent, SignalsManagerComponent signalsManagerComponent)
ref array< ref SCR_DayTimeCurveDef > m_aDayTimeCurve
void UpdateGlobalModifiers(float timeOfDay, float rainIntensity)
ref array< int > m_aDensity
void RandomizeAnimation(IEntity entity)
ResourceName m_sWindCurve
SCR_InsectDef GetRandomInsectDef(SCR_InsectType insectType)
override void Update(float worldTime, vector cameraPos, float timeOfDay, float rainIntensity)
static bool IsEmptyOrWhiteSpace(string input)
Array has to have the same size as EWindCurve count.
Instance of created debug visualizer.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
VCFlags
VObjectComponent flags.