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_AITakeGadgetInLeftHand.c
Go to the documentation of this file.
1
class
SCR_AITakeGadgetInLeftHand
:
AITaskScripted
2
{
3
[
Attribute
(
"0"
,
UIWidgets
.ComboBox, enums: ParamEnumArray.FromEnum(
ECommonItemType
) )]
4
private
ECommonItemType
m_eItemType;
5
6
[
Attribute
(
"0"
,
UIWidgets
.ComboBox, enums: ParamEnumArray.FromEnum(EGadgetType) )]
7
private
EGadgetType m_eGadgetType;
8
9
protected
const
float
TIMEOUT_S
= 6.0;
10
11
protected
IEntity
m_OwnerEntity
;
12
protected
CharacterControllerComponent
m_CharacterController
;
13
protected
SCR_InventoryStorageManagerComponent
m_InventoryMgr
;
14
protected
SCR_GadgetManagerComponent
m_GadgetManager
;
15
16
protected
IEntity
m_ItemEntity
;
// Item which we have requested to equip
17
protected
bool
m_bWaiting
;
// When true, we are waiting for item to be equipped
18
protected
float
m_fTimer_s
;
// Timer how long we've been waiting
19
20
// Inputs
21
protected
static
const
string
PORT_ITEM_IN
=
"ItemIn"
;
22
23
// Outputs
24
protected
static
const
string
PORT_ITEM_OUT
=
"ItemOut"
;
25
26
//------------------------------------------------------------------------------------------------
27
protected
static
ref
TStringArray
s_aVarsIn
= {
PORT_ITEM_IN
};
28
override
TStringArray
GetVariablesIn
() {
return
s_aVarsIn
; }
29
30
protected
static
ref
TStringArray
s_aVarsOut
= {
PORT_ITEM_OUT
};
31
override
TStringArray
GetVariablesOut
() {
return
s_aVarsOut
; }
32
33
// -----------------------------------------------------------------------------------------------
34
override
void
OnInit
(AIAgent owner)
35
{
36
m_OwnerEntity
= owner.GetControlledEntity();
37
m_CharacterController
= CharacterControllerComponent.Cast(
m_OwnerEntity
.FindComponent(CharacterControllerComponent));
38
m_InventoryMgr
= SCR_InventoryStorageManagerComponent.Cast(
m_OwnerEntity
.FindComponent(SCR_InventoryStorageManagerComponent));
39
m_GadgetManager
=
SCR_GadgetManagerComponent
.
GetGadgetManager
(
m_OwnerEntity
);
40
}
41
42
// -----------------------------------------------------------------------------------------------
43
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
44
{
45
if
(!
m_CharacterController
|| !
m_InventoryMgr
)
46
return
ENodeResult
.FAIL;
47
48
if
(
m_bWaiting
)
49
{
50
if
(
IsItemEquipped
(
m_ItemEntity
))
51
{
52
SetVariableOut
(
PORT_ITEM_OUT
,
m_ItemEntity
);
53
Reset
();
54
return
ENodeResult
.SUCCESS;
55
}
56
else
if
(
m_fTimer_s
>
TIMEOUT_S
)
57
{
58
ClearVariable
(
PORT_ITEM_OUT
);
59
Reset
();
60
return
ENodeResult
.FAIL;
61
}
62
else
63
{
64
m_fTimer_s
+= dt;
65
return
ENodeResult
.RUNNING;
66
}
67
}
68
else
69
{
70
IEntity
item =
FindItem
();
71
72
if
(!item)
73
return
ENodeResult
.FAIL;
74
else
75
{
76
if
(!
m_CharacterController
.CanEquipGadget(item))
77
return
ENodeResult
.RUNNING;
78
else
79
{
80
if
(
EquipInventoryItem
(item))
81
{
82
m_ItemEntity
= item;
83
m_fTimer_s
= 0;
84
m_bWaiting
=
true
;
85
return
ENodeResult
.RUNNING;
86
}
87
else
88
return
ENodeResult
.FAIL;
89
}
90
}
91
}
92
}
93
94
//-----------------------------------------------------------------------------------------------
95
protected
void
Reset
()
96
{
97
m_ItemEntity
= null;
98
m_fTimer_s
= 0;
99
m_bWaiting
=
false
;
100
}
101
102
//-----------------------------------------------------------------------------------------------
103
override
void
OnAbort
(AIAgent owner,
Node
nodeCausingAbort)
104
{
105
Reset
();
106
}
107
108
//-----------------------------------------------------------------------------------------------
109
IEntity
FindItem
()
110
{
111
IEntity
item;
112
113
// Try to read item through port
114
GetVariableIn
(
PORT_ITEM_IN
, item);
115
if
(item)
116
return
item;
117
118
// Item wasn't provided through port, find it in our inventory
119
if
(m_eItemType != 0)
120
{
121
SCR_HoldableItemPredicate predicate =
new
SCR_HoldableItemPredicate();
122
predicate.wanted = m_eItemType;
123
item =
m_InventoryMgr
.FindItem(predicate);
124
}
125
else
126
{
127
item =
m_GadgetManager
.GetGadgetByType(m_eGadgetType);
128
}
129
130
return
item;
131
}
132
133
//-----------------------------------------------------------------------------------------------
134
bool
EquipInventoryItem
(
IEntity
item)
135
{
136
m_GadgetManager
.SetGadgetMode(item, EGadgetMode.IN_HAND);
137
//m_CharacterController.TakeGadgetInLeftHand(item, 1);
138
139
return
true
;
140
}
141
142
//-----------------------------------------------------------------------------------------------
143
bool
IsItemEquipped
(
IEntity
item)
144
{
145
if
(!item)
146
return
false
;
147
148
IEntity
itemAtSlot =
m_CharacterController
.GetAttachedGadgetAtLeftHandSlot();
149
150
return
itemAtSlot == item;
151
}
152
153
//-----------------------------------------------------------------------------------------------
154
protected
override
string
GetNodeMiddleText
()
155
{
156
if
(m_eItemType != 0)
157
return
string
.Format(
"Item type: %1"
,
typename
.EnumToString(
ECommonItemType
, m_eItemType));
158
else
159
return
string
.Format(
"Gadget type: %1"
,
typename
.EnumToString(EGadgetType, m_eGadgetType));
160
}
161
162
// -----------------------------------------------------------------------------------------------
163
protected
override
static
bool
VisibleInPalette
()
164
{
165
return
true
;
166
}
167
168
//-----------------------------------------------------------------------------------------------
169
protected
override
static
bool
CanReturnRunning
()
170
{
171
return
true
;
172
}
173
174
//-----------------------------------------------------------------------------------------------
175
protected
override
static
string
GetOnHoverDescription
()
176
{
177
return
"Equips inventory item, returns success when done and item ref."
;
178
}
179
};
ECommonItemType
ECommonItemType
Definition
InventoryConstants.c:31
AITaskScripted
Definition
AITaskScripted.c:13
IEntity
Definition
IEntity.c:13
Node
Definition
Node.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
Node::ClearVariable
proto void ClearVariable(string name)
SCR_AITakeGadgetInLeftHand
Definition
SCR_AITakeGadgetInLeftHand.c:2
SCR_AITakeGadgetInLeftHand::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AITakeGadgetInLeftHand.c:163
SCR_AITakeGadgetInLeftHand::EquipInventoryItem
bool EquipInventoryItem(IEntity item)
Definition
SCR_AITakeGadgetInLeftHand.c:134
SCR_AITakeGadgetInLeftHand::m_InventoryMgr
SCR_InventoryStorageManagerComponent m_InventoryMgr
Definition
SCR_AITakeGadgetInLeftHand.c:13
SCR_AITakeGadgetInLeftHand::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AITakeGadgetInLeftHand.c:43
SCR_AITakeGadgetInLeftHand::m_GadgetManager
SCR_GadgetManagerComponent m_GadgetManager
Definition
SCR_AITakeGadgetInLeftHand.c:14
SCR_AITakeGadgetInLeftHand::Reset
void Reset()
Definition
SCR_AITakeGadgetInLeftHand.c:95
SCR_AITakeGadgetInLeftHand::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AITakeGadgetInLeftHand.c:27
SCR_AITakeGadgetInLeftHand::TIMEOUT_S
const float TIMEOUT_S
Definition
SCR_AITakeGadgetInLeftHand.c:9
SCR_AITakeGadgetInLeftHand::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AITakeGadgetInLeftHand.c:34
SCR_AITakeGadgetInLeftHand::m_bWaiting
bool m_bWaiting
Definition
SCR_AITakeGadgetInLeftHand.c:17
SCR_AITakeGadgetInLeftHand::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AITakeGadgetInLeftHand.c:28
SCR_AITakeGadgetInLeftHand::PORT_ITEM_OUT
static const string PORT_ITEM_OUT
Definition
SCR_AITakeGadgetInLeftHand.c:24
SCR_AITakeGadgetInLeftHand::m_CharacterController
CharacterControllerComponent m_CharacterController
Definition
SCR_AITakeGadgetInLeftHand.c:12
SCR_AITakeGadgetInLeftHand::m_OwnerEntity
IEntity m_OwnerEntity
Definition
SCR_AITakeGadgetInLeftHand.c:11
SCR_AITakeGadgetInLeftHand::GetNodeMiddleText
override string GetNodeMiddleText()
Definition
SCR_AITakeGadgetInLeftHand.c:154
SCR_AITakeGadgetInLeftHand::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AITakeGadgetInLeftHand.c:31
SCR_AITakeGadgetInLeftHand::m_ItemEntity
IEntity m_ItemEntity
Definition
SCR_AITakeGadgetInLeftHand.c:16
SCR_AITakeGadgetInLeftHand::PORT_ITEM_IN
static const string PORT_ITEM_IN
Definition
SCR_AITakeGadgetInLeftHand.c:21
SCR_AITakeGadgetInLeftHand::FindItem
IEntity FindItem()
Definition
SCR_AITakeGadgetInLeftHand.c:109
SCR_AITakeGadgetInLeftHand::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AITakeGadgetInLeftHand.c:175
SCR_AITakeGadgetInLeftHand::OnAbort
override void OnAbort(AIAgent owner, Node nodeCausingAbort)
Definition
SCR_AITakeGadgetInLeftHand.c:103
SCR_AITakeGadgetInLeftHand::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AITakeGadgetInLeftHand.c:30
SCR_AITakeGadgetInLeftHand::m_fTimer_s
float m_fTimer_s
Definition
SCR_AITakeGadgetInLeftHand.c:18
SCR_AITakeGadgetInLeftHand::CanReturnRunning
static override bool CanReturnRunning()
Definition
SCR_AITakeGadgetInLeftHand.c:169
SCR_AITakeGadgetInLeftHand::IsItemEquipped
bool IsItemEquipped(IEntity item)
Definition
SCR_AITakeGadgetInLeftHand.c:143
SCR_GadgetManagerComponent
Definition
SCR_GadgetManagerComponent.c:140
SCR_GadgetManagerComponent::GetGadgetManager
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
Definition
SCR_GadgetManagerComponent.c:177
UIWidgets
Definition
attributes.c:40
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Soldier
SCR_AITakeGadgetInLeftHand.c
Generated by
1.17.0