Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ObjectPositionalInsects.c
Go to the documentation of this file.
1
2[BaseContainerProps(configRoot: true)]
4{
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")]
7
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;
10
11 [Attribute(desc: "Enables setting up which effects are to be spawned around which entitites")]
12 protected ref array<ref SCR_PositionalInsectType> m_aPositionalInsectType;
13
14 protected ref array<ref SCR_InsectSpawnDef> m_aSpawnDef = {};
16
17 //------------------------------------------------------------------------------------------------
19 override void Update(float worldTime, vector cameraPos, float timeOfDay, float rainIntensity)
20 {
21 // Limit processing by time and moved distance
22 if (vector.DistanceSqXZ(m_vCameraPosLooped, cameraPos) < m_iMinimumMoveDistanceSq)
23 return;
24
25 m_vCameraPosLooped = cameraPos;
26
27 // First we get closest entities coresponding to each InsectType
28 GetClosestsEntities(cameraPos);
29
30 // Then we trigger update for each InsectType
32 {
33 type.Update(cameraPos);
34 }
35 }
36
37 //------------------------------------------------------------------------------------------------
39 protected void ProcessEntity(notnull IEntity entity)
40 {
41 EntityPrefabData prefabData = entity.GetPrefabData();
42 if (!prefabData)
43 return;
44
45 BaseContainer prefabContainer = prefabData.GetPrefab();
46 if (!prefabContainer)
47 return;
48
50 BaseContainer prefabContainerToTest;
51 // According to the prefab, if time and weather conditions are valid, it is added to the respective Insect type
53 {
55 if (leaves)
56 continue;
57
58 if (type.m_fDayTimeCurve <= 0)
59 continue;
60
61 if (type.m_fRainIntensityCurve <= 0)
62 continue;
63
64 prefabContainerToTest = prefabContainer;
65 while (prefabContainerToTest)
66 {
67 if (type.GetPrefabContainerSet().Contains(prefabContainerToTest))
68 {
69 type.AddClosestEntity(entity);
70 return;
71 }
72
73 prefabContainerToTest = prefabContainerToTest.GetAncestor();
74 }
75 }
76 }
77
78 //------------------------------------------------------------------------------------------------
81 {
82 // Clear closest entities for all types and retrieve their curve values for time and weather
84 {
85 type.ClearClosestEntities();
86
87 type.m_fDayTimeCurve = SCR_AmbientSoundsComponent.GetPoint(m_AmbientInsectsComponent.GetTimeOfDay(), type.m_SpawnDef.m_TimeModifier);
88 type.m_fRainIntensityCurve = SCR_AmbientSoundsComponent.GetPoint(m_AmbientInsectsComponent.GetRainIntensity(), type.m_SpawnDef.m_RainModifier);
89 }
90
91 ChimeraWorld world = GetGame().GetWorld();
92 if (!world)
93 return;
94
95 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
96 // Using TagManager we get array of closest entities where Insects can spawn
97 TagSystem tagSystem = TagSystem.Cast(world.FindSystem(TagSystem));
98 if (!tagSystem)
99 {
100 Print("AMBIENT LIFE: SCR_AmbientInsectsComponent: Missing TagManager in the world", LogLevel.WARNING);
101 m_AmbientInsectsComponent.RemoveInsectEffect(this);
102
103 return;
104 }
105
106 array<IEntity> closestEntities = {};
107 tagSystem.GetTagsInRange(closestEntities, cameraPos, m_fSearchDistance, ETagCategory.Insect);
108
109 // Process each entity to add it to the respective Insect type
110 foreach (IEntity entity : closestEntities)
111 {
112 ProcessEntity(entity);
113 }
114
115 //---- REFACTOR NOTE END ----
116 }
117
118 //------------------------------------------------------------------------------------------------
120 override void OnPostInit(SCR_AmbientSoundsComponent ambientSoundsComponent, SCR_AmbientInsectsComponent ambientInsectsComponent, SignalsManagerComponent signalsManagerComponent)
121 {
122 super.OnPostInit(ambientSoundsComponent, ambientInsectsComponent, signalsManagerComponent);
123
125 {
126 type.Init(ambientSoundsComponent, this, ambientInsectsComponent);
127 }
128 }
129}
ETagCategory
Definition ETagCategory.c:2
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
EDamageType type
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_AmbientInsectsComponent m_AmbientInsectsComponent
Handles looped ambient effects around specific entities.
ref array< ref SCR_InsectSpawnDef > m_aSpawnDef
ref array< ref SCR_PositionalInsectType > m_aPositionalInsectType
void GetClosestsEntities(vector cameraPos)
Clears ClosestEntities array for each InsectType and then runs new querry to fill it again.
override void OnPostInit(SCR_AmbientSoundsComponent ambientSoundsComponent, SCR_AmbientInsectsComponent ambientInsectsComponent, SignalsManagerComponent signalsManagerComponent)
Called by SCR_AmbientInsectsComponent in EOnPostInit().
override void Update(float worldTime, vector cameraPos, float timeOfDay, float rainIntensity)
Called by SCR_AmbientInsectsComponent.Update().
void ProcessEntity(notnull IEntity entity)
Finds Entity for each InsectType and adds it to the array of closest entities.
Handles insects that are supposed to be spawned trees.
Base class that handles different insects based on their type.
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