Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIDecoTimeSinceTargetDetected.c
Go to the documentation of this file.
1// Script File//------------------------------------------------------------------------------------------------
3{
4 static const string BASE_TARGET_PORT = "BaseTargetIn";
5
6 [Attribute("0.5", UIWidgets.EditBox, "Threshold time since target was detected", "")]
7 float m_TimeThreshold_S;
8
9 PerceptionComponent m_PerceptionComp;
10
11 //-----------------------------------------------------------------------------------------------------
12 protected override bool TestFunction(AIAgent owner)
13 {
14 if (!m_PerceptionComp)
15 m_PerceptionComp = PerceptionComponent.Cast(owner.GetControlledEntity().FindComponent(PerceptionComponent));
16
17 BaseTarget target;
18 GetVariableIn(BASE_TARGET_PORT,target);
19
20 if (!target || !m_PerceptionComp)
21 {
22 return false;
23 }
24
25 // When m_TimeThreshold_S value is lower than perception component update interval,
26 // which might be large at higher LOD levels, the decorator might periodically return false,
27 // even when target is still visible.
28 // Therefore we must prevent the threshold from being smaller than update interval of perception component.
29 float timeMax = Math.Max(m_TimeThreshold_S, m_PerceptionComp.GetUpdateInterval()) + 0.02;
30
31 return target.GetTimeSinceDetected() < timeMax;
32 }
33
34 //-----------------------------------------------------------------------------------------------------
35 protected static override bool VisibleInPalette()
36 {
37 return true;
38 }
39
40 //-----------------------------------------------------------------------------------------------------
41 protected static override string GetOnHoverDescription()
42 {
43 return "Checks time since target was detected and compares it with threshold. Returns true when time is below the threshold.";
44 }
45
46 //-----------------------------------------------------------------------------------------------------
47 protected static ref TStringArray s_aVarsIn = {
48 BASE_TARGET_PORT
49 };
50 protected override TStringArray GetVariablesIn()
51 {
52 return s_aVarsIn;
53 }
54};
Definition Math.c:13
proto bool GetVariableIn(string name, out void val)
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385