Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDecoTimeSinceTargetDetected.c
Go to the documentation of this file.
1 // Script File//------------------------------------------------------------------------------------------------
2 class SCR_AIDecoTimeSinceTargetDetected : DecoratorScripted
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  float timeSinceDetected = ;
32  bool returnValue = timeSinceDetected < timeMax;
33 
34  return target.GetTimeSinceDetected() < timeMax;
35  }
36 
37  //-----------------------------------------------------------------------------------------------------
38  protected override bool VisibleInPalette()
39  {
40  return true;
41  }
42 
43  //-----------------------------------------------------------------------------------------------------
44  protected override string GetOnHoverDescription()
45  {
46  return "Checks time since target was detected and compares it with threshold. Returns true when time is below the threshold.";
47  }
48 
49  //-----------------------------------------------------------------------------------------------------
50  protected static ref TStringArray s_aVarsIn = {
51  BASE_TARGET_PORT
52  };
53  protected override TStringArray GetVariablesIn()
54  {
55  return s_aVarsIn;
56  }
57 };
BaseTarget
Definition: BaseTarget.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AIDecoTimeSinceTargetDetected
Definition: SCR_AIDecoTimeSinceTargetDetected.c:2