Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MailboxComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/AIComponent", description: "Scripted m_Mailbox component", icon: HYBRID_COMPONENT_ICON)]
5
6class SCR_MailboxComponent : AICommunicationComponent
7{
8 #ifdef AI_MAILBOX_OVERFLOW_DETECTION
9 protected int m_iMailboxOverflowCount = 0;
10 #endif
11
12 //------------------------------------------------------------------------------------------------
16 AIMessage ReadMessage(bool remove)
17 {
18 /*
19 // Disabled for now
20 #ifdef AI_MAILBOX_OVERFLOW_DETECTION
21 if (GetMessageCount() > 100 && m_iMailboxOverflowCount < 5)
22 {
23 LogMailboxStatistics(LogLevel.WARNING);
24 m_iMailboxOverflowCount++;
25 }
26 #endif
27 */
28
29 AIMessage msg = GetMessage(0);
30
31 if (msg && remove)
33
34 return msg;
35 }
36
37 //------------------------------------------------------------------------------------------------
40 AIOrder ReadOrder(bool remove)
41 {
42 AIOrder order = GetOrder(0);
43
44 if (order && remove)
45 RemoveOrder(0);
46
47 return order;
48 }
49
50 //------------------------------------------------------------------------------------------------
53 void LogMessageStatistics(LogLevel logLevel = LogLevel.NORMAL)
54 {
55 map<typename, int> msgTypeCount = new map<typename, int>();
56 int msgCount = GetMessageCount();
57 for (int i = 0; i < msgCount; i++)
58 {
59 AIMessage msg = GetMessage(i);
60 if (!msg)
61 continue;
62 typename msgFinalType = msg.Type();
63 int nMsgsOfType = msgTypeCount.Get(msgFinalType);
64 nMsgsOfType++;
65 msgTypeCount.Set(msgFinalType, nMsgsOfType);
66 }
67
68 Print(string.Format("SCR_MailboxComponent statistics: count: %1, %2, %3", GetMessageCount(), this, GetAIAgent()), logLevel);
69 foreach (typename t, int count : msgTypeCount)
70 {
71 Print(string.Format(" %1: %2", t, count), logLevel);
72 }
73 Print(string.Format(" Total: %1", GetMessageCount()), logLevel);
74 }
75
76 //------------------------------------------------------------------------------------------------
79 {
80 return IsActive();
81 }
82
83 #ifdef AI_DEBUG
84
85 //------------------------------------------------------------------------------------------------
88 void DebugLogBroadcastMessage(AIMessage message)
89 {
90 AIAgent agent = GetAIAgent();
91 SCR_AIMessageBase msgBase = SCR_AIMessageBase.Cast(message);
92
93 string debugTextBasic = string.Format("----> SendMessage: %1 --> %2:\n", agent, message.GetReceiver());
94
95 string debugText;
96 if (msgBase)
97 debugText = debugTextBasic + msgBase.GetDebugText();
98 else
99 debugText = debugTextBasic + string.Format("\t%1", message);
100
101 SCR_AIDebug.DebugLog(debugText);
102 AddDebugMessage(debugText);
103 }
104
105 //------------------------------------------------------------------------------------------------
108 void DebugLogOnReceived(AIMessage message)
109 {
110 AIAgent agent = GetAIAgent();
111
112 AIAgent sender = message.GetSender();
113
114 string debugTextBasic = string.Format("<---- RecvMessage: %1 <-- %2\n", agent, sender);
115
116 SCR_AIMessageBase msgBase = SCR_AIMessageBase.Cast(message);
117
118 string debugText;
119 if (msgBase)
120 debugText = debugTextBasic + msgBase.GetDebugText();
121 else
122 debugText = debugTextBasic + string.Format("\t%1", message);
123
124 SCR_AIDebug.DebugLog(debugText);
125 AddDebugMessage(debugText);
126 }
127
128 //--------------------------------------------------------------------------------------------
129 protected void AddDebugMessage(string str)
130 {
131 SCR_AIInfoBaseComponent infoComp = SCR_AIInfoBaseComponent.Cast(GetAIAgent().FindComponent(SCR_AIInfoBaseComponent));
132 infoComp.AddDebugMessage(str, msgType: EAIDebugMsgType.MAILBOX);
133 }
134 #endif // AI_DEBUG
135}
string message
EAIDebugMsgType
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
int GetOrder()
void LogMessageStatistics(LogLevel logLevel=LogLevel.NORMAL)
SCR_MailboxComponentClass AICommunicationComponentClass ReadMessage(bool remove)
AIOrder ReadOrder(bool remove)
bool IsCommunicationEnabled()
Base class for all messages related to AI.
Definition AIMessage.c:14
Specialized message to send orders between AI agents.
Definition AIOrder.c:14
Definition Types.c:486
proto external void RemoveMessage(int id)
proto external int GetMessageCount()
proto external AIMessage GetMessage(int id)
proto external void RemoveOrder(int id)
HYBRID_COMPONENT_ICON
Default icon for all components written in script that don't inherit ScriptComponent.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14