Example #1
0
        // <summary>
        // Check if there are new vehicles and add them to the options list
        // </summary>
        private static void CompileVehiclesList()
        {
            List <VehicleOptions> optionsList = new List <VehicleOptions>();

            if (config.options != null)
            {
                optionsList.AddRange(config.options);
            }

            for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(i);

                if (prefab == null || ContainsPrefab(prefab))
                {
                    continue;
                }

                // New vehicle
                VehicleOptions options = new VehicleOptions();
                options.SetPrefab(prefab);

                optionsList.Add(options);
            }

            if (config.options != null)
            {
                DebugUtils.Log("Found " + (optionsList.Count - config.options.Length) + " new vehicle(s)");
            }
            else
            {
                DebugUtils.Log("Found " + optionsList.Count + " new vehicle(s)");
            }

            config.options = optionsList.ToArray();
        }
Example #2
0
        public static IEnumerator UpdateCapacityUnits(ThreadBase t)
        {
            int count = 0;
            Array16 <Vehicle> vehicles = VehicleManager.instance.m_vehicles;

            for (uint i = 0; i < vehicles.m_buffer.Length; i++)
            {
                if ((vehicles.m_buffer[i].m_flags & Vehicle.Flags.Spawned) == Vehicle.Flags.Spawned)
                {
                    if (prefabUpdateUnits == null || vehicles.m_buffer[i].Info == prefabUpdateUnits)
                    {
                        int capacity = GetUnitsCapacity(vehicles.m_buffer[i].Info.m_vehicleAI);

                        if (capacity != -1)
                        {
                            CitizenUnit[] units = CitizenManager.instance.m_units.m_buffer;
                            uint          unit  = vehicles.m_buffer[i].m_citizenUnits;

                            int currentUnitCount = GetTotalUnitGroups(unit);
                            int newUnitCount     = Mathf.CeilToInt(capacity / 5f);

                            // Capacity reduced
                            if (newUnitCount < currentUnitCount)
                            {
                                // Get the first unit to remove
                                uint n = unit;
                                for (int j = 1; j < newUnitCount; j++)
                                {
                                    n = units[n].m_nextUnit;
                                }
                                // Releasing units excess
                                CitizenManager.instance.ReleaseUnits(units[n].m_nextUnit);
                                units[n].m_nextUnit = 0;

                                count++;
                            }
                            // Capacity increased
                            else if (newUnitCount > currentUnitCount)
                            {
                                // Get the last unit
                                uint n = unit;
                                while (units[n].m_nextUnit != 0)
                                {
                                    n = units[n].m_nextUnit;
                                }

                                // Creating missing units
                                int newCapacity = capacity - currentUnitCount * 5;
                                CitizenManager.instance.CreateUnits(out units[n].m_nextUnit, ref SimulationManager.instance.m_randomizer, 0, (ushort)i, 0, 0, 0, newCapacity, 0);

                                count++;
                            }
                        }
                    }
                }
                if (i % 256 == 255)
                {
                    yield return(null);
                }
            }
            prefabUpdateUnits = null;

            if (count > 0)
            {
                DebugUtils.Log("Modified capacity of " + count + " vehicle(s). Total unit count: " + CitizenManager.instance.m_unitCount + "/" + CitizenManager.MAX_UNIT_COUNT);
            }
        }
