/// <summary> /// Starts a new route to a given goal StreetConnector. /// </summary> /// <param name="goal">The goal StreetConnector</param> public void StartNewRoute(StreetConnector goal) { goalConnector = goal; if (goal == currentConnector) { currentRoutingState = RoutingState.Finished; return; } baseRoute = RouteManager.GetBestBaseRoute(currentConnector, goal); if (baseRoute == null) { specialRoute = RouteManager.GetSpecialRoute(currentConnector, goal); currentRoutingState = RoutingState.SpecialStart2; } else { if (baseRoute.Start == currentConnector) { currentRoutingState = RoutingState.BaseStart; } else { specialRoute = RouteManager.GetSpecialRoute(currentConnector, baseRoute.Start); currentRoutingState = RoutingState.SpecialStart1; } } }
/// <summary> /// Creates a new Participant. /// </summary> /// <param name="position">The initial position of this participant</param> /// <param name="maxSpeed">The max speed of this participant</param> /// <param name="accidentRisk">The risk that this participant causes an accident</param> /// <param name="size">The amount of space this participant uses up</param> protected Participant(StreetConnector position, double maxSpeed, double accidentRisk, double size) { id = NextID; currentConnector = position; this.position = ParticipantPosition.FromCoordinate(position.Coordinate); this.maxSpeed = maxSpeed; this.accidentRisk = accidentRisk; this.size = size; baseRoute = null; specialRoute = null; currentRoutingState = RoutingState.Idle; lastConnector = null; nextConnector = null; goalConnector = null; timeBonus = TimeSpan.Zero; claimedSpace = false; isFirstClaim = true; }
/// <summary> /// Gets the request URL. /// </summary> /// <param name="actionTemplate">The action template.</param> /// <returns></returns> protected StringBuilder GetRequestUrl(string actionTemplate) => new StringBuilder().Append(BaseUrl?.TrimEnd('/') ?? string.Empty) .Append($"/{BaseRoute?.TrimStart('/').TrimEnd('/')}") .Append($"/{actionTemplate?.TrimStart('/')}");
/// <summary> /// Creates a new BaseRouteInfo for a given BaseRoute. /// </summary> /// <param name="baseRoute">The BaseRoute</param> public BaseRouteInfo(BaseRoute baseRoute) { this.baseRoute = baseRoute; users = 0; }