12 protected ref array<ref SCR_AIMessageVisualization> m_aElements = {};
13 protected ref array<ref SCR_AIAgentDebugPanel> m_aPanels = {};
34 static void VisualizeMessage(IEntity entity,
string message,
EAIDebugCategory category,
float showTime, Color color = Color.White,
float fontSize = 16,
bool ignoreCategory =
false)
42 if (!inst || !entity || message ==
string.Empty)
46 color = Color.FromInt(Color.WHITE);
48 inst.RemoveVisualization(entity);
52 inst.m_aElements.Insert(visualization);
56 void ShowAiAgentDebugPanel(AIAgent agent, IEntity entity)
61 if ((p.m_Agent && p.m_Agent == agent) || (p.m_Entity && p.m_Entity == entity))
70 m_aPanels.Insert(newPanel);
74 protected void RemoveVisualization(IEntity entity)
81 if (vis.m_TargetEntity == entity)
91 override protected void EOnDiag(IEntity owner,
float timeSlice)
94 bool enabled = DiagMenu.GetValue(
SCR_DebugMenuID.DEBUGUI_AI_DEBUG_CATEGORY);
98 for (
int i = count - 1; i >=0; i--)
107 bool openDebugPanel = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_AI_OPEN_DEBUG_PANEL);
110 AIAgent selectedAgent;
111 IEntity selectedEntity;
113 if (GetSelectedAiAgentOrEntity(selectedAgent, selectedEntity))
114 ShowAiAgentDebugPanel(selectedAgent, selectedEntity);
116 Debug.Error(
"Nothing is selected! You must select something with Game Master first!");
121 int count = m_aPanels.Count();
122 for (
int i = count - 1; i >= 0; i--)
124 bool requestClose = m_aPanels[i].Update(timeSlice);
132 AIAgent selectedAgent;
133 IEntity selectedEntity;
134 GetSelectedAiAgentOrEntity(selectedAgent, selectedEntity);
137 AIBehaviorTreeComponent btComp = AIBehaviorTreeComponent.Cast(selectedAgent.FindComponent(AIBehaviorTreeComponent));
140 btComp.SetBtBreakpoint(
true);
144 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_AI_SET_BT_BREAKPOINT,
false);
148 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_AI_SHOW_PERCEPTION_PANEL))
150 ShowPerceptionPanel();
155 void ShowPerceptionPanel()
157 DbgUI.Begin(
"Perception Panel");
159 DbgUI.Text(
"Values for tuning perception properties");
162 BaseTimeAndWeatherManagerEntity twm = world.GetTimeAndWeatherManager();
165 DbgUI.Text(
"BaseTimeAndWeatherManagerEntity not found!");
172 twm.GetCurrentSunMoonDirAndPhase(sunDir, moonDir, moonPhase);
173 float sunElevDeg = Math.RAD2DEG * Math.Asin(-sunDir[1]);
174 float moonElevDeg = Math.RAD2DEG * Math.Asin(-moonDir[1]);
175 DbgUI.Text(
string.Format(
"Sun Elevation: %1 deg", sunElevDeg.ToString(5, 1)));
176 DbgUI.Text(
string.Format(
"Moon ElevatioN: %1 deg", moonElevDeg.ToString(5, 1)));
177 DbgUI.Text(
string.Format(
"Moon Phase: %1", moonPhase.ToString(4, 2)));
180 PerceptionManager pm =
GetGame().GetPerceptionManager();
183 DbgUI.Text(
"PerceptionManager not found!");
190 pm.GetAmbientLV(directLV, ambientLV, totalLV);
191 DbgUI.Text(
string.Format(
"Direct LV: %1, Ambient LV: %2, Total Ambient LV: %3", directLV, ambientLV, totalLV));
198 protected bool GetSelectedAiAgentOrEntity(out AIAgent outAgent, out IEntity outEntity)
202 set<SCR_EditableEntityComponent> selectedEntities =
new set<SCR_EditableEntityComponent>();
203 filter.GetEntities(selectedEntities);
205 if (selectedEntities.Count() == 0)
218 outAgent = AIAgent.Cast(editGroupComp.GetOwner());
225 SCR_EditableCharacterComponent editCharacterComp = SCR_EditableCharacterComponent.Cast(selectedEntities[0]);
226 if (editCharacterComp)
228 outAgent = editCharacterComp.GetAgent();
229 outEntity = outAgent.GetControlledEntity();
235 outEntity = selectedEntities[0].GetOwner();
244 SetEventMask(EntityEvent.FRAME);
245 ConnectToDiagSystem();
246 SetFlags(EntityFlags.ACTIVE,
true);
252 DisconnectFromDiagSystem();