예제 #1
0
        private static VehicleInfo GetCargoVehicleInfo(
            VehicleManager instance,
            ushort cargoStation1, ushort cargoStation2,
            ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level)
        {
            var infoFrom = BuildingManager.instance.m_buildings.m_buffer[cargoStation1].Info;
            var infoTo   = BuildingManager.instance.m_buildings.m_buffer[cargoStation2].Info;

            var fromOutsideToStation = infoFrom?.m_buildingAI is OutsideConnectionAI &&
                                       infoFrom?.m_class?.m_subService == infoTo?.m_class?.m_subService;
            var cargoStationId = fromOutsideToStation ? cargoStation2 : cargoStation1;

            if (infoFrom?.m_class?.name == "Ferry Cargo Facility") //to support Cargo Ferries
            {
                level = ItemClass.Level.Level5;
            }
            if (!SerializableDataExtension.BuildingData().TryGetValue(cargoStationId, out var source) ||
                source.Count <= 0)
            {
                return(instance.GetRandomVehicleInfo(
                           ref Singleton <SimulationManager> .instance.m_randomizer, service, subService, level));
            }

            var array = source.ToArray();

            return(GetRandomVehicleInfoOverride(ref SimulationManager.instance.m_randomizer, service, subService, level,
                                                array));
        }
        private static VehicleInfo GetVehicleInfoWithoutType(
            VehicleManager instance,
            ushort buildingID,
            ItemClass.Service service,
            ItemClass.SubService subService,
            ItemClass.Level level)
        {
            if (!SerializableDataExtension.BuildingData().TryGetValue(buildingID, out var source) || source.Count <= 0)
            {
                return(instance.GetRandomVehicleInfo(ref SimulationManager.instance.m_randomizer, service, subService,
                                                     level));
            }

            return(GetRandomVehicleInfoOverride(ref SimulationManager.instance.m_randomizer, service, subService, level,
                                                source.ToArray()));
        }
        private static VehicleInfo GetVehicleInfoForDepot( //only for taxi and cable cars - and only for 1 of 4 cases
            VehicleManager instance,
            ushort buildingID,
            ItemClass.Service service,
            ItemClass.SubService subService,
            ItemClass.Level level)
        {
            if (
                service != ItemClass.Service.PublicTransport ||
                subService != ItemClass.SubService.PublicTransportTaxi &&
                subService != ItemClass.SubService.PublicTransportCableCar ||
                !SerializableDataExtension.BuildingData().TryGetValue(buildingID, out var source) || source.Count <= 0)
            {
                return(instance.GetRandomVehicleInfo(ref SimulationManager.instance.m_randomizer, service, subService,
                                                     level));
            }

            return(GetRandomVehicleInfoOverride(ref SimulationManager.instance.m_randomizer, service, subService, level,
                                                source.ToArray()));
        }