Example #3
0
        public static void CheckForConflicts()
        {
            StringBuilder conflicts = new StringBuilder();

            foreach (string name in m_default.Keys)
            {
                VehicleOptions options = new VehicleOptions();
                options.SetPrefab(m_prefabs[name]);

                DefaultOptions modded = m_modded[name];
                DefaultOptions stored = m_default[name];

                StringBuilder details = new StringBuilder();

                if (modded.m_enabled != stored.m_enabled && options.enabled == stored.m_enabled)
                {
                    options.enabled = modded.m_enabled;
                    details.Append("enabled, ");
                }
                if (modded.m_addBackEngine != stored.m_addBackEngine && options.addBackEngine == stored.m_addBackEngine)
                {
                    options.addBackEngine = modded.m_addBackEngine;
                    details.Append("back engine, ");
                }
                if (modded.m_maxSpeed != stored.m_maxSpeed && options.maxSpeed == stored.m_maxSpeed)
                {
                    options.maxSpeed = modded.m_maxSpeed;
                    details.Append("max speed, ");
                }
                if (modded.m_acceleration != stored.m_acceleration && options.acceleration == stored.m_acceleration)
                {
                    options.acceleration = modded.m_acceleration;
                    details.Append("acceleration, ");
                }
                if (modded.m_braking != stored.m_braking && options.braking == stored.m_braking)
                {
                    options.braking = modded.m_braking;
                    details.Append("braking, ");
                }
                if (modded.m_turning != stored.m_turning && options.turning == stored.m_turning)
                {
                    options.turning = modded.m_turning;
                    details.Append("turning, ");
                }
                if (modded.m_springs != stored.m_springs && options.springs == stored.m_springs)
                {
                    options.springs = modded.m_springs;
                    details.Append("springs, ");
                }
                if (modded.m_dampers != stored.m_dampers && options.dampers == stored.m_dampers)
                {
                    options.dampers = modded.m_dampers;
                    details.Append("dampers, ");
                }
                if (modded.m_leanMultiplier != stored.m_leanMultiplier && options.leanMultiplier == stored.m_leanMultiplier)
                {
                    options.leanMultiplier = modded.m_leanMultiplier;
                    details.Append("leanMultiplier, ");
                }
                if (modded.m_nodMultiplier != stored.m_nodMultiplier && options.nodMultiplier == stored.m_nodMultiplier)
                {
                    options.nodMultiplier = modded.m_nodMultiplier;
                    details.Append("nodMultiplier, ");
                }
                if (modded.m_capacity != stored.m_capacity && options.capacity == stored.m_capacity)
                {
                    options.capacity = modded.m_capacity;
                    details.Append("capacity, ");
                }

                if (details.Length > 0)
                {
                    details.Length -= 2;
                    conflicts.AppendLine(options.name + ": " + details);
                }
            }

            if (conflicts.Length > 0)
            {
                VehicleOptions.UpdateTransfertVehicles();
                DebugUtils.Log("Conflicts detected (this message is harmless):" + Environment.NewLine + conflicts);
            }
        }
Example #4
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                UICheckBox  checkBox;
                UITextField TextField;
                UIButton    Button;

// Section for General Settings

                UIHelperBase group_general = helper.AddGroup("General Settings                                                   " + Name);

                checkBox = (UICheckBox)group_general.AddCheckbox("Disable debug messages logging", DebugUtils.hideDebugMessages.value, (b) =>
                {
                    DebugUtils.hideDebugMessages.value = b;
                });
                checkBox.tooltip = "If checked, debug messages will not be logged.";

                group_general.AddSpace(10);

                checkBox = (UICheckBox)group_general.AddCheckbox("Hide the user interface", AdvancedVehicleOptionsUID.hideGUI.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.hideGUI.value = b;
                    AdvancedVehicleOptionsUID.UpdateGUI();
                });
                checkBox.tooltip = "Hide the UI completely if you feel like you are done with it and want to save\n" +
                                   "the little bit of memory it takes. Everything else will still be functional.";

                checkBox = (UICheckBox)group_general.AddCheckbox("Disable warning for no available services at map loading", !AdvancedVehicleOptionsUID.onLoadCheck.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.onLoadCheck.value = !b;
                });
                checkBox.tooltip = "Disable the check for missing service vehicles assigned in any category when loading a map.";

// Section for Game Balancing

                UIHelperBase group_balance = helper.AddGroup("Gameplay & Balancing");

// Checkbox for SpeedUnitOption kmh vs mph

                checkBox = (UICheckBox)group_balance.AddCheckbox("Display Miles per Hour (mph) instead of Kilometer per Hour (km/h)", AdvancedVehicleOptionsUID.SpeedUnitOption.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.SpeedUnitOption.value = b;
                });
                checkBox.tooltip = "Changes display of unit of speed from mph to km/h.";

