Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkActionOnResourceChanged.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Target entity to manipulate supply (Optional if action is attached on Slot that spawns target entity)")]
5 ref SCR_ScenarioFrameworkGet m_Getter;
6
7 [Attribute(desc: "Actions that will be executed on compartment entered", UIWidgets.Auto)]
8 ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
9
10 [Attribute(defvalue: "0", desc: "Activation Percentage", params: "0 inf 0.01")]
11 float m_iActivationPercentage;
12
13 [Attribute(defvalue: "0", desc: "Operator", uiwidget: UIWidgets.ComboBox, enumType: SCR_EScenarioFrameworkComparisonOperator)]
14 SCR_EScenarioFrameworkComparisonOperator m_eComparisonOperator;
15
17
18 //------------------------------------------------------------------------------------------------
19 override void OnActivate(IEntity object)
20 {
21 if (!CanActivate())
22 return;
23
24 if (!ValidateInputEntity(object, m_Getter, m_SupplyHolderEntity))
25 return;
26
27 SCR_ResourceComponent resourceComponent;
28 SCR_ResourceContainer supplyContainer = GetContainer(m_SupplyHolderEntity, resourceComponent);
29 if (!supplyContainer)
30 {
31 if (object)
32 PrintFormat("ScenarioFramework Action: No resource container found for Action %1 attached on %2.", this, object.GetName(), level: LogLevel.ERROR);
33 else
34 PrintFormat("ScenarioFramework Action: No resource container Managers found for Action %1.", this, level: LogLevel.ERROR);
35
36 return;
37 }
38
39 supplyContainer.GetOnResourcesChanged().Insert(OnResourceChanged);
40 }
41
42 //------------------------------------------------------------------------------------------------
43 void OnResourceChanged(SCR_ResourceContainer container, float previousValue)
44 {
45 float current = (container.GetResourceValue() / container.GetMaxResourceValue()) * 100;
46
47 if (
48 ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_THAN) && (current < m_iActivationPercentage)) ||
49 ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_OR_EQUAL) && (current <= m_iActivationPercentage)) ||
50 ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.EQUAL) && (current == m_iActivationPercentage)) ||
51 ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_OR_EQUAL) && (current >= m_iActivationPercentage)) ||
52 ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_THEN) && (current > m_iActivationPercentage))
53 )
54 {
55 foreach (SCR_ScenarioFrameworkActionBase action : m_aActions)
56 {
57 action.Init(m_SupplyHolderEntity);
58 }
59 }
60 }
61
62 //------------------------------------------------------------------------------------------------
67 SCR_ResourceContainer GetContainer(notnull IEntity entity, out SCR_ResourceComponent component)
68 {
69 component = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
70 SCR_ResourceContainer container;
71
72 if (component)
73 {
74 container = component.GetContainer(EResourceType.SUPPLIES);
75 if (container)
76 return container;
77 }
78
79 IEntity iteratedEntity = entity.GetChildren();
80 while (iteratedEntity)
81 {
82 component = SCR_ResourceComponent.Cast(iteratedEntity.FindComponent(SCR_ResourceComponent));
83 if (component)
84 {
85 container = component.GetContainer(EResourceType.SUPPLIES);
86 if (container)
87 return container;
88 }
89
90 iteratedEntity = iteratedEntity.GetSibling();
91 }
92
93 return null;
94 }
95
96 //------------------------------------------------------------------------------------------------
97 override array<ref SCR_ScenarioFrameworkActionBase> GetSubActions()
98 {
99 return m_aActions;
100 }
101}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external IEntity GetChildren()
proto external IEntity GetSibling()
ScriptInvoker GetOnResourcesChanged()
SCR_ResourceContainer GetContainer(notnull IEntity entity, out SCR_ResourceComponent component)
void OnResourceChanged(SCR_ResourceContainer container, float previousValue)
override array< ref SCR_ScenarioFrameworkActionBase > GetSubActions()
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute