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_AIGroupSettingsComponent.c
Go to the documentation of this file.
1
[
ComponentEditorProps
(
category
:
"GameScripted/AI"
, description:
"Component for AI Group settings"
)]
2
class
SCR_AIGroupSettingsComponentClass
:
SCR_AISettingsBaseComponentClass
3
{
4
}
5
18
19
class
SCR_AIGroupSettingsComponent : SCR_AISettingsBaseComponent
20
{
21
protected
SCR_AIGroup
m_Group
;
22
23
[
Attribute
(
""
,
UIWidgets
.Auto,
desc
:
"These settings will be added as SCR_EAISettingOrigin.DEFAULT"
)]
24
protected
ref array<ref SCR_AISettingBase>
m_aDefaultSettings
;
25
26
//----------------------------------------------------------------------------------------------------------------------------------------------
27
// Internal
28
29
//---------------------------------------------------------------------------------------------------
30
override
protected
void
OnSettingAdded
(notnull SCR_AISettingBase setting)
31
{
32
SCR_AICharacterSetting
characterSetting =
SCR_AICharacterSetting
.Cast(setting);
33
if
(characterSetting)
34
AddSettingToMembers
(characterSetting);
35
}
36
37
//---------------------------------------------------------------------------------------------------
38
override
protected
void
OnSettingRemoved
(notnull SCR_AISettingBase setting)
39
{
40
// If a character setting was removed, also remove it from members
41
SCR_AICharacterSetting
characterSetting =
SCR_AICharacterSetting
.Cast(setting);
42
if
(characterSetting)
43
RemoveSettingFromMembers
(characterSetting);
44
}
45
46
//---------------------------------------------------------------------------------------------------
47
override
void
OnPostInit
(
IEntity
owner)
48
{
49
super.OnPostInit(owner);
50
51
m_Group
=
SCR_AIGroup
.Cast(owner);
52
53
// Add default settings
54
foreach
(
auto
s :
m_aDefaultSettings
)
55
{
56
s.Internal_ConstructedAtProperty(
SCR_EAISettingOrigin
.DEFAULT, SCR_EAISettingFlags.SETTINGS_COMPONENT);
57
AddSetting
(s,
false
,
false
);
58
}
59
60
// Subscribe to group events
61
if
(
m_Group
)
62
{
63
m_Group
.GetOnAgentAdded().Insert(
OnAgentAdded
);
64
m_Group
.GetOnAgentRemoved().Insert(
OnAgentRemoved
);
65
m_Group
.GetOnCurrentWaypointChanged().Insert(
OnCurrentWaypointChanged
);
66
}
67
}
68
69
//---------------------------------------------------------------------------------------------------
73
protected
void
AddSettingToMembers
(notnull
SCR_AICharacterSetting
setting)
74
{
75
#ifdef AI_DEBUG
76
string
strDebugText =
string
.Format(
"AddCharacterSettingToMembers: %1, Origin: %2, Priority: %3, %4"
,
77
setting,
78
typename
.EnumToString(
SCR_EAISettingOrigin
, setting.GetOrigin()),
79
setting.GetPriority(),
80
setting.GetDebugText());
81
AddDebugMessage(strDebugText);
82
#endif
83
84
if
(!
m_Group
)
85
return
;
86
87
// Bail if there are no members, the rest makes no sense
88
array<AIAgent> agents = {};
89
m_Group
.GetAgents(agents);
90
91
foreach
(AIAgent agent : agents)
92
{
93
SCR_AICharacterSettingsComponent settingsComp = SCR_AICharacterSettingsComponent.Cast(agent.FindComponent(SCR_AICharacterSettingsComponent));
94
if
(!settingsComp)
95
continue
;
96
97
settingsComp.AddCharacterSetting(setting,
true
,
false
);
// Create a copy - every member gets its own copy, and we keep the original
98
}
99
}
100
101
//---------------------------------------------------------------------------------------------------
103
protected
void
RemoveSettingFromMembers
(notnull
SCR_AICharacterSetting
setting)
104
{
105
array<AIAgent> agents = {};
106
m_Group
.GetAgents(agents);
107
108
foreach
(AIAgent agent : agents)
109
{
110
SCR_AICharacterSettingsComponent settingsComp = SCR_AICharacterSettingsComponent.Cast(agent.FindComponent(SCR_AICharacterSettingsComponent));
111
if
(!settingsComp)
112
continue
;
113
114
settingsComp.RemoveChildSettingsOfParent(setting);
115
}
116
}
117
118
//---------------------------------------------------------------------------------------------------
119
protected
void
OnAgentAdded
(AIAgent agent)
120
{
121
SCR_AICharacterSettingsComponent settingsComp = SCR_AICharacterSettingsComponent.Cast(agent.FindComponent(SCR_AICharacterSettingsComponent));
122
if
(!settingsComp)
123
return
;
124
125
// Add all settings from m_aCharacterSettings and add them to that agent
126
foreach
(
typename
t,
auto
a :
m_mSettings
)
127
{
128
// Ignore settings which are not meant for characters
129
if
(!t.IsInherited(
SCR_AICharacterSetting
))
130
continue
;
131
132
foreach
(
auto
s : a)
133
{
134
SCR_AICharacterSetting
characterSetting =
SCR_AICharacterSetting
.Cast(s);
135
settingsComp.AddCharacterSetting(characterSetting,
true
);
// Create copy - the new agent gets a copy, and we keep the original
136
}
137
}
138
}
139
140
//---------------------------------------------------------------------------------------------------
141
protected
void
OnAgentRemoved
(AIGroup group, AIAgent agent)
142
{
143
SCR_AICharacterSettingsComponent settingsComp = SCR_AICharacterSettingsComponent.Cast(agent.FindComponent(SCR_AICharacterSettingsComponent));
144
if
(!settingsComp)
145
return
;
146
147
// Remove all settings in the agent which are added from the group
148
foreach
(
typename
t,
auto
a :
m_mSettings
)
149
{
150
// Ignore settings which are not meant for characters
151
if
(!t.IsInherited(
SCR_AICharacterSetting
))
152
continue
;
153
154
foreach
(
auto
s : a)
155
settingsComp.RemoveChildSettingsOfParent(s);
156
}
157
}
158
159
//---------------------------------------------------------------------------------------------------
160
protected
void
OnCurrentWaypointChanged
(AIWaypoint _currentWp, AIWaypoint _prevWp)
161
{
162
// Remove all settings which are related to waypoints
163
RemoveSettingsWithFlag
(SCR_EAISettingFlags.WAYPOINT);
164
165
// Add settings from new wp
166
SCR_AIWaypoint
currentWp =
SCR_AIWaypoint
.Cast(_currentWp);
167
if
(currentWp)
168
{
169
array<SCR_AISettingBase> wpSettings = {};
170
currentWp.
GetSettings
(wpSettings);
171
foreach
(
auto
s : wpSettings)
172
{
173
AddSetting
(s,
true
);
// Create copy - the original remains in the waypoint, and is not registered here
174
}
175
}
176
}
177
}
AddSetting
bool AddSetting(notnull SCR_AISettingBase setting, bool createCopy, bool removeSameTypeAndOrigin=false)
It's overridden as protected. This way SCR_AICharacterSettingsComponent accepts only character settin...
Definition
SCR_AICharacterSettingsComponent.c:26
AddSettingToMembers
void AddSettingToMembers(notnull SCR_AICharacterSetting setting)
Definition
SCR_AIGroupSettingsComponent.c:73
m_Group
SCR_AIGroupSettingsComponentClass m_Group
RemoveSettingFromMembers
void RemoveSettingFromMembers(notnull SCR_AICharacterSetting setting)
Iterates all group members and removes from them all settings which are linked to passed setting.
Definition
SCR_AIGroupSettingsComponent.c:103
OnSettingAdded
void OnSettingAdded(notnull SCR_AISettingBase setting)
Definition
SCR_AIGroupSettingsComponent.c:30
OnSettingRemoved
void OnSettingRemoved(notnull SCR_AISettingBase setting)
Definition
SCR_AIGroupSettingsComponent.c:38
OnAgentRemoved
void OnAgentRemoved(AIGroup group, AIAgent agent)
Definition
SCR_AIGroupSettingsComponent.c:141
m_aDefaultSettings
ref array< ref SCR_AISettingBase > m_aDefaultSettings
Definition
SCR_AIGroupSettingsComponent.c:24
ComponentEditorProps
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
Definition
SCR_AIGroupUtilityComponent.c:12
SCR_EAISettingOrigin
SCR_EAISettingOrigin
Definition
SCR_AISetting.c:4
m_mSettings
SCR_AISettingsBaseComponentClass m_mSettings
RemoveSettingsWithFlag
void RemoveSettingsWithFlag(SCR_EAISettingFlags f)
Iterates all settings, removes all which have given flag.
Definition
SCR_AISettingsBaseComponent.c:162
OnAgentRemoved
void OnAgentRemoved()
Definition
SCR_AmbientPatrolSpawnPointComponent.c:451
OnAgentAdded
void OnAgentAdded()
Definition
SCR_GroupIdentityComponent.c:99
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
IEntity
Definition
IEntity.c:13
SCR_AICharacterSetting
Definition
SCR_AICharacterSetting.c:5
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroupSettingsComponentClass
Definition
SCR_AIGroupSettingsComponent.c:3
SCR_AISettingsBaseComponentClass
Definition
SCR_AISettingsBaseComponent.c:4
SCR_AIWaypoint
Definition
SCR_AIWaypoint.c:6
SCR_AIWaypoint::GetSettings
void GetSettings(notnull array< SCR_AISettingBase > outSettings)
Definition
SCR_AIWaypoint.c:81
UIWidgets
Definition
attributes.c:40
OnAgentAdded
void OnAgentAdded(AIAgent agent)
Definition
SCR_AIGroupSettingsComponent.c:119
OnCurrentWaypointChanged
void OnCurrentWaypointChanged(AIWaypoint _currentWp, AIWaypoint _prevWp)
Definition
SCR_AIGroupSettingsComponent.c:160
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
scripts
Game
AI
Components
SCR_AIGroupSettingsComponent.c
Generated by
1.17.0