Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkResourceCondition.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Entity to check.")]
5 ref SCR_ScenarioFrameworkGet m_Getter;
6
7 [Attribute(defvalue: "EResourceType.INVALID.ToString()", desc: "Resource Type", uiwidget: UIWidgets.ComboBox, enumType: EResourceType)]
8 EResourceType m_eResourceType;
9
10 [Attribute(desc: "Required resource related conditions.")]
11 ref array<ref SCR_ScenarioFrameworkResourceConditionBase> m_aRequiredResourceConditions;
12
13 //------------------------------------------------------------------------------------------------
14 override bool Init(IEntity entity)
15 {
16 // Here you can debug specific Condition instance.
17 // This can be also adjusted during runtime via Debug Menu > ScenarioFramework > Condition Inspector
18 if (m_bDebug)
19 Print("[SCR_ScenarioFrameworkResourceCondition.Init] Condition invoked with debug flag (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.WARNING);
20
21 if (!m_Getter)
22 return false;
23
24 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
25 if (!entityWrapper)
26 {
27 SCR_ScenarioFrameworkParam<array<IEntity>> entityArrayWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_Getter.Get());
28 if (!entityArrayWrapper)
29 {
30 PrintFormat("ScenarioFramework Condition: Issue with Getter detected for condition %1.", this, level: LogLevel.ERROR);
31 return false;
32 }
33
34 array<IEntity> entities = entityArrayWrapper.GetValue();
35
36 if (entities.IsEmpty())
37 {
38 PrintFormat("ScenarioFramework Condition: Array Getter for %1 has no elements to work with.", this, level: LogLevel.ERROR);
39 return false;
40 }
41
42 foreach (IEntity ent : entities)
43 {
44 if (!EvaluateResourceConditions(ent))
45 return false;
46 }
47
48 return true;
49 }
50
51 IEntity wrappedEntity = entityWrapper.GetValue();
52 if (!wrappedEntity)
53 {
54 Print(string.Format("ScenarioFramework Condition: Entity not found for condition %1.", this), LogLevel.ERROR);
55 return false;
56 }
57
58 return EvaluateResourceConditions(wrappedEntity);
59 }
60
61 //------------------------------------------------------------------------------------------------
62 bool EvaluateResourceConditions(notnull IEntity ent)
63 {
64 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(ent.FindComponent(SCR_ResourceComponent));
65 if (!resourceComponent)
66 return false;
67
68 foreach (SCR_ScenarioFrameworkResourceConditionBase requiredCondition : m_aRequiredResourceConditions)
69 {
70 if (!requiredCondition.Init(ent, resourceComponent, m_eResourceType))
71 return false;
72 }
73 return true;
74 }
75}
override void Init()
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
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
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