Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResourceContainerStoreAction.c
Go to the documentation of this file.
1
3{
4 [Attribute(defvalue: EResourceType.SUPPLIES.ToString(), uiwidget: UIWidgets.ComboBox, desc: "Sets the type of Resource to be used.\nOnly a transaction matching Resource types can be successfully concluded.", enums: ParamEnumArray.FromEnum(EResourceType))]
6
7 //~protected static SCR_CharacterResourceRequesterComponent s_CharacterResourceRequester;
9 protected SCR_ResourceConsumer m_ResourceConsumer;
10 protected float m_fMaxStoredResource;
11 protected float m_fCurrentResource;
12
13 //------------------------------------------------------------------------------------------------
14 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
15 {
17
18 if (!gamemode || !gamemode.IsMaster())
19 return;
20
21 m_fCurrentResource = m_ResourceConsumer.GetAggregatedResourceValue();
22 m_fMaxStoredResource = Math.Min(m_ResourceGenerator.GetAggregatedMaxResourceValue() - m_ResourceGenerator.GetAggregatedResourceValue(), m_fCurrentResource);
23
26
27 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
28 PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
29
30 if (!playerController)
31 return;
32
34
35 if (!resourcePlayerControllerComponent)
36 return;
37
38 resourcePlayerControllerComponent.OnPlayerInteraction(EResourcePlayerInteractionType.STORAGE, m_ResourceConsumer.GetComponent(), m_ResourceGenerator.GetComponent(), m_eResourceType, m_fMaxStoredResource);
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override bool GetActionNameScript(out string outName)
43 {
44 /*
45 if (m_fMaxStoredResource > 0 && m_fMaxStoredResource < m_fCurrentResource)
46 outName = string.Format("Store %1/%2 resources", m_fMaxStoredResource, m_fCurrentResource);
47 else
48 outName = string.Format("Store %1 resources", m_fMaxStoredResource);
49
50 return true;
51 */
52
55 else
56 outName = WidgetManager.Translate(GetUIInfo().GetDescription(), m_fMaxStoredResource);
57
58 return true;
59
60 }
61
62 //------------------------------------------------------------------------------------------------
63 override event bool CanBePerformedScript(IEntity user)
64 {
65 SCR_ResourceComponent component = SCR_ResourceComponent.Cast(GetOwner().FindComponent(SCR_ResourceComponent));
66
67 if (!component)
68 return false;
69
70 m_ResourceGenerator = component.GetGenerator(EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);
71 m_ResourceConsumer = component.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);
72
74 {
75 SetCannotPerformReason(WidgetManager.Translate("#AR-Supplies_CannotPerform_Generic"));
76
77 return false;
78 }
79
80 m_fCurrentResource = m_ResourceConsumer.GetAggregatedResourceValue();
81 m_fMaxStoredResource = Math.Min(m_ResourceGenerator.GetAggregatedMaxResourceValue() - m_ResourceGenerator.GetAggregatedResourceValue(), m_fCurrentResource);
82
83 if (m_ResourceGenerator.GetContainerCount() == 0)
84 SetCannotPerformReason("#AR-Supplies_CannotPerform_Container_NoStorage");
85 else if (m_fMaxStoredResource == 0.0)
86 SetCannotPerformReason("#AR-Supplies_CannotPerform_Container_StorageFull");
87
89 }
90
91 //------------------------------------------------------------------------------------------------
92 override event void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
93 {
94 SCR_ResourceComponent component = SCR_ResourceComponent.Cast(pOwnerEntity.FindComponent(SCR_ResourceComponent));
95
96 if (!component)
97 return;
98
99 m_ResourceGenerator = component.GetGenerator(EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);
100 m_ResourceConsumer = component.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);
101 }
102}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
EResourceGeneratorID
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
sealed bool IsMaster()
TODO MARIO: Rework this class to work with multiple containers!!.
override bool GetActionNameScript(out string outName)
override event bool CanBePerformedScript(IEntity user)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override event void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
void OnPlayerInteraction(EResourcePlayerInteractionType interactionType, SCR_ResourceComponent resourceComponentFrom, SCR_ResourceComponent resourceComponentTo, EResourceType resourceType, float resourceValue, bool shouldBroadcast=true)
SCR_FieldOfViewSettings Attribute