Exemple #1
0
        private void DoTravel(Entity entity, Vector2 position)
        {
            var vehicle = entity.GetComponent<VehicleComponent>();
            var ship = entity.GetComponent<ShipComponent>();
            var mass = ship.Mass;

            vehicle.SteerForArrival(position.ToNumericsVector3(), ship.MaxForwardSpeed, GetDistanceToChangeSpeed(mass, -vehicle.Speed, ship.Ship.Handling.ManeuverForce / Constants.PhysicsUnitScale) + ship.Radius);
            ship.LinearThrustVector = vehicle.Velocity.ToXnaVector2();
            var spatialToken = entity.GetComponent<SpatialTokenComponent>();
            var xform = entity.GetComponent<Transform>();
            spatialToken.Token.FindNeighbors(xform.Position.ToNumericsVector3(), vehicle.Radius * 3, _neighborSearchResults);
            vehicle.SteerToAvoidCloseNeighbors(ship.Radius, _neighborSearchResults.Select(e=>e.GetComponent<VehicleComponent>()));
        }