private ISteeringEntity GetNeighborAhead(ISteeringEntity baseEntity, float maxQueueAhead, float maxQueueRadius) { var qa = baseEntity.Velocity; if (qa != Vector2.Zero) { qa.Normalize(); } qa *= maxQueueAhead; var ahead = baseEntity.Position + qa; var entities = Core.Scene.Entities.EntitiesWithTag(123); foreach (var entity in entities) { var d = Vector2.Distance(ahead, entity.Position); if (entity != baseEntity && d <= maxQueueRadius) { return(entity as ISteeringEntity); } } return(null); }
private Vector2 GetLeaderAhead(ISteeringEntity leader, float leaderBehindDist) { var dv = leader.Velocity; dv.Normalize(); dv *= leaderBehindDist; return(leader.Position + dv); }
public static Vector2 Seek(ISteeringTarget target, ISteeringEntity steeringEntity) { var dv = target.Position - steeringEntity.Position; dv.Normalize(); steeringEntity.DesiredVelocity = dv; return((steeringEntity.DesiredVelocity * steeringEntity.MaxVelocity) - steeringEntity.Velocity); }
public static Vector2 Flee(ISteeringTarget target, ISteeringEntity steeringEntity) { var dv = (target.Position - steeringEntity.Position); dv.Normalize(); dv *= steeringEntity.MaxVelocity; steeringEntity.DesiredVelocity = -dv; return(steeringEntity.DesiredVelocity - steeringEntity.Velocity); }
private bool IsOnLeaderSight(ISteeringEntity leader, ISteeringEntity entity, Vector2 leaderAhead, float leaderSightRadius) { return(Vector2.Distance(leaderAhead, entity.Position) <= leaderSightRadius || Vector2.Distance(leader.Position, entity.Position) <= leaderSightRadius); }
public ConditionArgs(ISteeringEntity entity, ISteeringTarget target) { Entity = entity; Target = target; }
public LeaderFollowing(ISteeringEntity leader, float leaderBehindDist, float leaderSightRadius) { Leader = leader; LeaderBehindDist = leaderBehindDist; LeaderSightRadius = leaderSightRadius; }