Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIBaseUtilityComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/AI", description: "Component for utility AI system calculations")]
3 {
4 }
5 
6 // TODO:
7 // - For handling orders, use enums
8 
9 class SCR_AIBaseUtilityComponent : AIBaseUtilityComponent
10 {
11  // This can be set externally to request a breakpoint on next EvaluateBehavior
12  #ifdef AI_DEBUG
13  protected bool m_bEvaluationBreakpoint;
14  protected int m_iDiagCounter = 0;
15  #endif
16 
17  //------------------------------------------------------------------------------------------------
21  void SendMessage(AIMessage msg, AIAgent receiver = null)
22  {
23  AICommunicationComponent commsComp = GetAIAgent().GetCommunicationComponent();
24  if (!commsComp)
25  return;
26 
27  commsComp.RequestBroadcast(msg, receiver);
28  }
29 
30  //------------------------------------------------------------------------------------------------
34  {
35  #ifdef AI_DEBUG
36  return m_iDiagCounter;
37  #else
38  return 0;
39  #endif
40  }
41 
42  //------------------------------------------------------------------------------------------------
45  {
46  #ifdef AI_DEBUG
47  m_iDiagCounter++;
48  #endif
49  }
50 
51  //------------------------------------------------------------------------------------------------
54  {
55  #ifdef AI_DEBUG
56  m_bEvaluationBreakpoint = true;
57  #endif
58  }
59 
60  #ifdef AI_DEBUG
61  //------------------------------------------------------------------------------------------------
62  protected void AddDebugMessage(string str, EAIDebugMsgType messageType = EAIDebugMsgType.UTILITY)
63  {
64  SCR_AIInfoBaseComponent infoComp = SCR_AIInfoBaseComponent.Cast(GetOwner().FindComponent(SCR_AIInfoBaseComponent));
65  infoComp.AddDebugMessage(str, msgType: messageType);
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  protected void DebugLogActionsPriority()
70  {
71  array<ref AIActionBase> actions = {};
72  GetActions(actions);
73  foreach (AIActionBase action : actions)
74  {
75  string actionStr = GetActionLogString(action);
76  AddDebugMessage(actionStr);
77 
79  if (parallelAction)
80  {
81  array<AIActionBase> subactions = {};
82  parallelAction.GetSubactions(subactions);
83  foreach (AIActionBase subaction : subactions)
84  {
85  string subactionStr = " " + GetActionLogString(subaction);
86  AddDebugMessage(subactionStr);
87  }
88  }
89 
90  }
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  protected string GetActionLogString(AIActionBase action)
95  {
96  SCR_AIActionBase scrActionBase = SCR_AIActionBase.Cast(action);
97 
98  string _strSuspended = string.Empty;
99  if (action.GetActionIsSuspended())
100  _strSuspended = "(S) ";
101  float score = action.Evaluate() + action.EvaluatePriorityLevel();
102 
103  string _strDebugInfo;
104  if (scrActionBase)
105  _strDebugInfo = scrActionBase.GetActionDebugInfo();
106 
107  return string.Format(" %1%2 %3 %4", _strSuspended, score.ToString(3, 1), action.Type().ToString(), _strDebugInfo);
108  }
109 
110  #endif
111 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_AIBaseUtilityComponentClass
Definition: SCR_AIBaseUtilityComponent.c:2
EAIDebugMsgType
EAIDebugMsgType
Definition: SCR_AIDebugMessage.c:1
SCR_AIActionBase
Definition: SCR_AIAction.c:1
DiagSetBreakpoint
void DiagSetBreakpoint()
Definition: SCR_AIBaseUtilityComponent.c:53
AIActionBase
Definition: AIActionBase.c:12
GetActions
int GetActions(out notnull array< SCR_BaseEditorAction > actions)
Definition: SCR_BaseActionsEditorComponent.c:168
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SendMessage
SCR_AIBaseUtilityComponentClass AIBaseUtilityComponentClass SendMessage(AIMessage msg, AIAgent receiver=null)
Definition: SCR_AIBaseUtilityComponent.c:21
DiagGetCounter
int DiagGetCounter()
Definition: SCR_AIBaseUtilityComponent.c:33
SCR_AICompositeActionParallel
Definition: SCR_AICompositeActionParallel.c:1
AIBaseUtilityComponentClass
Definition: AIBaseUtilityComponent.c:12
DiagIncreaseCounter
void DiagIncreaseCounter()
Definition: SCR_AIBaseUtilityComponent.c:44
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180