Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_ObjectPositionalInsects.c
Go to the documentation of this file.
1
2
[
BaseContainerProps
(configRoot:
true
)]
3
class
SCR_ObjectPositionalInsects
:
SCR_AmbientInsectsEffect
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"
)]
6
protected
int
m_iMinimumMoveDistanceSq
;
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
= {};
15
protected
vector
m_vCameraPosLooped
;
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
31
foreach
(
SCR_PositionalInsectType
type
:
m_aPositionalInsectType
)
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
49
SCR_PositionalAmbientLeafParticles
leaves;
50
BaseContainer
prefabContainerToTest;
51
// According to the prefab, if time and weather conditions are valid, it is added to the respective Insect type
52
foreach
(
int
i,
SCR_PositionalInsectType
type
:
m_aPositionalInsectType
)
53
{
54
leaves =
SCR_PositionalAmbientLeafParticles
.Cast(
type
);
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
//------------------------------------------------------------------------------------------------
80
void
GetClosestsEntities
(
vector
cameraPos)
81
{
82
// Clear closest entities for all types and retrieve their curve values for time and weather
83
foreach
(
int
i,
SCR_PositionalInsectType
type
:
m_aPositionalInsectType
)
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
124
foreach
(
SCR_PositionalInsectType
type
:
m_aPositionalInsectType
)
125
{
126
type
.Init(ambientSoundsComponent,
this
, ambientInsectsComponent);
127
}
128
}
129
}
ETagCategory
ETagCategory
Definition
ETagCategory.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
type
EDamageType type
Definition
SCR_DestructibleTreeV2.c:32
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
BaseContainer
Definition
BaseContainer.c:13
ChimeraWorld
Definition
ChimeraWorld.c:13
EntityPrefabData
Definition
EntityPrefabData.c:19
IEntity
Definition
IEntity.c:13
SCR_AmbientInsectsComponent
Definition
SCR_AmbientInsectsComponent.c:19
SCR_AmbientInsectsEffect
Definition
SCR_AmbientInsectEffect.c:3
SCR_AmbientInsectsEffect::m_AmbientInsectsComponent
SCR_AmbientInsectsComponent m_AmbientInsectsComponent
Definition
SCR_AmbientInsectEffect.c:5
SCR_ObjectPositionalInsects
Handles looped ambient effects around specific entities.
Definition
SCR_ObjectPositionalInsects.c:4
SCR_ObjectPositionalInsects::m_aSpawnDef
ref array< ref SCR_InsectSpawnDef > m_aSpawnDef
Definition
SCR_ObjectPositionalInsects.c:14
SCR_ObjectPositionalInsects::m_aPositionalInsectType
ref array< ref SCR_PositionalInsectType > m_aPositionalInsectType
Definition
SCR_ObjectPositionalInsects.c:12
SCR_ObjectPositionalInsects::m_vCameraPosLooped
vector m_vCameraPosLooped
Definition
SCR_ObjectPositionalInsects.c:15
SCR_ObjectPositionalInsects::GetClosestsEntities
void GetClosestsEntities(vector cameraPos)
Clears ClosestEntities array for each InsectType and then runs new querry to fill it again.
Definition
SCR_ObjectPositionalInsects.c:80
SCR_ObjectPositionalInsects::m_iMinimumMoveDistanceSq
int m_iMinimumMoveDistanceSq
Definition
SCR_ObjectPositionalInsects.c:6
SCR_ObjectPositionalInsects::OnPostInit
override void OnPostInit(SCR_AmbientSoundsComponent ambientSoundsComponent, SCR_AmbientInsectsComponent ambientInsectsComponent, SignalsManagerComponent signalsManagerComponent)
Called by SCR_AmbientInsectsComponent in EOnPostInit().
Definition
SCR_ObjectPositionalInsects.c:120
SCR_ObjectPositionalInsects::m_fSearchDistance
float m_fSearchDistance
Definition
SCR_ObjectPositionalInsects.c:9
SCR_ObjectPositionalInsects::Update
override void Update(float worldTime, vector cameraPos, float timeOfDay, float rainIntensity)
Called by SCR_AmbientInsectsComponent.Update().
Definition
SCR_ObjectPositionalInsects.c:19
SCR_ObjectPositionalInsects::ProcessEntity
void ProcessEntity(notnull IEntity entity)
Finds Entity for each InsectType and adds it to the array of closest entities.
Definition
SCR_ObjectPositionalInsects.c:39
SCR_PositionalAmbientLeafParticles
Handles insects that are supposed to be spawned trees.
Definition
SCR_PositionalInsectType.c:292
SCR_PositionalInsectType
Base class that handles different insects based on their type.
Definition
SCR_PositionalInsectType.c:4
SignalsManagerComponent
Definition
SignalsManagerComponent.c:13
TagSystem
Definition
TagSystem.c:13
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
Components
SCR_ObjectPositionalInsects.c
Generated by
1.17.0