// On agent detected, check if the agent is // executing same action. If it does, check // is it closer to target and abort and re-plan // otherwise continue private void OnAgentDetected(GameObject agent) { if (target != null && agent != null) { GoapAgent gaOther = agent.GetComponent <GoapAgent>(); if (gaOther != null && gaOther.GetCurrentAction().Equals(ActionName)) { CompareDistanceToTarget(agent); } } }
private void PrintTeam(List <Agent> team) { if (team.Count > 0) { foreach (AIAgent agent in team) { if (agent != null) { GoapAgent goapAgent = agent.gameObject.GetComponent <GoapAgent>(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (goapAgent != null) { if (IsSelected(agent.gameObject)) { GUILayout.Label("Agent Name: " + goapAgent.name, selectedText); } else { GUILayout.Label("Agent Name: " + goapAgent.name); } GUILayout.Label(" Plan: " + goapAgent.CurrentPlanTextual); GUILayout.Label(" State: " + goapAgent.State.ToString()); GUILayout.Label(" Action: " + goapAgent.GetCurrentAction()); GUILayout.Label(" Health: " + agent.Inventory.Health.Amount.ToString()); GUILayout.Label(" Ammo: " + agent.Inventory.Ammo.Amount.ToString()); GUILayout.Label(" Agent Internal State: "); PrintWorldState(agent.Memory?.GetWorldState()); } EditorGUILayout.EndVertical(); } } } else { EditorGUILayout.LabelField("No team members"); } }