/** * this simply sums up all the active behaviors X their weights and * truncates the result to the max available steering force before * returning */ private Vector3 CalculateWeightedSum() { if (On(behaviour_type.wall_avoidance)) { steeringForce += WallAvoidance(m_entity.World().Walls()) * m_fWeightWallAvoidance; } if (On(behaviour_type.obstacle_avoidance)) { steeringForce += ObstacleAvoidance(m_entity.World().Obstacles()) * m_fWeightObstacleAvoidance; } if (On(behaviour_type.evade)) { Debug.Assert(m_pTargetAgent1 != null, "Evade target not assigned"); steeringForce += Evade(m_pTargetAgent1) * m_fWeightEvade; } //these next three can be combined for flocking behavior (wander is //also a good behavior to add into this mix) if (On(behaviour_type.separation)) { steeringForce += Separation(m_entity.GetAIGroup().Agents()) * m_fWeightSeparation; } if (On(behaviour_type.allignment)) { steeringForce += Alignment(m_entity.GetAIGroup().Agents()) * m_fWeightAlignment; } if (On(behaviour_type.cohesion)) { steeringForce += Cohesion(m_entity.GetAIGroup().Agents()) * m_fWeightCohesion; } if (On(behaviour_type.wander)) { steeringForce += Wander() * m_fWeightWander; } if (On(behaviour_type.seek)) { steeringForce += Seek(m_entity.VTarget()) * m_fWeightSeek; } if (On(behaviour_type.flee)) { steeringForce += Flee(m_entity.VTarget()) * m_fWeightFlee; } if (On(behaviour_type.arrive)) { steeringForce += Arrive(m_entity.VTarget(), m_deceleration) * m_fWeightArrive; } if (On(behaviour_type.pursuit)) { Debug.Assert(m_pTargetAgent1 != null, "pursuit target not assigned"); steeringForce += Pursuit(m_pTargetAgent1) * m_fWeightPursuit; } if (On(behaviour_type.offset_pursuit)) { Debug.Assert(m_pTargetAgent1 != null, "pursuit target not assigned"); Debug.Assert(m_vOffset.magnitude > 0, "No offset assigned"); //steeringForce += OffsetPursuit(m_pTargetAgent1, m_vOffset) * m_fWeightOffestPursuit; } if (On(behaviour_type.interpose)) { Debug.Assert(m_pTargetAgent1 != null && m_pTargetAgent2 != null, "Interpose agents not assigned"); steeringForce += Interpose(m_pTargetAgent1, m_pTargetAgent2) * m_fWeightInterpose; } if (On(behaviour_type.hide)) { Debug.Assert(m_pTargetAgent1 != null, "Hide target not assigned"); steeringForce += Hide(m_pTargetAgent1, m_entity.World().Obstacles()); } if (On(behaviour_type.follow_path)) { steeringForce += FollowPath() * m_fWeightFollowPath; } steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce()); return(steeringForce); }
/// <summary> /// /// </summary> /// <param name="agent"></param> public void RemoveAgent(AIAgent agent) { agent.GetAIGroup().RemoveAgent(agent); }