Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIInfoBaseComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(visible: false)]
2 class SCR_AIInfoBaseComponentClass : ScriptComponentClass
3 {
4 }
5 
7 class SCR_AIInfoBaseComponent : ScriptComponent
8 {
9  // Debug history
10  #ifdef AI_DEBUG
11  ref array<ref SCR_AIDebugMessage> m_aDebugMessages = {};
12 
13  //------------------------------------------------------------------------------------------------
18  void AddDebugMessage(string str, EAIDebugMsgType msgType = EAIDebugMsgType.NONE, LogLevel logLevel = LogLevel.NORMAL)
19  {
20  SCR_AIDebugMessage msg = new SCR_AIDebugMessage(str, msgType, logLevel);
21  AddDebugMessageObject(msg);
22  }
23 
24  //------------------------------------------------------------------------------------------------
27  void AddDebugMessageObject(SCR_AIDebugMessage msg)
28  {
29  m_aDebugMessages.Insert(msg);
30  }
31 
32  //------------------------------------------------------------------------------------------------
37  void DumpDebugMessages(EAIDebugMsgType msgTypeFilter = EAIDebugMsgType.NONE, bool useTypeFilter = false, int ageThresholdMs = -1)
38  {
39  int idStart = 0;
40 
41  // If age threshold is provided, find from which message to start logging
42  if (ageThresholdMs != -1)
43  {
44  idStart = -1;
45  int timestampMsThreshold = System.GetTickCount() - ageThresholdMs;
46  for (int i = m_aDebugMessages.Count() - 1; i >= 0; i--)
47  {
48  if (m_aDebugMessages[i].m_TimestampMs >= timestampMsThreshold)
49  idStart = i;
50  else
51  break;
52  }
53  }
54 
55  // Log messages
56  const string strLine = "----------------------------------------------------------------------------------";
57 
58  LogToFile("\n\n\n\n");
59  LogToFile(strLine);
60  LogToFile(string.Format("Debug Message Dump for %1", GetOwner()));
61  if (ageThresholdMs != -1)
62  LogToFile(string.Format("Logging messages for past %1 milliseconds", ageThresholdMs));
63 
64  int msgCount = m_aDebugMessages.Count();
65  for (int i = idStart; i < msgCount; i++)
66  {
67  SCR_AIDebugMessage msg = m_aDebugMessages[i];
68  if (msg.m_Type == msgTypeFilter || !useTypeFilter)
69  LogToFile(msg.FormatMessage(), msg.m_LogLevel);
70  }
71 
72  LogToFile("End Debug Message Dump");
73  LogToFile(strLine);
74  LogToFile("\n\n\n\n");
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  protected void LogToFile(string msg, LogLevel logLevel = LogLevel.NORMAL)
79  {
80  Print(msg, logLevel);
81  SCR_AIDebug.DebugLog(msg, logLevel);
82  }
83 
84  #endif // AI_DEBUG
85 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
EAIDebugMsgType
EAIDebugMsgType
Definition: SCR_AIDebugMessage.c:1
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
SCR_AIInfoBaseComponentClass
Definition: SCR_AIInfoBaseComponent.c:2
SCR_AIDebugMessage
Definition: SCR_AIDebugMessage.c:17
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_AIDebug
Game core which persists through whole game and stores various data for AI debugging.
Definition: SCR_AIDebug.c:3