public void TagAIAgentWithinViewRange(AIAgent entity, float radius) { foreach (KeyValuePair <int, AIGroup> ai in m_aiGroup) { List <AIAgent> entities = ai.Value.Agents(); for (int i = 0; i < entities.Count; ++i) { AIAgent curEntity = entities[i]; //first clear any current tag curEntity.UnTagging(); Vector3 to = curEntity.VPos() - entity.VPos(); //the bounding radius of the other is taken into account by adding it //to the range float range = radius + curEntity.BRadius(); //if entity within range, tag for further consideration. (working in //distance-squared space to avoid sqrts) if ((curEntity.GetHashCode() != entity.GetHashCode()) && (to.sqrMagnitude < range * range)) { curEntity.Tagging(); } } } }
public void TagObstaclesWithinViewRange(AIAgent entity, float radius) { IEnumerator <AIObject> it = m_Obstacles.GetEnumerator(); while (it.MoveNext()) { AIObject curEntity = it.Current; //first clear any current tag curEntity.UnTagging(); Vector3 to = curEntity.VPos() - entity.VPos(); //the bounding radius of the other is taken into account by adding it //to the range float range = radius + curEntity.BRadius(); //if entity within range, tag for further consideration. (working in //distance-squared space to avoid sqrts) if ((curEntity.GetHashCode() != entity.GetHashCode()) && (to.sqrMagnitude < range * range)) { curEntity.Tagging(); } } }
/// <summary> /// /// </summary> /// <param name="agent"></param> public void AddAgent(AIAgent agent) { int idx = m_aiAgents.FindIndex(x => x.GetHashCode().Equals(agent.GetHashCode())); if (idx == -1) { m_aiAgents.Add(agent); agent.SetAIGroup(this); } }