Esempio n. 1
0
 /// <summary>
 /// Disposes the dispatchers.
 /// </summary>
 public static void DisposeHandlers()
 {
     Global.GarbageTruckDispatcher = null;
     Global.HearseDispatcher       = null;
     Global.AmbulanceDispatcher    = null;
     Global.ServiceBuildingInfoPriorityComparer = null;
     Global.TargetBuildingInfoPriorityComparer  = null;
     Global.Buildings       = null;
     Global.Vehicles        = null;
     Global.ServiceProblems = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes the dispatchers.
        /// </summary>
        public static void ReInitializeHandlers()
        {
            // Initialize dispatch objects.
            try
            {
                if (Settings.DeathCare.DispatchVehicles || Settings.Garbage.DispatchVehicles || Settings.HealthCare.DispatchVehicles)
                {
                    // Initialize buildings.
                    if (Buildings == null)
                    {
                        Buildings = new BuildingKeeper();
                    }
                    else
                    {
                        Buildings.ReInitialize();
                    }

                    if (TargetBuildingInfoPriorityComparer == null)
                    {
                        TargetBuildingInfoPriorityComparer = new TargetBuildingInfo.PriorityComparer();
                    }
                    else
                    {
                        TargetBuildingInfoPriorityComparer.ReInitialize();
                    }

                    if (ServiceBuildingInfoPriorityComparer == null)
                    {
                        ServiceBuildingInfoPriorityComparer = new ServiceBuildingInfo.PriorityComparer();
                    }
                    else
                    {
                        ServiceBuildingInfoPriorityComparer.ReInitialize();
                    }

                    // Initialize hearse objects.
                    if (Settings.DeathCare.DispatchVehicles)
                    {
                        if (HearseDispatcher == null)
                        {
                            HearseDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.HearseDispatcher);
                        }
                        else
                        {
                            HearseDispatcher.ReInitialize();
                        }
                    }

                    // Initialize garbage truck objects.
                    if (Settings.Garbage.DispatchVehicles)
                    {
                        if (GarbageTruckDispatcher == null)
                        {
                            GarbageTruckDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.GarbageTruckDispatcher);
                        }
                        else
                        {
                            GarbageTruckDispatcher.ReInitialize();
                        }
                    }

                    // Initialize hearse objects.
                    if (Settings.HealthCare.DispatchVehicles)
                    {
                        if (AmbulanceDispatcher == null)
                        {
                            AmbulanceDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.AmbulanceDispatcher);
                        }
                        else
                        {
                            AmbulanceDispatcher.ReInitialize();
                        }
                    }
                }

                // Initialize vehicle objects.
                if (Settings.DeathCare.DispatchVehicles || Settings.Garbage.DispatchVehicles || Settings.HealthCare.DispatchVehicles ||
                    Settings.DeathCare.RemoveFromGrid || Settings.HealthCare.RemoveFromGrid)
                {
                    if (Vehicles == null)
                    {
                        Vehicles = new VehicleKeeper();
                    }
                    else
                    {
                        Vehicles.ReInitialize();
                    }
                }

                BuildingUpdateNeeded = true;
            }
            catch (Exception ex)
            {
                Log.Error(typeof(Global), "ReInitializeHandlers", ex);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Disposes the dispatchers.
 /// </summary>
 public static void DisposeHandlers()
 {
     Global.GarbageTruckDispatcher = null;
     Global.HearseDispatcher = null;
     Global.AmbulanceDispatcher = null;
     Global.ServiceBuildingInfoPriorityComparer = null;
     Global.TargetBuildingInfoPriorityComparer = null;
     Global.Buildings = null;
     Global.Vehicles = null;
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes the dispatchers.
        /// </summary>
        public static void ReInitializeHandlers()
        {
            // Initialize dispatch objects.
            try
            {
                if (Settings.DispatchAnyVehicles || Settings.AutoEmptyAnyBuildings || Settings.WreckingCrews.DispatchVehicles)
                {
                    // Initialize buildings.
                    if (Buildings == null)
                    {
                        Buildings = new BuildingKeeper();
                    }
                    else
                    {
                        Buildings.ReInitialize();
                    }
                }

                if (Settings.DispatchAnyVehicles)
                {
                    if (TargetBuildingInfoPriorityComparer == null)
                    {
                        TargetBuildingInfoPriorityComparer = new TargetBuildingInfo.PriorityComparer();
                    }

                    if (ServiceBuildingInfoPriorityComparer == null)
                    {
                        ServiceBuildingInfoPriorityComparer = new ServiceBuildingInfo.PriorityComparer();
                    }

                    // Initialize hearse objects.
                    if (Settings.DeathCare.DispatchVehicles)
                    {
                        if (HearseDispatcher == null)
                        {
                            HearseDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.HearseDispatcher);
                        }
                        else
                        {
                            HearseDispatcher.ReInitialize();
                        }
                    }

                    // Initialize garbage truck objects.
                    if (Settings.Garbage.DispatchVehicles)
                    {
                        if (GarbageTruckDispatcher == null)
                        {
                            GarbageTruckDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.GarbageTruckDispatcher);
                        }
                        else
                        {
                            GarbageTruckDispatcher.ReInitialize();
                        }
                    }

                    // Initialize ambulance objects.
                    if (Settings.HealthCare.DispatchVehicles)
                    {
                        if (AmbulanceDispatcher == null)
                        {
                            AmbulanceDispatcher = new Dispatcher(Dispatcher.DispatcherTypes.AmbulanceDispatcher);
                        }
                        else
                        {
                            AmbulanceDispatcher.ReInitialize();
                        }
                    }

                    // Initialize problem keeper.
                    if (ServiceProblems == null)
                    {
                        ServiceProblems = new ServiceProblemKeeper();
                    }
                    else
                    {
                        ServiceProblems.ReInitialize();
                    }
                }

                // Initialize vehicle objects.
                if (Settings.DispatchAnyVehicles || Settings.DeathCare.RemoveFromGrid || Settings.HealthCare.RemoveFromGrid || Settings.RecoveryCrews.DispatchVehicles)
                {
                    if (Vehicles == null)
                    {
                        Vehicles = new VehicleKeeper();
                    }
                    else
                    {
                        Vehicles.ReInitialize();
                    }
                }

                BuildingUpdateNeeded = true;
            }
            catch (Exception ex)
            {
                Log.Error(typeof(Global), "ReInitializeHandlers", ex);
            }
        }