// Checkbox for Game Balancing

                checkBox = (UICheckBox)group_balance.AddCheckbox("Enable various values for non-cargo and non-passenger vehicles", AdvancedVehicleOptionsUID.GameBalanceOptions.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.GameBalanceOptions.value = b;
                });
                checkBox.tooltip = "Allows changes the Firefighting Rate and Capacity for Fire Safety, the Crime Rate Capacity\n" +
                                   "for Police Vehicles and the Maintenance and Pumping Rate for Maintenance Vehicles.\n\n" +
                                   "Can de-balance the intended gameplay. Some values are not documented.";

// Section for Compatibility

                UIHelperBase group_compatibility = helper.AddGroup("Compatibility");

// Checkbox for Overriding Incompability Warnings

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("Display Compatibility Warnings for Mods", AdvancedVehicleOptionsUID.OverrideCompatibilityWarnings.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.OverrideCompatibilityWarnings.value = b;
                });

                checkBox.tooltip = "If enabled, settings which can be modified in Improved Public Transport\n" +
                                   "(by BloodyPenguin) and Transport Lines Manager (by Klyte) will be shown\n" +
                                   "with warning color. Values should be edited in these mods only.\n\n" +
                                   "If disabled, the coloring will not shown.";
                //True, if AVO shall shall color shared mod setting values in red.

// Checkbox for Vehicle Color Expander

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("Vehicle Color Expander: Priority over AVO vehicle coloring", AdvancedVehicleOptionsUID.OverrideVCX.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.OverrideVCX.value = b;
                });

                checkBox.tooltip = "Permanent setting, if Vehicle Color Expander (by Klyte) is active.\n" +
                                   "The color management is controlled by Vehicle Color Expander.\n\n" +
                                   "Values will be configured in Vehicle Color Expander.";

                //True, if AVO shall not override Vehicle Color Expander settings. As there is not Settings for Vehicle Color Expander. AVO will show the option, but user cannot change anything as long readOnly is True.
                checkBox.readOnly        = true;
                checkBox.label.textColor = Color.gray;

                if (!VCXCompatibilityPatch.IsVCXActive())
                {
                    checkBox.enabled = false;                   //Do not show the option Checkbox, if Vehicle Color Expander is not active.
                }

// Checkbox for No Big Trucks

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("No Big Trucks: Classify Generic Industry vehicles as Large Vehicle", AdvancedVehicleOptionsUID.ControlTruckDelivery.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.ControlTruckDelivery.value = b;
                });

                checkBox.tooltip = "If enabled, Delivery Trucks can be tagged as Large Vehicles.\n" +
                                   "Dispatch will be blocked by No Big Trucks (by MacSergey).\n\n" +
                                   "Warning: Experimental feature and may have impact on the simulation.";
                //True, if AVO shall be enabled to classify Generic Industry vehicles as Large Vehicles, so No Big Trucks can suppress the dispatch to small buildings.

                if (!NoBigTruckCompatibilityPatch.IsNBTActive())
                {
                    checkBox.enabled = false;   //Do not show the option Checkbox, if No Big Trucks is not active.
                }

// Add a Spacer
                group_compatibility.AddSpace(20);

// Add Trailer Compatibility Reference

                TextField         = (UITextField)group_compatibility.AddTextfield("Vehicle Trailer compatibility references last updated:", TrailerRef.Revision, (value) => Debug.Log(""), (value) => Debug.Log(""));
                TextField.tooltip = "This field shows the vehicle list revision date for the Bus, Trolley Bus, Fire and Police\n" +
                                    "trailers, which are in real life industry trailers, but have been re-categorized by AVO.";
                TextField.readOnly = true;

                // Support Section with Wiki and Output-Log

                UIHelperBase group_support = helper.AddGroup("Support");

                Button = (UIButton)group_support.AddButton("Open the Advanced Vehicle Options Wiki", () =>
                {
                    SimulationManager.instance.SimulationPaused = true;
                    Application.OpenURL("https://github.com/CityGecko/CS-AdvancedVehicleOptions/wiki");
                });
                Button.textScale = 0.8f;

                Button = (UIButton)group_support.AddButton("Open Cities:Skylines log folder (output_log.txt)", () =>
                {
                    Utils.OpenInFileBrowser(Application.dataPath);
                });
                Button.textScale = 0.8f;
            }

            catch (Exception e)
            {
                DebugUtils.Log("OnSettingsUI failed");
                DebugUtils.LogException(e);
            }
        }