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_AIVehicleUsageComponent.c
Go to the documentation of this file.
1
2
enum
EAIVehicleType
3
{
4
INVALID
,
// Default value when not configured
5
6
GROUND_VEHICLE_WHEELED
,
// All wheeled ground vehicles, with weapon or not
7
GROUND_VEHICLE_TRACKED
,
// All tracked ground vehicles, with weapon or not
8
9
STATIC_WEAPON
,
// Static weapons which shoot directly, like static MGs
10
STATIC_ARTILLERY
,
// Static mortars
11
12
AIRCRAFT_HELICOPTER
,
// Helicopters
13
AIRCRAFT_PLANE
// Planes
14
}
15
16
class
SCR_AIVehicleUsageComponentClass :
ScriptComponentClass
17
{
18
}
19
20
void
SCR_AIOnVehicleDeleted
(
SCR_AIVehicleUsageComponent
comp);
21
typedef
func
SCR_AIOnVehicleDeleted
;
22
23
void
SCR_AIOnVehicleDamageStateChanged
(
SCR_AIVehicleUsageComponent
comp,
EDamageState
state);
24
typedef
func
SCR_AIOnVehicleDamageStateChanged
;
25
29
class
SCR_AIVehicleUsageComponent
:
ScriptComponent
30
{
31
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Vehicle type from point view of AI usage"
, enums: ParamEnumArray.FromEnum(
EAIVehicleType
))]
32
protected
EAIVehicleType
m_eVehicleType
;
33
34
[
Attribute
(
"1"
,
UIWidgets
.CheckBox,
"Can be AI a pilot of this vehicle"
)]
35
protected
bool
m_bCanBePiloted
;
36
37
protected
ref ScriptInvokerBase<SCR_AIOnVehicleDeleted>
m_OnDeleted
;
38
protected
ref ScriptInvokerBase<SCR_AIOnVehicleDamageStateChanged>
m_OnDamageStateChanged
;
39
protected
TurretCompartmentSlot
m_TurretSlot
;
40
protected
PilotCompartmentSlot
m_PilotSlot
;
41
protected
SCR_DamageManagerComponent
m_DamageManager
;
42
43
//------------------------------------------------------------------------------
44
ScriptInvokerBase<SCR_AIOnVehicleDeleted>
GetOnDeleted
()
45
{
46
if
(!
m_OnDeleted
)
47
m_OnDeleted
=
new
ScriptInvokerBase<SCR_AIOnVehicleDeleted>();
48
49
return
m_OnDeleted
;
50
}
51
52
//------------------------------------------------------------------------------
53
ScriptInvokerBase<SCR_AIOnVehicleDamageStateChanged>
GetOnDamageStateChanged
()
54
{
55
if
(!
m_OnDamageStateChanged
)
56
m_OnDamageStateChanged
=
new
ScriptInvokerBase<SCR_AIOnVehicleDamageStateChanged>();
57
58
return
m_OnDamageStateChanged
;
59
}
60
61
TurretCompartmentSlot
GetTurretCompartmentSlot
()
62
{
63
return
m_TurretSlot
;
64
}
65
66
PilotCompartmentSlot
GetPilotCompartmentSlot
()
67
{
68
return
m_PilotSlot
;
69
}
70
71
//------------------------------------------------------------------------------
73
bool
CanBePiloted
()
74
{
75
return
m_bCanBePiloted
;
76
}
77
78
//------------------------------------------------------------------------------
79
EAIVehicleType
GetVehicleType
()
80
{
81
return
m_eVehicleType
;
82
}
83
84
//------------------------------------------------------------------------------
85
bool
IsVehicleTypeValid
()
86
{
87
return
m_eVehicleType
!=
EAIVehicleType
.INVALID;
88
}
89
90
//------------------------------------------------------------------------------------------------
94
bool
IsOccupiedByGroup
(notnull
SCR_AIGroup
aiGroup)
95
{
96
array<AIAgent> members = {};
97
aiGroup.GetAgents(members);
98
foreach
(AIAgent agent : members)
99
{
100
if
(
IsOccupiedBy
(agent.GetControlledEntity()))
101
return
true
;
102
}
103
104
return
false
;
105
}
106
107
//------------------------------------------------------------------------------------------------
111
bool
IsOccupiedBy
(
IEntity
entity)
112
{
113
SCR_BaseCompartmentManagerComponent compartmentMananager = SCR_BaseCompartmentManagerComponent.Cast(
GetOwner
().
FindComponent
(SCR_BaseCompartmentManagerComponent));
114
if
(!compartmentMananager)
115
return
false
;
116
117
array<BaseCompartmentSlot> compartmentSlots = {};
118
compartmentMananager.GetCompartments(compartmentSlots);
119
foreach
(
BaseCompartmentSlot
slot : compartmentSlots)
120
{
121
if
(slot.GetOccupant() == entity)
122
return
true
;
123
}
124
125
return
false
;
126
}
127
128
//------------------------------------------------------------------------------------------------
129
EDamageState
GetDamageState
()
130
{
131
if
(!
m_DamageManager
)
132
return
EDamageState
.UNDAMAGED;
133
134
return
m_DamageManager
.GetState();
135
}
136
137
//---------------------------------------------------------------------------------------------------
140
static
SCR_AIVehicleUsageComponent
FindOnNearestParent
(notnull
IEntity
ent, out
IEntity
componentOwner)
141
{
142
SCR_AIVehicleUsageComponent
comp = null;
143
144
while
(!comp && ent)
145
{
146
comp =
SCR_AIVehicleUsageComponent
.Cast(ent.FindComponent(
SCR_AIVehicleUsageComponent
));
147
componentOwner = ent;
148
ent = ent.GetParent();
149
}
150
151
return
comp;
152
}
153
154
//---------------------------------------------------------------------------------------------------
155
// PROTECTED / INTERNAL
156
157
//------------------------------------------------------------------------------
158
protected
void
OnDamageStateChanged
(
EDamageState
damageState)
159
{
160
if
(!
m_OnDamageStateChanged
)
161
return
;
162
163
m_OnDamageStateChanged
.Invoke(
this
, damageState);
164
}
165
166
//------------------------------------------------------------------------------
167
protected
void
~SCR_AIVehicleUsageComponent
()
168
{
169
if
(
m_DamageManager
)
170
m_DamageManager
.GetOnDamageStateChanged().Remove(
OnDamageStateChanged
);
171
172
if
(
m_OnDeleted
)
173
m_OnDeleted
.Invoke(
this
);
174
}
175
176
//------------------------------------------------------------------------------
177
protected
override
void
OnPostInit
(
IEntity
owner)
178
{
179
SetEventMask
(owner,
EntityEvent
.INIT);
180
181
if
(!
IsVehicleTypeValid
())
182
ErrorIncorrectType
(owner);
183
}
184
185
//------------------------------------------------------------------------------
186
protected
override
void
EOnInit
(
IEntity
owner)
187
{
188
m_DamageManager
= SCR_DamageManagerComponent.Cast(owner.
FindComponent
(SCR_DamageManagerComponent));
189
if
(
m_DamageManager
)
190
m_DamageManager
.GetOnDamageStateChanged().Insert(
OnDamageStateChanged
);
191
192
// find pilot & turret slots
193
SCR_BaseCompartmentManagerComponent compartmentMan = SCR_BaseCompartmentManagerComponent.Cast(owner.
FindComponent
(SCR_BaseCompartmentManagerComponent));
194
if
(compartmentMan)
195
{
196
array<BaseCompartmentSlot> compartmentSlots = {};
197
compartmentMan.GetCompartments(compartmentSlots);
198
foreach
(
BaseCompartmentSlot
slot : compartmentSlots)
199
{
200
TurretCompartmentSlot
turretComp =
TurretCompartmentSlot
.Cast(slot);
201
PilotCompartmentSlot
pilotComp =
PilotCompartmentSlot
.Cast(slot);
202
if
(turretComp)
203
m_TurretSlot
= turretComp;
204
if
(pilotComp)
205
m_PilotSlot
= pilotComp;
206
}
207
}
208
}
209
210
//------------------------------------------------------------------------------
211
static
void
ErrorNoComponent
(notnull
IEntity
entity)
212
{
213
Print
(
string
.Format(
"SCR_AIVehicleUsageComponent not found on entity: %1"
, entity),
LogLevel
.ERROR);
214
}
215
216
//------------------------------------------------------------------------------
217
static
void
ErrorIncorrectType
(notnull
IEntity
entity)
218
{
219
Print
(
string
.Format(
"SCR_AIVehicleUsageComponent has incorrect type on entity: %1"
, entity),
LogLevel
.ERROR);
220
}
221
}
func
func
Definition
SCR_AIThreatSystem.c:6
SCR_AIOnVehicleDeleted
func SCR_AIOnVehicleDeleted
Definition
SCR_AIVehicleUsageComponent.c:21
STATIC_ARTILLERY
STATIC_ARTILLERY
Definition
SCR_AIVehicleUsageComponent.c:6
GROUND_VEHICLE_WHEELED
GROUND_VEHICLE_WHEELED
Definition
SCR_AIVehicleUsageComponent.c:2
AIRCRAFT_HELICOPTER
AIRCRAFT_HELICOPTER
Definition
SCR_AIVehicleUsageComponent.c:8
EAIVehicleType
EAIVehicleType
Vehicle type from point view of AI usage.
Definition
SCR_AIVehicleUsageComponent.c:3
STATIC_WEAPON
STATIC_WEAPON
Definition
SCR_AIVehicleUsageComponent.c:5
GROUND_VEHICLE_TRACKED
GROUND_VEHICLE_TRACKED
Definition
SCR_AIVehicleUsageComponent.c:3
SCR_AIOnVehicleDamageStateChanged
func SCR_AIOnVehicleDamageStateChanged
Definition
SCR_AIVehicleUsageComponent.c:24
AIRCRAFT_PLANE
AIRCRAFT_PLANE
Definition
SCR_AIVehicleUsageComponent.c:10
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
GenericComponent::SetEventMask
proto external int SetEventMask(notnull IEntity owner, int mask)
GenericComponent::FindComponent
proto external GenericComponent FindComponent(typename typeName)
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
PilotCompartmentSlot
Definition
PilotCompartmentSlot.c:13
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIVehicleUsageComponent
Definition
SCR_AIVehicleUsageComponent.c:30
SCR_AIVehicleUsageComponent::m_bCanBePiloted
bool m_bCanBePiloted
Definition
SCR_AIVehicleUsageComponent.c:35
SCR_AIVehicleUsageComponent::GetTurretCompartmentSlot
TurretCompartmentSlot GetTurretCompartmentSlot()
Definition
SCR_AIVehicleUsageComponent.c:61
SCR_AIVehicleUsageComponent::ErrorIncorrectType
static void ErrorIncorrectType(notnull IEntity entity)
Definition
SCR_AIVehicleUsageComponent.c:217
SCR_AIVehicleUsageComponent::GetOnDamageStateChanged
ScriptInvokerBase< SCR_AIOnVehicleDamageStateChanged > GetOnDamageStateChanged()
Definition
SCR_AIVehicleUsageComponent.c:53
SCR_AIVehicleUsageComponent::GetOnDeleted
ScriptInvokerBase< SCR_AIOnVehicleDeleted > GetOnDeleted()
Definition
SCR_AIVehicleUsageComponent.c:44
SCR_AIVehicleUsageComponent::m_eVehicleType
EAIVehicleType m_eVehicleType
Definition
SCR_AIVehicleUsageComponent.c:32
SCR_AIVehicleUsageComponent::EOnInit
override void EOnInit(IEntity owner)
Definition
SCR_AIVehicleUsageComponent.c:186
SCR_AIVehicleUsageComponent::~SCR_AIVehicleUsageComponent
void ~SCR_AIVehicleUsageComponent()
Definition
SCR_AIVehicleUsageComponent.c:167
SCR_AIVehicleUsageComponent::IsVehicleTypeValid
bool IsVehicleTypeValid()
Definition
SCR_AIVehicleUsageComponent.c:85
SCR_AIVehicleUsageComponent::m_PilotSlot
PilotCompartmentSlot m_PilotSlot
Definition
SCR_AIVehicleUsageComponent.c:40
SCR_AIVehicleUsageComponent::CanBePiloted
bool CanBePiloted()
AI can use the pilot compartments on this vehicle.
Definition
SCR_AIVehicleUsageComponent.c:73
SCR_AIVehicleUsageComponent::IsOccupiedByGroup
bool IsOccupiedByGroup(notnull SCR_AIGroup aiGroup)
Definition
SCR_AIVehicleUsageComponent.c:94
SCR_AIVehicleUsageComponent::FindOnNearestParent
static SCR_AIVehicleUsageComponent FindOnNearestParent(notnull IEntity ent, out IEntity componentOwner)
Definition
SCR_AIVehicleUsageComponent.c:140
SCR_AIVehicleUsageComponent::ErrorNoComponent
static void ErrorNoComponent(notnull IEntity entity)
Definition
SCR_AIVehicleUsageComponent.c:211
SCR_AIVehicleUsageComponent::m_OnDeleted
ref ScriptInvokerBase< SCR_AIOnVehicleDeleted > m_OnDeleted
Definition
SCR_AIVehicleUsageComponent.c:37
SCR_AIVehicleUsageComponent::m_DamageManager
SCR_DamageManagerComponent m_DamageManager
Definition
SCR_AIVehicleUsageComponent.c:41
SCR_AIVehicleUsageComponent::OnDamageStateChanged
void OnDamageStateChanged(EDamageState damageState)
Definition
SCR_AIVehicleUsageComponent.c:158
SCR_AIVehicleUsageComponent::OnPostInit
override void OnPostInit(IEntity owner)
Definition
SCR_AIVehicleUsageComponent.c:177
SCR_AIVehicleUsageComponent::IsOccupiedBy
bool IsOccupiedBy(IEntity entity)
Definition
SCR_AIVehicleUsageComponent.c:111
SCR_AIVehicleUsageComponent::m_TurretSlot
TurretCompartmentSlot m_TurretSlot
Definition
SCR_AIVehicleUsageComponent.c:39
SCR_AIVehicleUsageComponent::m_OnDamageStateChanged
ref ScriptInvokerBase< SCR_AIOnVehicleDamageStateChanged > m_OnDamageStateChanged
Definition
SCR_AIVehicleUsageComponent.c:38
SCR_AIVehicleUsageComponent::GetDamageState
EDamageState GetDamageState()
Definition
SCR_AIVehicleUsageComponent.c:129
SCR_AIVehicleUsageComponent::GetPilotCompartmentSlot
PilotCompartmentSlot GetPilotCompartmentSlot()
Definition
SCR_AIVehicleUsageComponent.c:66
SCR_AIVehicleUsageComponent::GetVehicleType
EAIVehicleType GetVehicleType()
Definition
SCR_AIVehicleUsageComponent.c:79
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
TurretCompartmentSlot
Definition
TurretCompartmentSlot.c:13
UIWidgets
Definition
attributes.c:40
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
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
EDamageState
EDamageState
Definition
EDamageState.c:13
INVALID
@ INVALID
Missing components, or obstruction test was not possible.
Definition
WindingOrder.c:16
scripts
Game
AI
Components
SCR_AIVehicleUsageComponent.c
Generated by
1.17.0