Пример #1
0
        public static List <ushort> getAllBuildingsFromCity(ServiceSystemDefinition ssd)
        {
            List <ushort>     saida = new List <ushort>();
            var               bm    = Singleton <BuildingManager> .instance;
            FastList <ushort> buildings;

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                if (ssd.isFromSystem(bm.m_buildings.m_buffer[i].Info))
                {
                    saida.Add(i);
                }
            }
            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2}); saida.sz = {3}", ssd, buildings.ToArray(), buildings.m_size, saida.Count);
            return(saida);
        }
Пример #2
0
        public static List <ushort> getAllBuildingsFromCity(ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false)
        {
            List <ushort>     saida = new List <ushort>();
            var               bm    = Singleton <BuildingManager> .instance;
            FastList <ushort> buildings;
            var               ext = ssd.GetTransportExtension();

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                if (ssd.isFromSystem(bm.m_buildings.m_buffer[i].Info))
                {
                    if (districtId != null && ext.GetAllowDistrictServiceRestrictions())
                    {
                        var buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position);
                        if (districtId != buildingDistrict && (strict || !ext.GetAllowGoOutsideEffective(buildingDistrict)))
                        {
                            continue;
                        }
                    }
                    if (mustAllowSpawn)
                    {
                        int max      = GetMaxVehiclesBuilding(i, ssd.vehicleType, ssd.level);
                        int count    = 0;
                        int cargo    = 0;
                        int capacity = 0;
                        int inbound  = 0;
                        int outbound = 0;
                        SVMBuildingUtils.CalculateOwnVehicles(i, ref bm.m_buildings.m_buffer[i], SVMBuildingAIOverrideUtils.getBuildingOverrideExtensionStrict(bm.m_buildings.m_buffer[i].Info).GetManagedReasons(bm.m_buildings.m_buffer[i].Info).Where(x => x.Value.vehicleLevel == null).Select(x => x.Key), ref count, ref cargo, ref capacity, ref inbound, ref outbound);
                        if (count >= max)
                        {
                            continue;
                        }
                    }
                    saida.Add(i);
                }
            }
            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2}); saida.sz = {3}", ssd, buildings.ToArray(), buildings.m_size, saida.Count);
            return(saida);
        }
Пример #3
0
        internal static List <string> LoadBasicAssets(ServiceSystemDefinition definition)
        {
            List <string> basicAssetsList = new List <string>();

            for (uint num = 0u; (ulong)num < (ulong)((long)PrefabCollection <VehicleInfo> .PrefabCount()); num += 1u)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                if (!(prefab == null) && definition.isFromSystem(prefab) && !IsTrailer(prefab))
                {
                    basicAssetsList.Add(prefab.name);
                }
            }
            return(basicAssetsList);
        }
Пример #4
0
        public static List <ushort> getAllBuildingsFromCity(ref ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false)
        {
            var                   saida = new List <ushort>();
            BuildingManager       bm    = Singleton <BuildingManager> .instance;
            FastList <ushort>     buildings;
            IVMCDistrictExtension ext = ssd.GetDistrictExtension();

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            LogUtils.DoLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                ref Building building = ref bm.m_buildings.m_buffer[i];
                if (ssd.isFromSystem(building.Info))
                {
                    if (districtId != null && ssd.AllowRestrictions)
                    {
                        byte buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position);
                        if (districtId != buildingDistrict && (strict || (!ext.GetAllowServeOtherDistricts(buildingDistrict) ?? VehiclesMasterControlMod.allowServeOtherDistrictsAsDefault)))
                        {
                            continue;
                        }
                    }
                    if (mustAllowSpawn)
                    {
                        int max      = GetMaxVehiclesBuilding(ref building, ssd.vehicleType, ssd.level);
                        int count    = 0;
                        int cargo    = 0;
                        int capacity = 0;
                        int inbound  = 0;
                        int outbound = 0;
                        VMCBuildingUtils.CalculateOwnVehicles(ref bm.m_buildings.m_buffer[i], ref count, ref cargo, ref capacity, ref inbound, ref outbound);
                        if (count >= max)
                        {
                            continue;
                        }
                    }
                    saida.Add(i);
                }
            }