Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
EditablePrefabsLabel_CharacterRole.c
Go to the documentation of this file.
1
[
BaseContainerProps
(),
SCR_BaseContainerCustomTitleEnum
(
EEditableEntityLabel
,
"m_Label"
)]
2
class
EditablePrefabsLabel_CharacterRole
:
EditablePrefabsLabel_Base
3
{
4
[
Attribute
()]
5
protected
int
m_MedicItemCountRequired
;
6
7
protected
ref array<EEditableEntityLabel>
m_aRoleLabels
= {};
8
9
//------------------------------------------------------------------------------------------------
10
override
bool
GetLabelValid
(
WorldEditorAPI
api,
IEntitySource
entitySource,
IEntityComponentSource
componentSource,
string
targetPath,
EEditableEntityType
entityType, notnull array<EEditableEntityLabel> authoredLabels, out
EEditableEntityLabel
label)
11
{
12
if
(authoredLabels.Contains(
EEditableEntityLabel
.ROLE_LEADER))
13
return
false
;
14
15
m_aRoleLabels
.Clear();
16
17
CheckWeapons
(entitySource);
18
CheckInventory
(entitySource);
19
CheckLoadout
(entitySource);
20
21
return
GetRoleLabel
(label);
22
}
23
24
//------------------------------------------------------------------------------------------------
25
protected
void
CheckWeapons
(
IEntitySource
entitySource)
26
{
27
array<ref array<IEntityComponentSource>> weaponSlotComponents = {};
28
array<string> componentTypeArray = {
"CharacterWeaponSlotComponent"
};
29
int
weaponSlotCount =
SCR_BaseContainerTools
.FindComponentSources(entitySource, componentTypeArray, weaponSlotComponents);
30
31
array<IEntityComponentSource> weaponSlotComponentSources = weaponSlotComponents.Get(0);
32
33
if
(!weaponSlotComponentSources)
34
return
;
35
36
Resource
resource;
37
IEntitySource
weaponSource;
38
IEntityComponentSource
weaponComponentSource;
39
foreach
(
IEntityComponentSource
weaponSlotComponent : weaponSlotComponentSources)
40
{
41
ResourceName
weaponPrefab;
42
if
(weaponSlotComponent.Get(
"WeaponTemplate"
, weaponPrefab))
43
{
44
if
(!weaponPrefab)
45
continue
;
46
47
resource =
Resource
.Load(weaponPrefab);
48
if
(!resource.IsValid())
49
continue
;
50
51
weaponSource =
SCR_BaseContainerTools
.FindEntitySource(resource);
52
if
(!weaponSource)
53
continue
;
54
55
weaponComponentSource =
SCR_BaseContainerTools
.FindComponentSource(weaponSource,
"WeaponComponent"
);
56
if
(!weaponComponentSource)
57
continue
;
58
59
EWeaponType
weaponType;
60
if
(weaponComponentSource.Get(
"WeaponType"
, weaponType))
61
AddLabelForWeaponType
(weaponType);
62
63
CheckWeaponAttachments
(weaponComponentSource);
64
}
65
}
66
}
67
68
//------------------------------------------------------------------------------------------------
71
void
CheckWeaponAttachments
(
IEntityComponentSource
weaponEntitySource)
72
{
73
BaseContainer
weaponComponent = weaponEntitySource.ToBaseContainer();
74
BaseContainerList
weaponComponents = weaponComponent.GetObjectArray(
"components"
);
75
76
// Check WeaponComponent child components
77
BaseContainer
container;
78
for
(
int
i, count = weaponComponents.Count(); i < count; i++)
79
{
80
container = weaponComponents.Get(i);
81
if
(container && container.GetClassName() ==
"AttachmentSlotComponent"
)
// TODO: inherit?
82
{
83
string
attachmentType;
84
container.Get(
"AttachmentType"
, attachmentType);
85
if
(attachmentType ==
"underbarrel"
)
86
{
87
container = container.GetObject(
"AttachmentSlot"
);
// variable reuse
88
ResourceName
attachmentPrefab;
89
90
// TODO check if underbarrel attachment is actually a grenade launcher.
91
if
(container && container.Get(
"Prefab"
, attachmentPrefab))
92
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_GRENADIER);
93
}
94
}
95
}
96
}
97
98
//------------------------------------------------------------------------------------------------
99
protected
void
AddLabelForWeaponType
(
EWeaponType
weaponType)
100
{
101
switch
(weaponType)
102
{
103
case
EWeaponType
.WT_RIFLE:
104
{
105
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_RIFLEMAN);
106
break
;
107
}
108
case
EWeaponType
.WT_MACHINEGUN:
109
{
110
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_MACHINEGUNNER);
111
break
;
112
}
113
case
EWeaponType
.WT_ROCKETLAUNCHER:
114
{
115
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_ANTITANK);
116
break
;
117
}
118
case
EWeaponType
.WT_GRENADELAUNCHER:
119
{
120
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_GRENADIER);
121
break
;
122
}
123
case
EWeaponType
.WT_SNIPERRIFLE:
124
{
125
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_SHARPSHOOTER);
126
break
;
127
}
128
}
129
}
130
131
//------------------------------------------------------------------------------------------------
134
void
CheckLoadout
(
IEntitySource
entitySource)
135
{
136
IEntityComponentSource
inventoryManagerComponent =
SCR_BaseContainerTools
.FindComponentSource(entitySource, BaseLoadoutManagerComponent);
137
if
(!inventoryManagerComponent)
138
return
;
139
140
BaseContainerList
slotList = inventoryManagerComponent.GetObjectArray(
"Slots"
);
141
if
(!slotList)
142
return
;
143
144
for
(
int
i, count = slotList.Count(); i < count; i++)
145
{
146
BaseContainer
slot = slotList.Get(i);
147
LoadoutAreaType
slotArea;
148
if
(!slot.Get(
"AreaType"
, slotArea))
149
continue
;
150
151
ResourceName
slotPrefab;
152
if
(slotArea.IsInherited(
LoadoutBackpackArea
) && slot.Get(
"Prefab"
, slotPrefab))
153
{
154
Resource
slotResource =
Resource
.Load(slotPrefab);
155
IEntityComponentSource
radioComponentSource =
SCR_BaseContainerTools
.FindComponentSource(slotResource, SCR_RadioComponent);
156
ERadioCategory
radioCategory;
157
if
(radioComponentSource && radioComponentSource.Get(
"m_iRadioCategory"
, radioCategory) && radioCategory ==
ERadioCategory
.MANPACK)
158
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_RADIOOPERATOR);
159
}
160
}
161
}
162
163
//------------------------------------------------------------------------------------------------
166
void
CheckInventory
(
IEntitySource
entitySource)
167
{
168
IEntityComponentSource
inventoryManagerComponent =
SCR_BaseContainerTools
.FindComponentSource(entitySource, SCR_InventoryStorageManagerComponent);
169
if
(!inventoryManagerComponent)
170
return
;
171
172
BaseContainerList
inventoryItems = inventoryManagerComponent.GetObjectArray(
"InitialInventoryItems"
);
173
if
(!inventoryItems)
174
return
;
175
176
int
medicItemCount = 0;
177
for
(
int
i, count = inventoryItems.Count(); i < count; i++)
178
{
179
BaseContainer
inventoryItem = inventoryItems.Get(i);
180
181
array<ResourceName> prefabsToSpawn = {};
182
inventoryItem.Get(
"PrefabsToSpawn"
, prefabsToSpawn);
183
184
if
(!prefabsToSpawn)
185
continue
;
186
187
IEntityComponentSource
consumableComponentSource;
188
BaseContainer
consumableEffect;
189
foreach
(
ResourceName
prefabToSpawn : prefabsToSpawn)
190
{
191
Resource
inventoryPrefab =
Resource
.Load(prefabToSpawn);
192
if
(!inventoryPrefab.IsValid())
193
continue
;
194
195
consumableComponentSource =
SCR_BaseContainerTools
.FindComponentSource(inventoryPrefab, SCR_ConsumableItemComponent);
196
if
(consumableComponentSource)
197
{
198
consumableEffect = consumableComponentSource.GetObject(
"m_ConsumableEffect"
);
199
if
(consumableEffect)
200
{
201
SCR_EConsumableType
consumableType;
202
if
(consumableEffect.Get(
"m_eConsumableType"
, consumableType) && consumableType ==
SCR_EConsumableType
.BANDAGE)
203
medicItemCount++;
204
}
205
}
206
}
207
}
208
209
if
(medicItemCount >=
m_MedicItemCountRequired
)
210
m_aRoleLabels
.Insert(
EEditableEntityLabel
.ROLE_MEDIC);
211
}
212
213
//------------------------------------------------------------------------------------------------
214
protected
bool
GetRoleLabel
(out
EEditableEntityLabel
label)
215
{
216
label =
EEditableEntityLabel
.NONE;
217
218
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_RADIOOPERATOR))
219
label =
EEditableEntityLabel
.ROLE_RADIOOPERATOR;
220
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_ANTITANK))
221
label =
EEditableEntityLabel
.ROLE_ANTITANK;
222
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_MACHINEGUNNER))
223
label =
EEditableEntityLabel
.ROLE_MACHINEGUNNER;
224
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_GRENADIER))
225
label =
EEditableEntityLabel
.ROLE_GRENADIER;
226
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_SHARPSHOOTER))
227
label =
EEditableEntityLabel
.ROLE_SHARPSHOOTER;
228
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_MEDIC))
229
label =
EEditableEntityLabel
.ROLE_MEDIC;
230
else
if
(
m_aRoleLabels
.Contains(
EEditableEntityLabel
.ROLE_RIFLEMAN))
231
label =
EEditableEntityLabel
.ROLE_RIFLEMAN;
232
233
return
label !=
EEditableEntityLabel
.NONE;
234
}
235
}
EEditableEntityLabel
EEditableEntityLabel
Definition
EEditableEntityLabel.c:2
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition
SCR_CampaignHintStorage.c:22
SCR_EConsumableType
SCR_EConsumableType
Type of consumable gadget.
Definition
SCR_ConsumableEffectBase.c:3
ERadioCategory
ERadioCategory
Radio slot.
Definition
SCR_RadioComponent.c:3
BaseContainer
Definition
BaseContainer.c:13
BaseContainerList
Definition
BaseContainerList.c:13
EditablePrefabsLabel_Base
Definition
EditablePrefabsLabel_Base.c:3
EditablePrefabsLabel_CharacterRole
Definition
EditablePrefabsLabel_CharacterRole.c:3
EditablePrefabsLabel_CharacterRole::CheckWeapons
void CheckWeapons(IEntitySource entitySource)
Definition
EditablePrefabsLabel_CharacterRole.c:25
EditablePrefabsLabel_CharacterRole::GetRoleLabel
bool GetRoleLabel(out EEditableEntityLabel label)
Definition
EditablePrefabsLabel_CharacterRole.c:214
EditablePrefabsLabel_CharacterRole::GetLabelValid
override bool GetLabelValid(WorldEditorAPI api, IEntitySource entitySource, IEntityComponentSource componentSource, string targetPath, EEditableEntityType entityType, notnull array< EEditableEntityLabel > authoredLabels, out EEditableEntityLabel label)
Definition
EditablePrefabsLabel_CharacterRole.c:10
EditablePrefabsLabel_CharacterRole::CheckWeaponAttachments
void CheckWeaponAttachments(IEntityComponentSource weaponEntitySource)
Definition
EditablePrefabsLabel_CharacterRole.c:71
EditablePrefabsLabel_CharacterRole::AddLabelForWeaponType
void AddLabelForWeaponType(EWeaponType weaponType)
Definition
EditablePrefabsLabel_CharacterRole.c:99
EditablePrefabsLabel_CharacterRole::CheckLoadout
void CheckLoadout(IEntitySource entitySource)
Definition
EditablePrefabsLabel_CharacterRole.c:134
EditablePrefabsLabel_CharacterRole::m_MedicItemCountRequired
int m_MedicItemCountRequired
Definition
EditablePrefabsLabel_CharacterRole.c:5
EditablePrefabsLabel_CharacterRole::m_aRoleLabels
ref array< EEditableEntityLabel > m_aRoleLabels
Definition
EditablePrefabsLabel_CharacterRole.c:7
EditablePrefabsLabel_CharacterRole::CheckInventory
void CheckInventory(IEntitySource entitySource)
Definition
EditablePrefabsLabel_CharacterRole.c:166
IEntityComponentSource
Definition
IEntityComponentSource.c:13
IEntitySource
Definition
IEntitySource.c:13
LoadoutAreaType
Definition
LoadoutAreaType.c:13
LoadoutBackpackArea
Definition
LoadoutBackpackArea.c:13
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
ResourceName
Definition
ResourceName.c:13
SCR_BaseContainerTools
Definition
SCR_BaseContainerTools.c:4
WorldEditorAPI
Definition
WorldEditorAPI.c:13
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition
EEditableEntityType.c:6
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EWeaponType
EWeaponType
Definition
EWeaponType.c:13
scripts
WorkbenchGame
Editor
EditablePrefabsComponent
LabelsConfig
EditablePrefabsLabel_CharacterRole.c
Generated by
1.17.0