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_EquipClothAction.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
3
class
SCR_EquipClothAction
:
SCR_InventoryAction
4
{
5
#ifndef DISABLE_INVENTORY
6
7
protected
bool
m_bIsSwappingItems
=
false
;
8
protected
string
m_sItemToSwapName
=
""
;
9
10
protected
EquipedLoadoutStorageComponent
m_LoadoutStorage
;
11
protected
BaseLoadoutClothComponent
m_LoadoutCloth
;
12
protected
SCR_CharacterInventoryStorageComponent
m_CharacterStorage
;
13
14
15
[
Attribute
(
"#AR-Inventory_Equip"
,
desc
:
"What text should be displayed when the Equip action is available."
)]
16
protected
string
m_sEquipActionString
;
17
[
Attribute
(
"#AR-Inventory_Swap"
,
desc
:
"What text should be displayed when the Swap action is available."
)]
18
protected
string
m_sSwapActionString
;
19
[
Attribute
(
"#AR-Inventory_Replaces"
,
desc
:
"What text should be displayed when the Replace action is available."
)]
20
protected
string
m_sReplaceActionString
;
21
22
//------------------------------------------------------------------------------------------------
23
override
protected
void
PerformActionInternal
(SCR_InventoryStorageManagerComponent manager,
IEntity
pOwnerEntity,
IEntity
pUserEntity)
24
{
25
manager.EquipCloth( pOwnerEntity );
26
}
27
28
//------------------------------------------------------------------------------------------------
29
override
bool
CanBePerformedScript
(
IEntity
user)
30
{
31
if
( !super.CanBePerformedScript( user ) )
32
return
false
;
33
34
if
( !
m_LoadoutStorage
)
35
m_LoadoutStorage
= EquipedLoadoutStorageComponent.Cast( user.
FindComponent
( EquipedLoadoutStorageComponent ) );
36
37
if
( !
m_LoadoutCloth
)
38
return
false
;
39
40
LoadoutAreaType
targetArea =
m_LoadoutCloth
.GetAreaType();
41
if
(!targetArea)
42
return
false
;
43
44
array<typename> blockedSlots = {};
45
m_LoadoutCloth
.GetBlockedSlots(blockedSlots);
46
foreach
(
typename
blockedArea : blockedSlots)
47
{
48
if
(
m_LoadoutStorage
.GetClothFromArea(blockedArea))
49
{
50
m_sItemToSwapName
=
""
;
51
m_bIsSwappingItems
=
false
;
52
return
false
;
53
}
54
}
55
56
if
(!
m_CharacterStorage
)
57
m_CharacterStorage
=
SCR_CharacterInventoryStorageComponent
.Cast(user.
FindComponent
(
SCR_CharacterInventoryStorageComponent
));
58
59
if
(
m_CharacterStorage
)
60
{
61
blockedSlots.Clear();
62
m_CharacterStorage
.GetBlockedSlots(blockedSlots);
63
if
(blockedSlots.Contains(targetArea.Type()))
64
{
65
m_sItemToSwapName
=
""
;
66
m_bIsSwappingItems
=
false
;
67
return
false
;
68
}
69
}
70
71
// Checks if the desired area is occupied. If it's occupied it will save the UI info related to the replaced item is saved.
72
if
(
m_LoadoutStorage
)
73
{
74
IEntity
itemToSwap =
m_LoadoutStorage
.GetClothFromArea( targetArea.Type() );
75
if
(itemToSwap)
76
{
77
InventoryItemComponent
itemComp =
InventoryItemComponent
.Cast( itemToSwap.
FindComponent
(
InventoryItemComponent
) );
78
79
// If the component is missing configuration we can fall back on the target area name.
80
if
( !itemComp || !itemComp.GetAttributes().GetUIInfo().GetName() )
81
{
82
m_sItemToSwapName
= targetArea.ToString();
83
m_bIsSwappingItems
=
false
;
84
85
return
true
;
86
}
87
88
m_sItemToSwapName
= itemComp.GetAttributes().GetUIInfo().GetName();
89
m_bIsSwappingItems
=
true
;
90
}
91
else
92
{
93
m_sItemToSwapName
=
""
;
94
m_bIsSwappingItems
=
false
;
95
}
96
}
97
else
98
{
99
m_sItemToSwapName
=
""
;
100
m_bIsSwappingItems
=
false
;
101
}
102
103
return
true
;
104
}
105
106
//------------------------------------------------------------------------------------------------
107
override
bool
GetActionNameScript
(out
string
outName)
108
{
109
if
(
m_bIsSwappingItems
)
110
{
111
string
replaceAction =
string
.Format(
WidgetManager
.Translate(
m_sReplaceActionString
),
WidgetManager
.Translate(
m_sItemToSwapName
));
112
outName =
string
.Format(
"%1 %2"
,
m_sSwapActionString
, replaceAction );
113
}
114
else
115
outName =
m_sEquipActionString
;
116
117
return
true
;
118
}
119
120
//------------------------------------------------------------------------------------------------
121
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
122
{
123
super.Init(pOwnerEntity, pManagerComponent);
124
125
if
(!m_Item)
126
return
;
127
IEntity
item = m_Item.GetOwner();
128
if
(!item)
129
return
;
130
m_LoadoutCloth
=
BaseLoadoutClothComponent
.Cast( item.
FindComponent
(
BaseLoadoutClothComponent
) );
131
132
if
(!
m_LoadoutCloth
)
133
{
134
Print
(
"Missing BaseLoadoutClothComponent"
,
LogLevel
.ERROR);
135
return
;
136
}
137
}
138
139
#endif
140
};
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseLoadoutClothComponent
Definition
BaseLoadoutClothComponent.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
InventoryItemComponent
Definition
InventoryItemComponent.c:13
LoadoutAreaType
Definition
LoadoutAreaType.c:13
SCR_CharacterInventoryStorageComponent
Definition
SCR_CharacterInventoryStorageComponent.c:90
SCR_EquipClothAction
modded version for to be used with the inventory 2.0
Definition
SCR_EquipClothAction.c:4
SCR_EquipClothAction::m_sItemToSwapName
string m_sItemToSwapName
Definition
SCR_EquipClothAction.c:8
SCR_EquipClothAction::m_sSwapActionString
string m_sSwapActionString
Definition
SCR_EquipClothAction.c:18
SCR_EquipClothAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_EquipClothAction.c:29
SCR_EquipClothAction::m_sEquipActionString
string m_sEquipActionString
Definition
SCR_EquipClothAction.c:16
SCR_EquipClothAction::m_CharacterStorage
SCR_CharacterInventoryStorageComponent m_CharacterStorage
Definition
SCR_EquipClothAction.c:12
SCR_EquipClothAction::PerformActionInternal
void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_EquipClothAction.c:23
SCR_EquipClothAction::m_LoadoutCloth
BaseLoadoutClothComponent m_LoadoutCloth
Definition
SCR_EquipClothAction.c:11
SCR_EquipClothAction::m_LoadoutStorage
EquipedLoadoutStorageComponent m_LoadoutStorage
Definition
SCR_EquipClothAction.c:10
SCR_EquipClothAction::m_sReplaceActionString
string m_sReplaceActionString
Definition
SCR_EquipClothAction.c:20
SCR_EquipClothAction::GetActionNameScript
override bool GetActionNameScript(out string outName)
Definition
SCR_EquipClothAction.c:107
SCR_EquipClothAction::m_bIsSwappingItems
bool m_bIsSwappingItems
Definition
SCR_EquipClothAction.c:7
SCR_EquipClothAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_EquipClothAction.c:121
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition
SCR_InventoryAction.c:4
WidgetManager
Definition
WidgetManager.c:16
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
UserActions
SCR_EquipClothAction.c
Generated by
1.17.0