Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_UnloadSuppliesWaypoint.c
Go to the documentation of this file.
2{
3}
4
5class SCR_UnloadSuppliesWaypoint : SCR_SuppliesTransferWaypoint
6{
7 //------------------------------------------------------------------------------------------------
9 {
10 return new SCR_UnloadSuppliesWaypointState(groupUtilityComp, this);
11 }
12}
13
14class SCR_UnloadSuppliesWaypointState : SCR_SuppliesTransferWaypointState
15{
16 //------------------------------------------------------------------------------------------------
17 void SCR_UnloadSuppliesWaypointState(notnull SCR_AIGroupUtilityComponent utility, SCR_AIWaypoint waypoint)
18 {
19 SCR_UnloadSuppliesWaypoint wp = SCR_UnloadSuppliesWaypoint.Cast(waypoint);
20 if (!wp)
21 return;
22
23 InitSupplyTransfer(utility, wp, EResourceGeneratorID.DEFAULT, EResourceGeneratorID.VEHICLE_UNLOAD, false);
24 }
25
26 //------------------------------------------------------------------------------------------------
27 protected void Unload()
28 {
30 if (!gamemode || !gamemode.IsMaster())
31 return;
32
33 SCR_UnloadSuppliesWaypoint wp = SCR_UnloadSuppliesWaypoint.Cast(m_Waypoint);
34 if (!wp)
35 return;
36
38 {
39 Print("Missing resource generator, consumer or component!", LogLevel.WARNING);
40 if (m_Utility && m_Utility.m_Owner)
41 m_Utility.OnMoveFailed(EMoveError.UNKNOWN, GetVehicleFromGroupLeader(m_Utility), true, m_Utility.m_Owner.GetOrigin());
42
43 return;
44 }
45
47 float maxResourceValue = container.GetMaxResourceValue();
48
49 SCR_ResourceGenerationResponse response = m_ResourceGenerator.RequestAvailability(maxResourceValue);
50
52
55
56 SCR_ResourceComponent baseResourceComponent = m_Base.GetResourceComponent();
57 if (baseResourceComponent && s_OnAITransferedSupplies)
58 s_OnAITransferedSupplies.Invoke(EResourcePlayerInteractionType.VEHICLE_UNLOAD, baseResourceComponent, m_ResourceComponent, RESOURCE_TYPE, m_fCurrentTransferValue, m_Utility);
59
60 bool isStorageFull = (m_ResourceGenerator.GetAggregatedMaxResourceValue() - m_ResourceGenerator.GetAggregatedResourceValue()) <= 0;
61 if (isStorageFull || container.GetResourceValue() == 0)
62 {
63 if (m_Utility && m_Utility.m_Owner)
64 m_Utility.m_Owner.CompleteWaypoint(m_Waypoint);
65
66 }
67 else
68 {
69 // Schedule the next supply unload after a delay, unless the container is full or the truck empty
70 GetGame().GetCallqueue().CallLater(Unload, wp.GetTransferDelay() * 1000, false);
71 }
72 }
73
74 //------------------------------------------------------------------------------------------------
75 override void OnSelected()
76 {
77 super.OnSelected();
78
79 Unload();
80 }
81}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_EAIActivityCause m_Utility
SCR_BaseGameMode GetGameMode()
EResourceGeneratorID
SCR_ResourceComponent m_ResourceComponent
IEntity GetVehicleFromGroupLeader(notnull SCR_AIGroupUtilityComponent utility)
float m_fCurrentResource
SCR_SuppliesTransferWaypoint RESOURCE_TYPE
SCR_CampaignMilitaryBaseComponent m_Base
float m_fCurrentTransferValue
float m_fMaxStoredResource
SCR_ResourceConsumer m_ResourceConsumer
SCR_ResourceGenerator m_ResourceGenerator
void InitSupplyTransfer(notnull SCR_AIGroupUtilityComponent utility, SCR_SuppliesTransferWaypoint wp, EResourceGeneratorID generatorId, EResourceGeneratorID consumerId, bool isLoad)
void GetResourceValues(out float currentResource, out float maxResource, out float transferAmount)
SCR_AIWaypointState CreateWaypointState(SCR_AIGroupUtilityComponent groupUtilityComp)
sealed bool IsMaster()
EMoveError
Definition EMoveError.c:13
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14