3 [
Attribute(
"1", UIWidgets.EditBox,
"Max time since target was last seen",
"")]
4 float m_fTimeSinceSeenMax_S;
6 [
Attribute(
"1", UIWidgets.EditBox,
"Max time since target was last detected",
"")]
7 float m_fTimeSinceDetectedMax_S;
9 protected static const string PORT_BASE_TARGET =
"BaseTarget";
11 protected PerceptionComponent m_PerceptionComp;
12 protected SCR_AIConfigComponent m_ConfigComp;
19 override void OnInit(AIAgent owner)
25 m_PerceptionComp = PerceptionComponent.Cast(ent.FindComponent(PerceptionComponent));
26 m_ConfigComp = SCR_AIConfigComponent.Cast(owner.FindComponent(SCR_AIConfigComponent));
30 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
32 if (!m_ConfigComp || !m_ConfigComp.m_EnablePerception || !m_PerceptionComp)
33 return ENodeResult.FAIL;
37 float updateInterval = m_PerceptionComp.GetUpdateInterval();
38 float timeSinceSeenMax = Math.Max(m_fTimeSinceSeenMax_S, updateInterval) + 0.02;
39 float timeSinceDetectedMax = Math.Max(m_fTimeSinceDetectedMax_S, updateInterval) + 0.02;
42 outTarget = m_PerceptionComp.GetClosestTarget(
ETargetCategory.DETECTED, timeSinceSeenMax, timeSinceDetectedMax);
51 outTarget = m_PerceptionComp.GetClosestTarget(
ETargetCategory.ENEMY, timeSinceSeenMax, timeSinceDetectedMax);
60 if (outTarget && outTarget.IsDisarmed())
63 SetVariableOut(PORT_BASE_TARGET, outTarget);
66 if (outTarget && DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_AI_SHOW_TARGET_LASTSEEN))
68 m_Shape = Shape.CreateSphere(COLOR_BLUE_A, ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER|ShapeFlags.TRANSP, outTarget.GetLastSeenPosition(), 0.1);
73 return ENodeResult.SUCCESS;
75 return ENodeResult.FAIL;
79 protected static ref TStringArray s_aVarsOut = {
82 override TStringArray GetVariablesOut()
87 override bool VisibleInPalette()