5 [
Attribute(defvalue:
"100", UIWidgets.Slider,
params:
"0 1000 1",
desc:
"How far the player has to move (squared distance) in order to refresh insects around")]
6 protected int m_iMinimumMoveDistanceSq;
8 [
Attribute(defvalue:
"30", UIWidgets.Slider,
params:
"0 100 1",
desc:
"How far it will seek the objects in range for the Insects to spawn around")]
9 protected float m_fSearchDistance;
11 [
Attribute(
desc:
"Enables setting up which effects are to be spawned around which entitites")]
12 protected ref array<ref SCR_PositionalInsectType> m_aPositionalInsectType;
14 protected ref array<ref SCR_InsectSpawnDef> m_aSpawnDef = {};
15 protected vector m_vCameraPosLooped;
17 protected ref array<float> m_aDayTimeCurve = {};
18 protected ref array<float> m_aRainIntensityCurve = {};
22 override void Update(
float worldTime, vector cameraPos,
float timeOfDay,
float rainIntensity)
25 if (vector.DistanceSqXZ(m_vCameraPosLooped, cameraPos) < m_iMinimumMoveDistanceSq)
28 m_vCameraPosLooped = cameraPos;
31 GetClosestsEntities(cameraPos);
36 type.Update(cameraPos);
42 protected void ProcessEntity(notnull IEntity entity)
44 EntityPrefabData prefabData = entity.GetPrefabData();
48 BaseContainer prefabContainer = prefabData.GetPrefab();
53 float rainIntensityCurve;
62 if (m_aDayTimeCurve[i] <= 0)
65 if (m_aRainIntensityCurve[i] <= 0)
68 BaseContainer prefabContainerToTest = prefabContainer;
69 while (prefabContainerToTest)
71 if (
type.GetPrefabContainerSet().Contains(prefabContainerToTest))
73 type.AddClosestEntity(entity);
77 prefabContainerToTest = prefabContainerToTest.GetAncestor();
84 void GetClosestsEntities(vector cameraPos)
89 type.ClearClosestEntities();
91 m_aDayTimeCurve[i] =
SCR_AmbientSoundsComponent.GetPoint(m_AmbientInsectsComponent.GetTimeOfDay(), m_aSpawnDef[i].m_TimeModifier);
92 m_aRainIntensityCurve[i] =
SCR_AmbientSoundsComponent.GetPoint(m_AmbientInsectsComponent.GetRainIntensity(), m_aSpawnDef[i].m_RainModifier);
103 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing TagManager in the world", LogLevel.WARNING);
104 m_AmbientInsectsComponent.RemoveInsectEffect(
this);
109 array<IEntity> closestEntities = {};
110 tagSystem.GetTagsInRange(closestEntities, cameraPos, m_fSearchDistance,
ETagCategory.Insect);
113 foreach (IEntity entity : closestEntities)
115 ProcessEntity(entity);
123 super.OnPostInit(ambientSoundsComponent, ambientInsectsComponent, signalsManagerComponent);
128 type.Init(ambientSoundsComponent);
130 if (!
type.m_sSpawnDef.IsEmpty())
132 Resource holder = BaseContainerTools.LoadContainer(
type.m_sSpawnDef);
134 spawnDef =
SCR_InsectSpawnDef.Cast(BaseContainerTools.CreateInstanceFromContainer(holder.GetResource().ToBaseContainer()));
139 Print(
"AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing Spawn Definition Config", LogLevel.WARNING);
140 m_AmbientInsectsComponent.RemoveInsectEffect(
this);
146 m_aDayTimeCurve.Insert(1);
147 m_aRainIntensityCurve.Insert(1);
148 m_aSpawnDef.Insert(spawnDef);