예제 #1
0
 /// <summary>
 /// Sets the specified configuration for the values from the specified settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 internal void SetSettings(Settings settings)
 {
     this.ReflectionAllowance         = settings.ReflectionAllowance;
     this.BlockTransferManagerOffers  = settings.BlockTransferManagerOffers;
     this.AssignmentCompatibilityMode = settings.AssignmentCompatibilityMode;
     this.CreationCompatibilityMode   = settings.CreationCompatibilityMode;
 }
예제 #2
0
        /// <summary>
        /// Deserializes a compatibility settings block.
        /// </summary>
        /// <param name="serializedData">The serialized data.</param>
        /// <param name="settings">The settings.</param>
        /// <returns>The deserialization result.</returns>
        private static DeserializationResult DeserializeCompatibilitySettings(BinaryData serializedData, Settings settings)
        {
            if (serializedData == null || serializedData.Left == 0)
            {
                return(DeserializationResult.EndOfData);
            }

            Log.DevDebug(typeof(BinarySettings), "DeserializeCompatibilitySettings", applySettings);

            serializedData.ResetLocalCheckSum();

            SettingsType settingsType = serializedData.GetSettingsType();

            if (settingsType != SettingsType.Compatibility)
            {
                throw new InvalidOperationException("Not a compatibility settings block");
            }

            ulong version = serializedData.GetVersion();

            if (version > 0)
            {
                Log.Warning(typeof(BinarySettings), "DeserializeCompatibilitySettings", "Serialized data version too high", version, 0);
                return(DeserializationResult.Error);
            }

            // Settings.
            ServiceDispatcherSettings.Allowance reflectionAllowance = serializedData.GetAllowance();
            bool blockTransferManagerOffers = serializedData.GetBool();

            ServiceDispatcherSettings.ModCompatibilityMode assignmentCompatibilityMode = serializedData.GetModCompatibilityMode();
            ServiceDispatcherSettings.ModCompatibilityMode creationCompatibilityMode   = serializedData.GetModCompatibilityMode();

            serializedData.CheckLocalCheckSum();

            // Only use these settings if no settings file was loaded.
            if (!settings.Loaded)
            {
                Log.Debug(typeof(BinarySettings), "DeserializeCompatibilitySettings", applySettings, reflectionAllowance, blockTransferManagerOffers, assignmentCompatibilityMode, creationCompatibilityMode);

                if (applySettings)
                {
                    settings.ReflectionAllowance         = reflectionAllowance;
                    settings.BlockTransferManagerOffers  = blockTransferManagerOffers;
                    settings.AssignmentCompatibilityMode = assignmentCompatibilityMode;
                    settings.CreationCompatibilityMode   = creationCompatibilityMode;
                }
            }

            return(DeserializationResult.Success);
        }
        /// <summary>
        /// Initializes the settings.
        /// </summary>
        public void Initialize()
        {
            if (this.Version < 5)
            {
                this.CreateSpareAmbulances    = FixBrokenSpareVehiclesCreation(this.CreateSpareAmbulances);
                this.CreateSpareGarbageTrucks = FixBrokenSpareVehiclesCreation(this.CreateSpareGarbageTrucks);
                this.CreateSpareHearses       = FixBrokenSpareVehiclesCreation(this.CreateSpareHearses);

                if (this.Version < 4)
                {
                    this.AssignmentCompatibilityMode = ServiceDispatcherSettings.DefaultAssignmentCompatibilityMode;
                    this.CreationCompatibilityMode   = ServiceDispatcherSettings.DefaultCreationCompatibilityMode;

                    if (this.Version < 3)
                    {
                        if (this.Version < 2)
                        {
                            this.DispatchHearsesByDistrict       = this.DispatchByDistrict;
                            this.DispatchHearsesByRange          = this.DispatchByRange;
                            this.DispatchGarbageTrucksByDistrict = this.DispatchByDistrict;
                            this.DispatchGarbageTrucksByRange    = this.DispatchByRange;
                            this.DispatchAmbulancesByDistrict    = this.DispatchByDistrict;
                            this.DispatchAmbulancesByRange       = this.DispatchByRange;
                        }

                        if (this.MinimumGarbageForDispatch >= 2000)
                        {
                            this.MinimumGarbageForPatrol = 200;
                        }
                        else if (this.MinimumGarbageForDispatch >= 300)
                        {
                            this.MinimumGarbageForPatrol = 150;
                        }
                        else if (this.MinimumGarbageForDispatch >= 100)
                        {
                            this.MinimumGarbageForPatrol = 100;
                        }
                        else
                        {
                            this.MinimumGarbageForPatrol = this.MinimumGarbageForDispatch;
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified data.
 /// </summary>
 /// <param name="data">The data.</param>
 public void Add(ServiceDispatcherSettings.ModCompatibilityMode data)
 {
     this.Add((byte)data);
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Settings"/> class.
        /// </summary>
        /// <param name="settings">The file settings.</param>
        public Settings(ServiceDispatcherSettings settings = null)
        {
            if (settings != null)
            {
                this.loadedVersion = settings.Version;

                this.RangeModifier = settings.RangeModifier;
                this.RangeLimit = settings.RangeLimit;
                this.RangeMaximum = settings.RangeMaximum;
                this.RangeMinimum = settings.RangeMinimum;
                this.ReflectionAllowance = settings.ReflectionAllowance;
                this.AssignmentCompatibilityMode = settings.AssignmentCompatibilityMode;
                this.CreationCompatibilityMode = settings.CreationCompatibilityMode;

                this.DeathCare.DispatchVehicles = settings.DispatchHearses;
                this.DeathCare.DispatchByDistrict = settings.DispatchHearsesByDistrict;
                this.DeathCare.DispatchByRange = settings.DispatchHearsesByRange;
                this.DeathCare.CreateSpares = settings.CreateSpareHearses;
                this.DeathCare.RemoveFromGrid = settings.RemoveHearsesFromGrid;
                this.DeathCare.ChecksCustom = settings.DeathChecksCustom;
                this.DeathCare.ChecksPreset = settings.DeathChecksPreset;
                this.DeathCare.AutoEmpty = settings.AutoEmptyCemeteries;
                this.DeathCare.AutoEmptyStartLevelPercent = settings.AutoEmptyCemeteryStartLevelPercent;
                this.DeathCare.AutoEmptyStopLevelPercent = settings.AutoEmptyCemeteryStopLevelPercent;

                this.HealthCare.DispatchVehicles = settings.DispatchAmbulances;
                this.HealthCare.DispatchByDistrict = settings.DispatchAmbulancesByDistrict;
                this.HealthCare.DispatchByRange = settings.DispatchAmbulancesByRange;
                this.HealthCare.CreateSpares = settings.CreateSpareAmbulances;
                this.HealthCare.RemoveFromGrid = settings.RemoveAmbulancesFromGrid;
                this.HealthCare.ChecksCustom = settings.SickChecksCustom;
                this.HealthCare.ChecksPreset = settings.SickChecksPreset;

                this.Garbage.DispatchVehicles = settings.DispatchGarbageTrucks;
                this.Garbage.DispatchByDistrict = settings.DispatchGarbageTrucksByDistrict;
                this.Garbage.DispatchByRange = settings.DispatchGarbageTrucksByRange;
                this.Garbage.LimitOpportunisticCollection = settings.LimitOpportunisticGarbageCollection;
                this.Garbage.CreateSpares = settings.CreateSpareGarbageTrucks;
                this.Garbage.MinimumAmountForDispatch = settings.MinimumGarbageForDispatch;
                this.Garbage.MinimumAmountForPatrol = settings.MinimumGarbageForPatrol;
                this.Garbage.ChecksCustom = settings.GarbageChecksCustom;
                this.Garbage.ChecksPreset = settings.GarbageChecksPreset;
                this.Garbage.AutoEmpty = settings.AutoEmptyLandfills;
                this.Garbage.AutoEmptyStartLevelPercent = settings.AutoEmptyLandfillStartLevelPercent;
                this.Garbage.AutoEmptyStopLevelPercent = settings.AutoEmptyLandfillStopLevelPercent;

                this.WreckingCrews.DispatchVehicles = settings.AutoBulldozeBuildings;
                this.WreckingCrews.DelaySeconds = settings.AutoBulldozeBuildingsDelaySeconds;

                this.RecoveryCrews.DispatchVehicles = settings.RemoveStuckVehicles;
                this.RecoveryCrews.DelaySeconds = settings.RemoveStuckVehiclesDelaySeconds;
            }

            if (!Global.EnableExperiments)
            {
                this.DeathCare.AutoEmpty = false;
                this.Garbage.AutoEmpty = false;
            }

            this.AssignmentCompatibilityMode = ServiceDispatcherSettings.ModCompatibilityMode.UseCustomCode;
            this.CreationCompatibilityMode = ServiceDispatcherSettings.ModCompatibilityMode.UseCustomCode;
            this.HealthCare.DispatchVehicles = false;
        }
        /// <summary>
        /// Sets the settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public void SetSettings(Settings settings)
        {
            this.DispatchByDistrict          = settings.DeathCare.DispatchByDistrict && settings.Garbage.DispatchByDistrict && settings.HealthCare.DispatchByDistrict;
            this.DispatchByRange             = settings.DeathCare.DispatchByRange || settings.Garbage.DispatchByRange || settings.HealthCare.DispatchByRange;
            this.RangeModifier               = settings.RangeModifier;
            this.RangeLimit                  = settings.RangeLimit;
            this.RangeMaximum                = settings.RangeMaximum;
            this.RangeMinimum                = settings.RangeMinimum;
            this.ReflectionAllowance         = settings.ReflectionAllowance;
            this.BlockTransferManagerOffers  = settings.BlockTransferManagerOffers;
            this.AssignmentCompatibilityMode = settings.AssignmentCompatibilityMode;
            this.CreationCompatibilityMode   = settings.CreationCompatibilityMode;

            this.DispatchHearses           = settings.DeathCare.DispatchVehicles;
            this.DispatchHearsesByDistrict = settings.DeathCare.DispatchByDistrict;
            this.DispatchHearsesByRange    = settings.DeathCare.DispatchByRange;
            this.RemoveHearsesFromGrid     = settings.DeathCare.RemoveFromGrid;
            this.CreateSpareHearses        = settings.DeathCare.CreateSpares;
            this.DeathChecksPreset         = settings.DeathCare.ChecksPreset;
            this.DeathChecksCustom         = settings.DeathCare.ChecksCustom;
            this.DeathChecksCurrent        = settings.DeathCare.ChecksParameters;
            this.IgnoreRangeUseClosestDeathCareBuilding = settings.DeathCare.IgnoreRangeUseClosestBuildings;
            this.AutoEmptyCemeteries = settings.DeathCare.AutoEmpty;
            this.AutoEmptyCemeteryStartLevelPercent = settings.DeathCare.AutoEmptyStartLevelPercent;
            this.AutoEmptyCemeteryStopLevelPercent  = settings.DeathCare.AutoEmptyStopLevelPercent;

            this.DispatchAmbulances                      = settings.HealthCare.DispatchVehicles;
            this.DispatchAmbulancesByDistrict            = settings.HealthCare.DispatchByDistrict;
            this.DispatchAmbulancesByRange               = settings.HealthCare.DispatchByRange;
            this.RemoveAmbulancesFromGrid                = settings.HealthCare.RemoveFromGrid;
            this.CreateSpareAmbulances                   = settings.HealthCare.CreateSpares;
            this.SickChecksPreset                        = settings.HealthCare.ChecksPreset;
            this.SickChecksCustom                        = settings.HealthCare.ChecksCustom;
            this.SickChecksCurrent                       = settings.HealthCare.ChecksParameters;
            this.IgnoreRangeUseClosestHealthCareBuilding = settings.HealthCare.IgnoreRangeUseClosestBuildings;

            this.DispatchGarbageTrucks               = settings.Garbage.DispatchVehicles;
            this.DispatchGarbageTrucksByDistrict     = settings.Garbage.DispatchByDistrict;
            this.DispatchGarbageTrucksByRange        = settings.Garbage.DispatchByRange;
            this.LimitOpportunisticGarbageCollection = settings.Garbage.LimitOpportunisticCollection;
            this.CreateSpareGarbageTrucks            = settings.Garbage.CreateSpares;
            this.MinimumGarbageForDispatch           = settings.Garbage.MinimumAmountForDispatch;
            this.MinimumGarbageForPatrol             = settings.Garbage.MinimumAmountForPatrol;
            this.GarbageChecksPreset  = settings.Garbage.ChecksPreset;
            this.GarbageChecksCustom  = settings.Garbage.ChecksCustom;
            this.GarbageChecksCurrent = settings.Garbage.ChecksParameters;
            this.IgnoreRangeUseClosestGarbageBuilding = settings.Garbage.IgnoreRangeUseClosestBuildings;
            this.AutoEmptyLandfills = settings.Garbage.AutoEmpty;
            this.AutoEmptyLandfillStartLevelPercent = settings.Garbage.AutoEmptyStartLevelPercent;
            this.AutoEmptyLandfillStopLevelPercent  = settings.Garbage.AutoEmptyStopLevelPercent;

            this.AutoBulldozeBuildings             = settings.WreckingCrews.DispatchVehicles;
            this.AutoBulldozeBuildingsDelaySeconds = settings.WreckingCrews.DelaySeconds;

            this.RemoveStuckVehicles             = settings.RecoveryCrews.DispatchVehicles;
            this.RemoveStuckVehiclesDelaySeconds = settings.RecoveryCrews.DelaySeconds;

            this.BuildingChecksPresets  = (Enum.GetValues(typeof(ServiceDispatcherSettings.BuildingCheckOrder)) as ServiceDispatcherSettings.BuildingCheckOrder[]).WhereSelectToArray(bco => bco != ServiceDispatcherSettings.BuildingCheckOrder.Custom, bco => new ServiceDispatcherSettings.BuildingChecksPresetInfo(bco));
            this.BuildingChecksPossible = (Enum.GetValues(typeof(ServiceDispatcherSettings.BuildingCheckParameters)) as ServiceDispatcherSettings.BuildingCheckParameters[]).WhereToArray(bcp => bcp != ServiceDispatcherSettings.BuildingCheckParameters.Undefined);

            this.Version   = CurrentVersion;
            this.SaveCount = settings.SaveCount;
        }