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_SuppliesTransferWaypoint.c
Go to the documentation of this file.
1
class
SCR_SuppliesTransferWaypointClass
:
SCR_AIWaypointClass
2
{
3
}
4
5
//~ Supplies transfer invoker
6
void
ScriptInvokerAITransferSuppliesMethod
(
EResourcePlayerInteractionType
interactionType, SCR_ResourceComponent resourceComponentFrom, SCR_ResourceComponent resourceComponentTo,
EResourceType
resourceType,
float
resourceValue,
SCR_AIGroupUtilityComponent
utility);
7
typedef
func
ScriptInvokerAITransferSuppliesMethod
;
8
typedef
ScriptInvokerBase<ScriptInvokerAITransferSuppliesMethod>
ScriptInvokerAITransferSupplies
;
9
10
// Base class for supply transfer waypoints (shared logic)
11
class
SCR_SuppliesTransferWaypoint
:
SCR_AIWaypoint
12
{
13
[
Attribute
(
"2000"
,
desc
:
"How much supplies can transfer per operation"
,
params
:
"0 inf"
)]
14
protected
float
m_fTransferAmount
;
15
16
[
Attribute
(
"2"
,
desc
:
"Delay between operations [s]"
,
params
:
"0 inf"
)]
17
protected
float
m_fTransferDelay;
18
19
protected
SCR_CampaignMilitaryBaseComponent
m_Base
;
20
21
//------------------------------------------------------------------------------------------------
23
void
SetBase
(
SCR_CampaignMilitaryBaseComponent
base
)
24
{
25
m_Base
=
base
;
26
}
27
28
//------------------------------------------------------------------------------------------------
30
SCR_CampaignMilitaryBaseComponent
GetBase
()
31
{
32
return
m_Base
;
33
}
34
35
//------------------------------------------------------------------------------------------------
37
float
GetTransferAmount
()
38
{
39
return
m_fTransferAmount
;
40
}
41
42
//------------------------------------------------------------------------------------------------
44
float
GetTransferDelay
()
45
{
46
return
m_fTransferDelay;
47
}
48
}
49
50
// Base class for state functionality (shared logic)
51
class
SCR_SuppliesTransferWaypointState :
SCR_AIWaypointState
52
{
53
protected
const
EResourceType
RESOURCE_TYPE
=
EResourceType
.SUPPLIES;
54
55
protected
SCR_ResourceComponent
m_ResourceComponent
;
56
protected
SCR_ResourceGenerator
m_ResourceGenerator
;
57
protected
SCR_ResourceConsumer
m_ResourceConsumer
;
58
59
protected
float
m_fMaxStoredResource
;
60
protected
float
m_fCurrentResource
;
61
protected
float
m_fCurrentTransferValue
;
62
protected
float
m_fTransferAmount
;
63
64
protected
SCR_CampaignMilitaryBaseComponent
m_Base
;
65
66
protected
static
ref
ScriptInvokerAITransferSupplies
s_OnAITransferedSupplies;
67
68
//------------------------------------------------------------------------------------------------
69
protected
void
InitSupplyTransfer
(notnull
SCR_AIGroupUtilityComponent
utility,
SCR_SuppliesTransferWaypoint
wp,
EResourceGeneratorID
generatorId,
EResourceGeneratorID
consumerId,
bool
isLoad)
70
{
71
m_Base
= wp.
GetBase
();
72
if
(!
m_Base
)
73
m_Base
=
FindBase
(wp.GetOrigin());
74
75
if
(!
m_Base
)
76
return
;
77
78
SCR_ResourceComponent baseResourceComponent =
m_Base
.GetResourceComponent();
79
if
(!baseResourceComponent)
80
return
;
81
82
// For load operation: DEFAULT is consumer, VEHICLE_LOAD is generator
83
// For unload operation: VEHICLE_UNLOAD is consumer, DEFAULT is generator
84
if
(isLoad)
85
m_ResourceConsumer
= baseResourceComponent.GetConsumer(
EResourceGeneratorID
.DEFAULT,
RESOURCE_TYPE
);
86
else
87
m_ResourceGenerator
= baseResourceComponent.GetGenerator(
EResourceGeneratorID
.DEFAULT,
RESOURCE_TYPE
);
88
89
m_fTransferAmount
= wp.
GetTransferAmount
();
90
91
IEntity
vehicleEntity =
GetVehicleFromGroupLeader
(utility);
92
if
(!vehicleEntity)
93
{
94
Print
(
"The group leader is not in a vehicle."
,
LogLevel
.WARNING);
95
if
(
m_Utility
&&
m_Utility
.m_Owner)
96
m_Utility
.m_Owner.CompleteWaypoint(
m_Waypoint
);
97
98
return
;
99
}
100
101
m_ResourceComponent
= SCR_ResourceComponent.FindResourceComponent(vehicleEntity);
102
if
(!
m_ResourceComponent
)
103
return
;
104
105
if
(isLoad)
106
m_ResourceGenerator
=
m_ResourceComponent
.GetGenerator(
EResourceGeneratorID
.VEHICLE_LOAD,
RESOURCE_TYPE
);
107
else
108
m_ResourceConsumer
=
m_ResourceComponent
.GetConsumer(
EResourceGeneratorID
.VEHICLE_UNLOAD,
RESOURCE_TYPE
);
109
110
}
111
112
//------------------------------------------------------------------------------------------------
113
protected
SCR_CampaignMilitaryBaseComponent
FindBase
(
vector
position
)
114
{
115
SCR_MilitaryBaseSystem
militaryBaseSystem =
SCR_MilitaryBaseSystem
.
GetInstance
();
116
if
(!militaryBaseSystem)
117
return
null;
118
119
array<SCR_MilitaryBaseComponent> bases = {};
120
militaryBaseSystem.
GetBases
(bases);
121
122
SCR_CampaignMilitaryBaseComponent
campaignBase;
123
foreach
(SCR_MilitaryBaseComponent
base
: bases)
124
{
125
campaignBase =
SCR_CampaignMilitaryBaseComponent
.Cast(
base
);
126
if
(!campaignBase)
127
continue
;
128
129
int
radius = campaignBase.GetRadius();
130
if
(
vector
.DistanceSqXZ(campaignBase.GetOwner().GetOrigin(),
position
) <= (radius * radius))
131
{
132
return
campaignBase;
133
}
134
}
135
136
return
null;
137
}
138
139
//------------------------------------------------------------------------------------------------
140
protected
IEntity
GetVehicleFromGroupLeader
(notnull
SCR_AIGroupUtilityComponent
utility)
141
{
142
AIAgent aiAgent = utility.GetAIAgent();
143
AIGroup group = AIGroup.Cast(aiAgent);
144
if
(!group)
145
return
null;
146
147
AIAgent leaderAgent = group.GetLeaderAgent();
148
if
(!leaderAgent)
149
return
null;
150
151
ChimeraCharacter
character =
ChimeraCharacter
.Cast(leaderAgent.GetControlledEntity());
152
if
(!character)
153
return
null;
154
155
CompartmentAccessComponent compartment = character.GetCompartmentAccessComponent();
156
if
(!compartment)
157
return
null;
158
159
return
compartment.GetVehicleIn(character);
160
}
161
162
//------------------------------------------------------------------------------------------------
163
protected
void
GetResourceValues
(out
float
currentResource, out
float
maxResource, out
float
transferAmount)
164
{
165
if
(!
m_ResourceConsumer
|| !
m_ResourceGenerator
)
166
return
;
167
168
currentResource =
m_ResourceConsumer
.GetAggregatedResourceValue();
169
maxResource =
Math
.Min(
m_ResourceGenerator
.GetAggregatedMaxResourceValue() -
m_ResourceGenerator
.GetAggregatedResourceValue(), currentResource);
170
171
if
(
m_fTransferAmount <= 0 || m_fTransferAmount >
maxResource)
172
transferAmount = maxResource;
173
else
174
transferAmount =
m_fTransferAmount
;
175
}
176
177
//------------------------------------------------------------------------------------------------
178
static
ScriptInvokerAITransferSupplies
GetOnAITransferedSupplies()
179
{
180
if
(!s_OnAITransferedSupplies)
181
s_OnAITransferedSupplies =
new
ScriptInvokerAITransferSupplies
();
182
183
return
s_OnAITransferedSupplies;
184
}
185
}
m_Utility
enum SCR_EAIActivityCause m_Utility
func
func
Definition
SCR_AIThreatSystem.c:6
m_Waypoint
AIWaypoint m_Waypoint
Definition
SCR_AmbientPatrolSpawnPointComponent.c:48
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
base
around base
Definition
SCR_HoldCampaignMilitaryBaseTaskEntity.c:9
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
EResourceGeneratorID
EResourceGeneratorID
Definition
SCR_ResourceGenerator.c:2
EResourcePlayerInteractionType
EResourcePlayerInteractionType
Definition
SCR_ResourcePlayerControllerInventoryComponent.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
m_ResourceComponent
SCR_ResourceComponent m_ResourceComponent
Definition
SCR_SuppliesTransferWaypoint.c:55
GetVehicleFromGroupLeader
IEntity GetVehicleFromGroupLeader(notnull SCR_AIGroupUtilityComponent utility)
Definition
SCR_SuppliesTransferWaypoint.c:140
m_fCurrentResource
float m_fCurrentResource
Definition
SCR_SuppliesTransferWaypoint.c:60
RESOURCE_TYPE
SCR_SuppliesTransferWaypoint RESOURCE_TYPE
m_fTransferAmount
float m_fTransferAmount
Definition
SCR_SuppliesTransferWaypoint.c:62
m_Base
SCR_CampaignMilitaryBaseComponent m_Base
Definition
SCR_SuppliesTransferWaypoint.c:64
m_fCurrentTransferValue
float m_fCurrentTransferValue
Definition
SCR_SuppliesTransferWaypoint.c:61
m_fMaxStoredResource
float m_fMaxStoredResource
Definition
SCR_SuppliesTransferWaypoint.c:59
m_ResourceConsumer
SCR_ResourceConsumer m_ResourceConsumer
Definition
SCR_SuppliesTransferWaypoint.c:57
m_ResourceGenerator
SCR_ResourceGenerator m_ResourceGenerator
Definition
SCR_SuppliesTransferWaypoint.c:56
InitSupplyTransfer
void InitSupplyTransfer(notnull SCR_AIGroupUtilityComponent utility, SCR_SuppliesTransferWaypoint wp, EResourceGeneratorID generatorId, EResourceGeneratorID consumerId, bool isLoad)
Definition
SCR_SuppliesTransferWaypoint.c:69
FindBase
SCR_CampaignMilitaryBaseComponent FindBase(vector position)
Definition
SCR_SuppliesTransferWaypoint.c:113
GetResourceValues
void GetResourceValues(out float currentResource, out float maxResource, out float transferAmount)
Definition
SCR_SuppliesTransferWaypoint.c:163
ScriptInvokerAITransferSuppliesMethod
func ScriptInvokerAITransferSuppliesMethod
Definition
SCR_SuppliesTransferWaypoint.c:7
ScriptInvokerAITransferSupplies
ScriptInvokerBase< ScriptInvokerAITransferSuppliesMethod > ScriptInvokerAITransferSupplies
Definition
SCR_SuppliesTransferWaypoint.c:8
ChimeraCharacter
Definition
ChimeraCharacter.c:13
IEntity
Definition
IEntity.c:13
Math
Definition
Math.c:13
SCR_AIGroupUtilityComponent
Definition
SCR_AIGroupUtilityComponent.c:18
SCR_AIWaypointClass
Definition
SCR_AIWaypoint.c:2
SCR_AIWaypoint::SCR_AIWaypoint
void SCR_AIWaypoint(IEntitySource src, IEntity parent)
Definition
SCR_AIWaypoint.c:16
SCR_AIWaypointState
Definition
SCR_AIWaypointState.c:7
SCR_CampaignMilitaryBaseComponent
Definition
SCR_CampaignMilitaryBaseComponent.c:38
SCR_MilitaryBaseSystem
Definition
SCR_MilitaryBaseSystem.c:18
SCR_MilitaryBaseSystem::GetBases
int GetBases(notnull out array< SCR_MilitaryBaseComponent > bases)
Definition
SCR_MilitaryBaseSystem.c:330
SCR_MilitaryBaseSystem::GetInstance
static SCR_MilitaryBaseSystem GetInstance()
Definition
SCR_MilitaryBaseSystem.c:37
SCR_ResourceGenerator
Definition
SCR_ResourceGenerator.c:80
SCR_SuppliesTransferWaypointClass
Definition
SCR_SuppliesTransferWaypoint.c:2
SCR_SuppliesTransferWaypoint
Definition
SCR_SuppliesTransferWaypoint.c:12
SCR_SuppliesTransferWaypoint::GetBase
SCR_CampaignMilitaryBaseComponent GetBase()
Definition
SCR_SuppliesTransferWaypoint.c:30
SCR_SuppliesTransferWaypoint::GetTransferAmount
float GetTransferAmount()
Definition
SCR_SuppliesTransferWaypoint.c:37
SCR_SuppliesTransferWaypoint::m_Base
SCR_CampaignMilitaryBaseComponent m_Base
Definition
SCR_SuppliesTransferWaypoint.c:19
SCR_SuppliesTransferWaypoint::m_fTransferAmount
float m_fTransferAmount
Definition
SCR_SuppliesTransferWaypoint.c:14
SCR_SuppliesTransferWaypoint::GetTransferDelay
float GetTransferDelay()
Definition
SCR_SuppliesTransferWaypoint.c:44
SCR_SuppliesTransferWaypoint::SetBase
void SetBase(SCR_CampaignMilitaryBaseComponent base)
Set the base for supply operation, if not set will auto-discover.
Definition
SCR_SuppliesTransferWaypoint.c:23
vector
Definition
vector.c:13
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
AI
Group
SCR_SuppliesTransferWaypoint.c
Generated by
1.17.0