4     TextWidget m_wBehavior;
 
   15     SCR_AIUtilityComponent m_UtilityComponent;
 
   16     SCR_AICombatComponent m_CombatComponent;
 
   17     SCR_AIInfoComponent m_InfoComponent;
 
   18     CameraManager m_CameraManager;
 
   20     const float OFFSET_X = 60;
 
   21     const float OFFSET_Y = 0;
 
   24     override void HandlerAttached(Widget w)
 
   28         Widget parent = w.FindAnyWidget(
"Behavior");
 
   30             m_wBehavior = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   32         parent = w.FindAnyWidget(
"Order");
 
   34             m_wOrder = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   36         parent = w.FindAnyWidget(
"Target");
 
   38             m_wTarget = TextWidget.Cast(parent.FindAnyWidget(
"Value"));     
 
   40         parent = w.FindAnyWidget(
"Threat");
 
   42             m_wThreat = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   44         parent = w.FindAnyWidget(
"BehaviorTable");
 
   46             m_wTable = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   48         parent = w.FindAnyWidget(
"CombatComponent");
 
   50             m_wCombat = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   52         parent = w.FindAnyWidget(
"AIInfoComponent");
 
   54             m_wAIInfo = TextWidget.Cast(parent.FindAnyWidget(
"Value"));
 
   61     void SelectAIAsFixed()
 
   65             m_FixedAI = m_TargetAI;
 
   73             m_CameraManager = 
GetGame().GetCameraManager();
 
   75         if (!m_CameraManager || !
m_wRoot)
 
   78         m_Camera = m_CameraManager.CurrentCamera();
 
   82         IEntity target = 
m_Camera.GetCursorTarget();
 
   87         if ((!m_TargetAI || m_TargetAI != target || !m_UtilityComponent) && !m_FixedAI)
 
   89             ChimeraCharacter character = ChimeraCharacter.Cast(target);
 
   96             AIControlComponent comp = AIControlComponent.Cast(character.FindComponent(AIControlComponent));
 
  109             m_UtilityComponent = SCR_AIUtilityComponent.Cast(agent.FindComponent(SCR_AIUtilityComponent));
 
  110             if (!m_UtilityComponent)
 
  116             m_CombatComponent = SCR_AICombatComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_AICombatComponent));
 
  123             m_InfoComponent = agent.m_InfoComponent;
 
  124             if (!m_InfoComponent)
 
  134         if (!m_UtilityComponent)
 
  143         vector boundMin, boundMax;
 
  144         target.GetWorldBounds(boundMin, boundMax);
 
  145         vector entityCenter = (boundMax + boundMin) * 0.5;
 
  147         vector pos = 
GetGame().GetWorkspace().ProjWorldToScreen(entityCenter, target.GetWorld());
 
  149             FrameSlot.SetPos(
m_wRoot.GetChildren(), pos[0] + OFFSET_X, pos[1]);
 
  151             FrameSlot.SetPos(
m_wRoot.GetChildren(), 0, 60); 
 
  153         if (m_wBehavior && m_UtilityComponent.m_CurrentBehavior)
 
  155             typename type = m_UtilityComponent.m_CurrentBehavior.Type();
 
  156             m_wBehavior.SetText(
type.ToString());
 
  169         if (m_wThreat && m_UtilityComponent.m_ThreatSystem != 
null)
 
  172             m_UtilityComponent.m_ThreatSystem.DebugPrintToWidget(m_wThreat);
 
  177             array<string> results = GetSortedBehaviors();
 
  179             int resultsCount = results.Count();
 
  180             for (
int i = 0; i < resultsCount; i++)
 
  182                 finalString = finalString + results[i];
 
  183                 if (i + 1 < resultsCount)
 
  184                     finalString = finalString + 
"\n";
 
  186             m_wTable.SetText(finalString);
 
  196             m_InfoComponent.DebugPrintToWidget(m_wAIInfo);
 
  203     ref array<string> GetSortedBehaviors()
 
  205         array<string> results = {};
 
  206         array<ref AIActionBase> actions = {};
 
  208         m_UtilityComponent.GetActions(actions);
 
  213         while (!actions.IsEmpty())
 
  215             highScore = -
float.MAX;
 
  219                 float score = action.Evaluate();
 
  220                 if (score > highScore)
 
  227             resultString = actions[highIndex].Type().ToString() + 
"   " + Math.Round(highScore);
 
  228             results.Insert(resultString);
 
  230             actions.RemoveOrdered(highIndex);