Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkEntityDistanceCondition.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Entity A")]
5 ref SCR_ScenarioFrameworkGet m_GetterA;
6
7 [Attribute(desc: "Entity B")]
8 ref SCR_ScenarioFrameworkGet m_GetterB;
9
10 [Attribute(defvalue: "0", desc: "Minimum distance between entities in metres (Inclusive).", params: "0 inf 0.1", precision: 1)]
11 float m_fMinDistance;
12
13 [Attribute(defvalue: "20", desc: "Maximum distance between entities in metres (Inclusive). -1 for infinity", params: "-1 inf 0.1", precision: 1)]
14 float m_fMaxDistance;
15
16 //------------------------------------------------------------------------------------------------
17 override bool Init(IEntity entity)
18 {
19 // Here you can debug specific Condition instance.
20 // This can be also adjusted during runtime via Debug Menu > ScenarioFramework > Condition Inspector
21 if (m_bDebug)
22 Print("[SCR_ScenarioFrameworkEntityDistanceCondition.Init] debug line (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.WARNING);
23
24 if (m_fMaxDistance < 0)
25 m_fMaxDistance = float.INFINITY;
26 if (m_fMinDistance > m_fMaxDistance)
27 {
28 Print(string.Format("ScenarioFramework Condition: Min distance %1 is larger than max distance %2. If you intended to exclude a range, then use the OR operator on two distance conditions instead.", m_fMinDistance, m_fMaxDistance, this), LogLevel.WARNING);
29 return false;
30 }
31
32 if (!m_GetterA || !m_GetterB)
33 return false;
34
35 SCR_ScenarioFrameworkParam<IEntity> entityWrapperA = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_GetterA.Get());
36 if (!entityWrapperA)
37 {
38 Print(string.Format("ScenarioFramework Condition: Entity A not found for condition %1.", this), LogLevel.ERROR);
39 return false;
40 }
41
42 SCR_ScenarioFrameworkParam<IEntity> entityWrapperB = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_GetterB.Get());
43 if (!entityWrapperB)
44 {
45 Print(string.Format("ScenarioFramework Condition: Entity B not found for condition %1.", this), LogLevel.ERROR);
46 return false;
47 }
48
49 IEntity wrappedEntityA = entityWrapperA.GetValue();
50 if (!wrappedEntityA)
51 {
52 Print(string.Format("ScenarioFramework Condition: Entity A not found for condition %1.", this), LogLevel.ERROR);
53 return false;
54 }
55
56 IEntity wrappedEntityB = entityWrapperB.GetValue();
57 if (!wrappedEntityB)
58 {
59 Print(string.Format("ScenarioFramework Condition: Entity B not found for condition %1.", this), LogLevel.ERROR);
60 return false;
61 }
62
63 float distance = vector.Distance(wrappedEntityA.GetOrigin(), wrappedEntityB.GetOrigin());
64 return distance >= m_fMinDistance && distance <= m_fMaxDistance;
65 }
66}
override void Init()
params precision
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
float distance
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external vector GetOrigin()
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
SCR_FieldOfViewSettings Attribute