Exemple #1
0
        /// <summary>
        /// Used to update flight statuses
        /// </summary>
        internal void UpdateFlightStatuses(SimulationTime time)
        {
            // Gets the time until takeoff
            double timeToTakeoff = Departure.Subtract(time.DateTime).TotalMinutes;

            // When reservations count is to small
            // Cancel the flight
            if (Status != FlightStatus.OpenForReservation && Reservations.Count < 20)
            {
                if (ChangeStatusIfNewer(FlightStatus.Canceled))
                {
                    BadFlightInfo?.Invoke($"{Name} got canceled due to reservation amount was < 20");
                }
            }

            // Updates the different flight states
            if (ChangeStatusInsidePeriod(timeToTakeoff, 360, 900, FlightStatus.FarAway))
            {
                FlightInfo?.Invoke($"{Name} is now closed for reservations");
            }
            if (ChangeStatusInsidePeriod(timeToTakeoff, 70, 360, FlightStatus.OnTheWay))
            {
                FlightInfo?.Invoke($"{Name} is 290 min from the airport");
            }
            if (ChangeStatusInsidePeriod(timeToTakeoff, 60, 70, FlightStatus.Landing))
            {
                FlightInfo?.Invoke($"{Name} has just landed");
            }
            if (ChangeStatusInsidePeriod(timeToTakeoff, 30, 60, FlightStatus.Refilling))
            {
                FlightInfo?.Invoke($"{Name} is being filled with luggages");
            }
            if (ChangeStatusInsidePeriod(timeToTakeoff, 5, 30, FlightStatus.Boarding))
            {
                FlightInfo?.Invoke($"{Name} is now boading");
            }
            if (ChangeStatusInsidePeriod(timeToTakeoff, 0, 5, FlightStatus.Takeoff))
            {
                if (GetCheckinAmount() == Reservations.Count)
                {
                    FlightInfo?.Invoke($"{Name} is about to takeoff with all booked passengers");
                }
                else
                {
                    BadFlightInfo?.Invoke($"{Name} is about to takeoff with missing passengers due to bustle");
                }
            }
        }