Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LoadSuppliesWaypoint.c
Go to the documentation of this file.
2{
3}
4
5class SCR_LoadSuppliesWaypoint : SCR_SuppliesTransferWaypoint
6{
7 [Attribute("0.5", desc: "Ratio of supplies fulfillment to consider load waypoint completed in a case of supply source being empty", params: "0 1 0.01")]
8 protected float m_fLoadFulfillmentThresholdWhenSourceEmpty;
9
10 //------------------------------------------------------------------------------------------------
12 float GetLoadFulfillmentThresholdWhenSourceEmpty()
13 {
14 return m_fLoadFulfillmentThresholdWhenSourceEmpty;
15 }
16
17 //------------------------------------------------------------------------------------------------
20 {
21 m_fLoadFulfillmentThresholdWhenSourceEmpty = Math.Clamp(value, 0, 1);
22 }
23
24 //------------------------------------------------------------------------------------------------
26 {
27 return new SCR_LoadSuppliesWaypointState(groupUtilityComp, this);
28 }
29}
30
31class SCR_LoadSuppliesWaypointState : SCR_SuppliesTransferWaypointState
32{
33 //------------------------------------------------------------------------------------------------
34 void SCR_LoadSuppliesWaypointState(notnull SCR_AIGroupUtilityComponent utility, SCR_AIWaypoint waypoint)
35 {
36 SCR_LoadSuppliesWaypoint wp = SCR_LoadSuppliesWaypoint.Cast(waypoint);
37 if (!wp)
38 return;
39
40 InitSupplyTransfer(utility, wp, EResourceGeneratorID.VEHICLE_LOAD, EResourceGeneratorID.DEFAULT, true);
41 }
42
43 //------------------------------------------------------------------------------------------------
44 protected void Load()
45 {
47 if (!gamemode || !gamemode.IsMaster())
48 return;
49
50 SCR_LoadSuppliesWaypoint wp = SCR_LoadSuppliesWaypoint.Cast(m_Waypoint);
51 if (!wp)
52 return;
53
55 return;
56
58 float maxResourceValue = container.GetMaxResourceValue();
59
60 SCR_ResourceConsumtionResponse response = m_ResourceConsumer.RequestAvailability(maxResourceValue);
61
63
65 {
66 SCR_ResourceComponent baseResourceComponent = m_Base.GetResourceComponent();
67 if (baseResourceComponent && s_OnAITransferedSupplies)
68 s_OnAITransferedSupplies.Invoke(EResourcePlayerInteractionType.VEHICLE_LOAD, m_ResourceComponent, baseResourceComponent, RESOURCE_TYPE, m_fCurrentTransferValue, m_Utility);
69
72 }
73
74 if (container.GetResourceValue() >= container.GetMaxResourceValue()
75 || (m_ResourceConsumer.GetAggregatedResourceValue() == 0 && container.GetResourceValue() >= container.GetMaxResourceValue() * wp.GetLoadFulfillmentThresholdWhenSourceEmpty()))
76 {
77 if (m_Utility && m_Utility.m_Owner)
78 m_Utility.m_Owner.CompleteWaypoint(m_Waypoint);
79
80 }
81 else
82 {
83 // Schedule the next supply load after a delay, unless the container is empty or the truck is full
84 GetGame().GetCallqueue().CallLater(Load, wp.GetTransferDelay() * 1000, false);
85 }
86 }
87
88 //------------------------------------------------------------------------------------------------
89 override void OnSelected()
90 {
91 super.OnSelected();
92 Load();
93 }
94}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_EAIActivityCause m_Utility
SCR_BaseGameMode GetGameMode()
void SetLoadFulfillmentThresholdWhenSourceEmpty(float value)
void SCR_ResourceConsumtionResponse(float availableResource=0, float resourceMultiplier=0, float range=0, EResourceReason reasonCode=EResourceReason.UNAVAILABLE)
EResourceGeneratorID
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ResourceComponent m_ResourceComponent
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)
Definition Math.c:13
SCR_AIWaypointState CreateWaypointState(SCR_AIGroupUtilityComponent groupUtilityComp)
sealed bool IsMaster()
SCR_FieldOfViewSettings Attribute