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))]
9 protected SCR_ResourceConsumer m_ResourceConsumer;
10 protected float m_fMaxStoredResource;
11 protected float m_fCurrentResource;
14 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
18 if (!gamemode || !gamemode.IsMaster())
22 m_fMaxStoredResource = Math.Min(m_ResourceGenerator.GetAggregatedMaxResourceValue() - m_ResourceGenerator.GetAggregatedResourceValue(), m_fCurrentResource);
25 m_ResourceGenerator.RequestGeneration(m_fMaxStoredResource);
27 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
28 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
30 if (!playerController)
35 if (!resourcePlayerControllerComponent)
42 override bool GetActionNameScript(out
string outName)
53 if (m_fMaxStoredResource > 0 && m_fMaxStoredResource < m_fCurrentResource)
54 outName = WidgetManager.Translate(
GetUIInfo().
GetName(), m_fMaxStoredResource, m_fCurrentResource);
56 outName = WidgetManager.Translate(
GetUIInfo().GetDescription(), m_fMaxStoredResource);
63 override event bool CanBePerformedScript(IEntity user)
65 SCR_ResourceComponent component = SCR_ResourceComponent.Cast(
GetOwner().FindComponent(SCR_ResourceComponent));
70 m_ResourceGenerator = component.GetGenerator(
EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);
73 if (!m_ResourceGenerator || !m_ResourceConsumer)
75 SetCannotPerformReason(WidgetManager.Translate(
"#AR-Supplies_CannotPerform_Generic"));
81 m_fMaxStoredResource = Math.Min(m_ResourceGenerator.GetAggregatedMaxResourceValue() - m_ResourceGenerator.GetAggregatedResourceValue(), m_fCurrentResource);
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");
88 return m_fMaxStoredResource > 0.0 && m_fMaxStoredResource <= m_fCurrentResource;
92 override event void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
94 SCR_ResourceComponent component = SCR_ResourceComponent.Cast(pOwnerEntity.FindComponent(SCR_ResourceComponent));
99 m_ResourceGenerator = component.GetGenerator(
EResourceGeneratorID.DEFAULT_STORAGE, m_eResourceType);