Esempio n. 1
0
        // Update the budget based on service type and whether or not it's night time
        private void updateBudget(ItemClass.Service service, bool night)
        {
            ServiceObject s         = getServiceObject(service, night);
            int           newBudget = getNewBudget(s);

            Singleton <EconomyManager> .instance.SetBudget(service, ItemClass.SubService.None, newBudget, night);
        }
        public override void OnBuildingCreated(ushort id)
        {
            base.OnBuildingCreated(id);

            if (Singleton <BuildingManager> .exists)
            {
                ZoneManager       zm      = Singleton <ZoneManager> .instance;
                ItemClass.Service service = Singleton <BuildingManager> .instance.m_buildings.m_buffer[id].Info.GetService();
                int drop = Singleton <GameSpeedManager> .instance.Parameters.DemandDropAfterBuildingCreated;

                switch (service)
                {
                case ItemClass.Service.Residential:
                    zm.m_actualResidentialDemand = Mathf.Max(0, zm.m_actualResidentialDemand - drop);
                    break;

                case ItemClass.Service.Commercial:
                    zm.m_actualCommercialDemand = Mathf.Max(0, zm.m_actualCommercialDemand - drop);
                    break;

                case ItemClass.Service.Industrial:
                    zm.m_actualWorkplaceDemand = Mathf.Max(0, zm.m_actualWorkplaceDemand - drop);
                    break;

                case ItemClass.Service.Office:
                    zm.m_actualWorkplaceDemand = Mathf.Max(0, zm.m_actualWorkplaceDemand - drop);
                    break;
                }
            }
        }
        private bool ProcessCitizenSick(TAI instance, uint citizenId, ref TCitizen citizen)
        {
            Citizen.Location currentLocation = CitizenProxy.GetLocation(ref citizen);
            if (currentLocation == Citizen.Location.Moving)
            {
                return(false);
            }

            ushort currentBuilding = CitizenProxy.GetCurrentBuilding(ref citizen);

            if (currentLocation != Citizen.Location.Home && currentBuilding == 0)
            {
                Log.Debug(LogCategory.State, $"Teleporting {GetCitizenDesc(citizenId, ref citizen)} back home because they are sick but no building is specified");
                CitizenProxy.SetLocation(ref citizen, Citizen.Location.Home);
                return(true);
            }

            if (currentLocation != Citizen.Location.Home && CitizenProxy.GetVehicle(ref citizen) != 0)
            {
                return(true);
            }

            if (currentLocation == Citizen.Location.Visit)
            {
                ItemClass.Service service = BuildingMgr.GetBuildingService(CitizenProxy.GetVisitBuilding(ref citizen));
                if (service == ItemClass.Service.HealthCare || service == ItemClass.Service.Disaster)
                {
                    return(true);
                }
            }

            Log.Debug(LogCategory.State, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is sick, trying to get to a hospital");
            residentAI.FindHospital(instance, citizenId, currentBuilding, TransferManager.TransferReason.Sick);
            return(true);
        }
Esempio n. 4
0
        public static bool Prefix(int amount, ItemClass.Service service, ItemClass.SubService subService,
                                  ItemClass.Level level, int taxRate, ref int __result)
        {
            if (DontRunPatch)
            {
                return(true);
            }

            // This method is only called from the simulation tick, so only execute it on the server
            if (MultiplayerManager.Instance.CurrentRole == MultiplayerRole.Client)
            {
                __result = amount;
                return(false);
            }

            ResourceCommandHandler.Queue(new EconomyResourceCommand()
            {
                Action         = ResourceAction.PRIVATE,
                ResourceAmount = amount,
                Service        = service,
                SubService     = subService,
                Level          = level,
                TaxRate        = taxRate
            });
            return(true);
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
        private static ushort FindCargoStation(
            Vector3 position,
            ItemClass.Service service,
            ItemClass.SubService subservice = ItemClass.SubService.None)
        {
            BuildingManager instance = Singleton<BuildingManager>.instance;
            if (subservice != ItemClass.SubService.PublicTransportPlane)
                subservice = ItemClass.SubService.None;
            ushort num1 = instance.FindBuilding(position, 100f, service, subservice, Building.Flags.None, Building.Flags.None);
            int num2 = 0;
            while (num1 != (ushort)0)
            {
                ushort parentBuilding = instance.m_buildings.m_buffer[(int)num1].m_parentBuilding;
                BuildingInfo info = instance.m_buildings.m_buffer[(int)num1].Info;
                if (info.m_buildingAI is CargoStationAI || info.m_buildingAI is OutsideConnectionAI || parentBuilding == (ushort)0)
                    return num1;
                num1 = parentBuilding;
                if (++num2 > 49152)
                {
                    CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace);
                    break;
                }
            }

            return 0;
        }
 public bool FindPathPositionWithSpiralLoop(Vector3 position,
                                            Vector3?secondaryPosition,
                                            ItemClass.Service service,
                                            NetInfo.LaneType laneType,
                                            VehicleInfo.VehicleType vehicleType,
                                            NetInfo.LaneType otherLaneType,
                                            VehicleInfo.VehicleType otherVehicleType,
                                            bool allowUnderground,
                                            bool requireConnect,
                                            float maxDistance,
                                            out PathUnit.Position pathPos)
 {
     return(FindPathPositionWithSpiralLoop(
                position,
                secondaryPosition,
                service,
                laneType,
                vehicleType,
                otherLaneType,
                otherVehicleType,
                VehicleInfo.VehicleType.None,
                allowUnderground,
                requireConnect,
                maxDistance,
                out pathPos,
                out PathUnit.Position _,
                out float _,
                out float _));
 }
Esempio n. 8
0
        public static int GetAreaIndex(ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, int width, int length, BuildingInfo.ZoningMode zoningMode)
        {
            int areaIndex;

            if (subService != ItemClass.SubService.None)
            {
                areaIndex = 8 + subService - ItemClass.SubService.ResidentialLow;
            }
            else
            {
                areaIndex = service - ItemClass.Service.Residential;
            }
            areaIndex = (int)(areaIndex * 5 + level);
            if (zoningMode == BuildingInfo.ZoningMode.CornerRight)
            {
                areaIndex = areaIndex * 4 + length - 1;
                areaIndex = areaIndex * 4 + width - 1;
                areaIndex = areaIndex * 2 + 1;
            }
            else
            {
                areaIndex = areaIndex * 4 + width - 1;
                areaIndex = areaIndex * 4 + length - 1;
                areaIndex = (int)(areaIndex * 2 + zoningMode);
            }
            return(areaIndex);
        }
Esempio n. 9
0
        private int GetTotalCapacity <TAI>(ItemClass.Service service, CapacityGetter <TAI> getter) where TAI : PlayerBuildingAI
        {
            int capacity = 0;

            var serviceBuildings = BuildingManager.instance.GetServiceBuildings(service);

            if (serviceBuildings == null || serviceBuildings.m_buffer == null || serviceBuildings.m_size > serviceBuildings.m_buffer.Length)
            {
                return(0);
            }

            var buildings = serviceBuildings.m_buffer;

            for (int i = 0; i < serviceBuildings.m_size; i++)
            {
                if (buildings[i] == 0)
                {
                    continue;
                }
                var b = BuildingManager.instance.m_buildings.m_buffer[buildings[i]];

                // Building is not active. Ignore it.
                if ((b.m_flags & Building.Flags.Active) == 0)
                {
                    continue;
                }
                var ai = b.Info.m_buildingAI as TAI;
                if (ai != null)
                {
                    capacity += getter(ref BuildingManager.instance.m_buildings.m_buffer[buildings[i]], ai);
                }
            }
            return(capacity);
        }
        /// <summary>
        /// Extension method. Call via 'segment.MayHaveCustomSpeedLimits()`.
        /// Check whether custom speed limits may be assigned to the given segment.
        /// </summary>
        /// <param name="segment">Reference to affected segment.</param>
        /// <returns>True if this segment type can have custom speed limits set.</returns>
        public static bool MayHaveCustomSpeedLimits(this ref NetSegment segment)
        {
            if ((segment.m_flags & NetSegment.Flags.Created) == NetSegment.Flags.None)
            {
                return(false);
            }

            // Collapsed roads cannot have speed limit, but will be restored if you upgrade in place
            if ((segment.m_flags & NetSegment.Flags.Collapsed) != NetSegment.Flags.None)
            {
                return(false);
            }

            ItemClass connectionClass = segment.Info.GetConnectionClass();

            ItemClass.SubService subService = connectionClass.m_subService;
            ItemClass.Service    service    = connectionClass.m_service;

            return(service == ItemClass.Service.Road ||
                   (service == ItemClass.Service.PublicTransport &&
                    subService
                    is ItemClass.SubService.PublicTransportTrain
                    or ItemClass.SubService.PublicTransportTram
                    or ItemClass.SubService.PublicTransportMetro
                    or ItemClass.SubService.PublicTransportMonorail));
        }
        public static VehicleInfo GetRandomVehicleInfo(
            ref Randomizer r,
            ItemClass.Service service,
            ItemClass.SubService subService,
            ItemClass.Level level)
        {
            if (CurrentSourceBuilding == 0 || BuildingUseDefaultVehicles[CurrentSourceBuilding] || BuildingToVehicles[CurrentSourceBuilding] == null || BuildingToVehicles[CurrentSourceBuilding].Count == 0)
            {
                return(null);
            }

            /*
             * if (service == ItemClass.Service.PlayerIndustry)
             * {
             *  service = ItemClass.Service.Industrial;
             * }
             *
             * var buildingInfo = BuildingManager.instance.m_buildings.m_buffer[CurrentSourceBuilding].Info;
             * var buildingService = buildingInfo.GetService();
             * var buildingSubService = buildingInfo.GetSubService();
             * if (buildingService != service || buildingSubService != subService)
             * {
             *  return null;
             * }
             */

            int index  = r.Int32((uint)BuildingToVehicles[CurrentSourceBuilding].Count);
            var prefab = PrefabCollection <VehicleInfo> .GetPrefab((uint)BuildingToVehicles[CurrentSourceBuilding][index]);

            return(prefab);
        }
Esempio n. 12
0
 private static void SetTicketPrice(ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, VehicleAI ai, int ticketPrice)
 {
     if (service == ItemClass.Service.PublicTransport)
     {
         if (level == ItemClass.Level.Level1)
         {
             if (subService == ItemClass.SubService.PublicTransportBus && ai is BusAI)
             {
                 (ai as BusAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportMetro && ai is PassengerTrainAI)
             {
                 (ai as PassengerTrainAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportTrain && ai is PassengerTrainAI)
             {
                 (ai as PassengerTrainAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportShip && ai is PassengerShipAI)
             {
                 (ai as PassengerShipAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportPlane && ai is PassengerPlaneAI)
             {
                 (ai as PassengerPlaneAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportTaxi && ai is TaxiAI)
             {
                 (ai as TaxiAI).m_pricePerKilometer = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportTram && ai is TramAI)
             {
                 (ai as TramAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportMonorail && ai is PassengerTrainAI)
             {
                 (ai as PassengerTrainAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportCableCar && ai is CableCarAI)
             {
                 (ai as CableCarAI).m_ticketPrice = ticketPrice;
             }
         }
         else if (level == ItemClass.Level.Level2)
         {
             if (subService == ItemClass.SubService.PublicTransportShip && ai is PassengerFerryAI)
             {
                 (ai as PassengerFerryAI).m_ticketPrice = ticketPrice;
             }
             else if (subService == ItemClass.SubService.PublicTransportPlane && ai is PassengerBlimpAI)
             {
                 (ai as PassengerBlimpAI).m_ticketPrice = ticketPrice;
             }
         }
     }
     else if (service == ItemClass.Service.Disaster && subService == ItemClass.SubService.None && level == ItemClass.Level.Level4 && ai is BusAI)
     {
         (ai as BusAI).m_ticketPrice = ticketPrice;
     }
 }
Esempio n. 13
0
        private bool ShouldSwitchBuildingLightsOff(ushort buildingId, ItemClass.Service service, ItemClass.SubService subService)
        {
            switch (service)
            {
            case ItemClass.Service.None:
                return(false);

            case ItemClass.Service.Residential:
                float currentHour = timeInfo.CurrentHour;
                return(currentHour < Math.Min(config.WakeUpHour, EarliestWakeUp) || currentHour >= config.GoToSleepHour);

            case ItemClass.Service.Office when buildingManager.GetBuildingLevel(buildingId) != ItemClass.Level.Level1:
                return(false);

            case ItemClass.Service.Commercial when subService == ItemClass.SubService.CommercialLeisure:
                return(IsNoiseRestricted(buildingId));

            case ItemClass.Service.Commercial
                when subService == ItemClass.SubService.CommercialHigh && buildingManager.GetBuildingLevel(buildingId) != ItemClass.Level.Level1:
                return(false);

            case ItemClass.Service.Monument:
                return(false);

            default:
                return(!workBehavior.IsBuildingWorking(service, subService));
            }
        }
Esempio n. 14
0
        public static string getBuildingName(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, ushort lineId = 0)
        {
            NetManager      nm = Singleton <NetManager> .instance;
            BuildingManager bm = Singleton <BuildingManager> .instance;

            Building b = bm.m_buildings.m_buffer[buildingId];

            while (b.m_parentBuilding > 0)
            {
                doLog("getBuildingName(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding);
                buildingId = b.m_parentBuilding;
                b          = bm.m_buildings.m_buffer[buildingId];
            }
            InstanceID iid = default;

            iid.Building    = buildingId;
            serviceFound    = b.Info?.GetService() ?? default;
            subserviceFound = b.Info?.GetSubService() ?? default;
            var index = GameServiceExtensions.ToConfigIndex(serviceFound, subserviceFound);
            TransportSystemDefinition tsd = default;

            if ((index & TLMCW.ConfigIndex.DESC_DATA) == TLMCW.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG)
            {
                tsd   = TransportSystemDefinition.From(b.Info.GetAI());
                index = tsd.ToConfigIndex();
            }
            prefix = index.GetSystemStationNamePrefix(lineId)?.TrimStart();
            doLog($"getBuildingName(): serviceFound {serviceFound} - subserviceFound = {subserviceFound} - tsd = {tsd} - index = {index} - prefix = {prefix}");

            return(bm.GetBuildingName(buildingId, iid));
        }
Esempio n. 15
0
        public bool IsSupported(ushort buildingID)
        {
            Building building = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID];

            ItemClass.Service service = building.Info.GetService();

            // ignore prisons
            if (service.Equals(ItemClass.Service.PoliceDepartment) &&
                building.Info.m_class.m_level >= ItemClass.Level.Level4)
            {
                return(false);
            }

            if (service.Equals(ItemClass.Service.FireDepartment) ||
                service.Equals(ItemClass.Service.Garbage) ||
                service.Equals(ItemClass.Service.HealthCare) ||
                service.Equals(ItemClass.Service.PoliceDepartment) ||
                service.Equals(ItemClass.Service.Road) ||
                (service.Equals(ItemClass.Service.PublicTransport) && building.Info.GetSubService().Equals(ItemClass.SubService.PublicTransportTaxi)) ||    //allow Taxi
                (service.Equals(ItemClass.Service.Education) && Settings.RestrictCitizenEducationalAccess) ||    //allow for schools if citizen access restricted
                (service.Equals(ItemClass.Service.Beautification) && Settings.RestrictCitizenParkAccess)       //allow for parks if citizen access restricted
                )
            {
                DistrictManager districtManager = Singleton <DistrictManager> .instance;
                byte            districtID      = districtManager.GetDistrict(building.m_position);

                Utils.LogGeneral($"Checking buildingID {buildingID}, District {districtID}:'{districtManager.GetDistrictName(districtID)}' active... {DistrictChecker.IsActive(districtID)}");

                return(DistrictChecker.IsActive(districtID));
            }
            return(false);
        }
Esempio n. 16
0
 public ServiceInfo(String serviceName, ItemClass.Service service, ItemClass.SubService subService, int budgetExpensePollIndex)
 {
     this.serviceName            = serviceName;
     this.service                = service;
     this.subService             = subService;
     this.budgetExpensePollIndex = budgetExpensePollIndex;
 }
        public static void Prefix(EconomyManager.Resource resource, ref int amount, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level)
        {
            // NON-STOCK CODE START
            if (resource == EconomyManager.Resource.PublicIncome)
            {
                if (service == ItemClass.Service.Vehicles)
                {
                    RealCityEconomyManager.roadIncomeForUI[MainDataStore.updateMoneyCount] += amount;

                    if (subService == ItemClass.SubService.None)
                    {
                        if (level == ItemClass.Level.Level2)
                        {
                            MainDataStore.outsideGovermentMoney -= amount;
                        }
                        else
                        {
                            MainDataStore.outsideTouristMoney -= amount;
                        }
                    }
                }
            }
            else if (resource == EconomyManager.Resource.ResourcePrice)
            {
                RealCityEconomyManager.playerIndustryIncomeForUI[MainDataStore.updateMoneyCount] += amount;
            }
            /// NON-STOCK CODE END ///
        }
Esempio n. 18
0
        public static string GetBuildingDetails(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, out NamingType namingType, ushort lineId = 0)
        {
            BuildingManager bm = Singleton <BuildingManager> .instance;

            Building b = bm.m_buildings.m_buffer[buildingId];

            while (b.m_parentBuilding > 0)
            {
                LogUtils.DoLog("getBuildingName(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding);
                buildingId = b.m_parentBuilding;
                b          = bm.m_buildings.m_buffer[buildingId];
            }
            InstanceID iid = default;

            iid.Building    = buildingId;
            serviceFound    = b.Info?.GetService() ?? default;
            subserviceFound = b.Info?.GetSubService() ?? default;
            TransportSystemDefinition tsd = TransportSystemDefinition.From(b.Info.GetAI());

            if (tsd is null)
            {
                var data = TLMBaseConfigXML.CurrentContextConfig.GetAutoNameData(serviceFound);
                prefix     = data?.NamingPrefix?.Trim();
                namingType = NamingTypeExtensions.From(serviceFound, subserviceFound);
            }
            else
            {
                prefix = tsd.GetConfig().NamingPrefix?.TrimStart();
                LogUtils.DoLog($"getBuildingName(): serviceFound {serviceFound} - subserviceFound = {subserviceFound} - tsd = {tsd} - prefix = {prefix}");
                namingType = NamingTypeExtensions.From(tsd);
            }
            return(bm.GetBuildingName(buildingId, iid));
        }
Esempio n. 19
0
        private void UpdateBindings()
        {
            bool         flag1         = false;
            ushort       extractorID   = GetFishExtractorID();
            ushort       fishFarmID    = BuildingExtension.GetFishFarm(extractorID);
            BuildingInfo extractorInfo = BuildingManager.instance.m_buildings.m_buffer[extractorID].Info;
            BuildingInfo fishFarmInfo  = BuildingManager.instance.m_buildings.m_buffer[fishFarmID].Info;

            ItemClass.Service service = fishFarmInfo.GetService();
            BuildingExtension.FishItemClass fishfarm = new BuildingExtension.FishItemClass(service);
            if (!FishFarmUtil.IsValidFishFarm(fishFarmID))
            {
                flag1 = true;
            }
            if (flag1 || _updateFishFarms[fishfarm])
            {
                PopulateFishFarmDropDown(extractorInfo, fishFarmInfo);
                _updateFishFarms[fishfarm] = false;
            }
            if (_fishFarmDropDown.Items.Length == 0)
            {
                _fishFarmDropDown.Text = "No fish farm found.";
            }
            else
            {
                _fishFarmDropDown.SelectedItem = fishFarmID;
            }
            Vector3[] extractor_pos_arr = new Vector3[BuildingExtension._extractorData.Length];
            BuildingExtension._extractorData.ForEach <BuildingExtension.ExtractorData>(item => {
                extractor_pos_arr = extractor_pos_arr.Concat <Vector3>(new Vector3[] { item.Position }).ToArray();
            });
            m_extractionPositions = extractor_pos_arr;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="service"></param>
        /// <param name="subService"></param>
        /// <param name="highRiseBan"></param>
        /// <returns></returns>
        private float getHeightLimit(ItemClass.Service service, ItemClass.SubService subService, bool highRiseBan)
        {
            float retVal = 500000.0f;  // Anyone who exceeds this deserves a thumping.

            if (highRiseBan)
            {
                switch (service)
                {
                case ItemClass.Service.Residential:
                    retVal = DataStore.getInstance().resHeightLimit;
                    break;

                case ItemClass.Service.Industrial:
                    retVal = DataStore.getInstance().indHeightLimit;
                    break;

                case ItemClass.Service.Commercial:
                    retVal = DataStore.getInstance().comHeightLimit;
                    break;

                case ItemClass.Service.Office:
                    retVal = DataStore.getInstance().offHeightLimit;
                    break;
                }
            }

            return(retVal);
        }
 public bool FindPathPositionWithSpiralLoop(Vector3 position,
                                            ItemClass.Service service,
                                            NetInfo.LaneType laneType,
                                            VehicleInfo.VehicleType vehicleType,
                                            NetInfo.LaneType otherLaneType,
                                            VehicleInfo.VehicleType otherVehicleType,
                                            bool allowUnderground,
                                            bool requireConnect,
                                            float maxDistance,
                                            out PathUnit.Position pathPosA,
                                            out PathUnit.Position pathPosB,
                                            out float distanceSqrA,
                                            out float distanceSqrB)
 {
     return(FindPathPositionWithSpiralLoop(
                position,
                null,
                service,
                laneType,
                vehicleType,
                otherLaneType,
                otherVehicleType,
                allowUnderground,
                requireConnect,
                maxDistance,
                out pathPosA,
                out pathPosB,
                out distanceSqrA,
                out distanceSqrB));
 }
Esempio n. 22
0
        private static bool IsBuildingActiveOnWeekend(ItemClass.Service service, ItemClass.SubService subService)
        {
            switch (service)
            {
            case ItemClass.Service.Commercial
                when subService != ItemClass.SubService.CommercialHigh && subService != ItemClass.SubService.CommercialEco:
            case ItemClass.Service.Industrial when subService != ItemClass.SubService.IndustrialGeneric:
            case ItemClass.Service.Tourism:
            case ItemClass.Service.Electricity:
            case ItemClass.Service.Water:
            case ItemClass.Service.Beautification:
            case ItemClass.Service.HealthCare:
            case ItemClass.Service.PoliceDepartment:
            case ItemClass.Service.FireDepartment:
            case ItemClass.Service.PublicTransport:
            case ItemClass.Service.Disaster:
            case ItemClass.Service.Monument:
            case ItemClass.Service.Garbage:
            case ItemClass.Service.Road:
                return(true);

            default:
                return(false);
            }
        }
        public static void CustomAddGovermentIncome(ref int amount, ItemClass.Service service)
        {
            switch (service)
            {
            case ItemClass.Service.Garbage:
                ProcessUnitTax100(ref amount, ref garbageIncome);
                RealCityEconomyManager.garbageIncomeForUI[MainDataStore.updateMoneyCount] += amount;
                break;

            case ItemClass.Service.Education:
                ProcessUnitTax100(ref amount, ref schoolIncome);
                RealCityEconomyManager.schoolIncomeForUI[MainDataStore.updateMoneyCount] += amount;
                break;

            case ItemClass.Service.HealthCare:
                ProcessUnitTax100(ref amount, ref healthCareIncome);
                RealCityEconomyManager.healthCareIncomeForUI[MainDataStore.updateMoneyCount] += amount;
                break;

            case ItemClass.Service.FireDepartment:
                ProcessUnitTax100(ref amount, ref fireStationIncome);
                RealCityEconomyManager.fireStationIncomeForUI[MainDataStore.updateMoneyCount] += amount;
                break;

            case ItemClass.Service.PoliceDepartment:
                ProcessUnitTax100(ref amount, ref policeStationIncome);
                RealCityEconomyManager.policeStationIncomeForUI[MainDataStore.updateMoneyCount] += amount;
                break;

            default:
                amount = 0;
                DebugLog.LogToFileOnly("Error: Find unknown EXAddGovermentIncome building" + " service is" + service.ToString());
                break;
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Determines whether a building of specified <paramref name="service"/> and <paramref name="subService"/>
        /// currently has working hours. Note that this method always returns <c>true</c> for residential buildings.
        /// </summary>
        /// <param name="service">The building service.</param>
        /// <param name="subService">The building sub-service.</param>
        /// <returns>
        ///   <c>true</c> if a building of specified <paramref name="service"/> and <paramref name="subService"/>
        /// currently has working hours; otherwise, <c>false</c>.
        /// </returns>
        public bool IsBuildingWorking(ItemClass.Service service, ItemClass.SubService subService)
        {
            switch (subService)
            {
            case ItemClass.SubService.CommercialLow:
            case ItemClass.SubService.IndustrialOil:
            case ItemClass.SubService.IndustrialOre:
                return(true);
            }

            switch (service)
            {
            case ItemClass.Service.Residential:
            case ItemClass.Service.Tourism:
            case ItemClass.Service.PoliceDepartment:
            case ItemClass.Service.FireDepartment:
            case ItemClass.Service.PublicTransport:
            case ItemClass.Service.Disaster:
            case ItemClass.Service.Electricity:
            case ItemClass.Service.Water:
            case ItemClass.Service.HealthCare:
            case ItemClass.Service.Garbage:
            case ItemClass.Service.Road:
                return(true);
            }

            if (config.IsWeekendEnabled && timeInfo.Now.IsWeekend() && !IsBuildingActiveOnWeekend(service, subService))
            {
                return(false);
            }

            return(IsBuildingWorking(
                       GetBuildingWorkShiftCount(service, subService),
                       HasExtendedFirstWorkShift(service, subService)));
        }
Esempio n. 25
0
        public static string getBuildingName(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix)
        {
            NetManager      nm = Singleton <NetManager> .instance;
            BuildingManager bm = Singleton <BuildingManager> .instance;

            Building b = bm.m_buildings.m_buffer[buildingId];

            while (b.m_parentBuilding > 0)
            {
                doLog("getStationNameWithPrefix(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding);
                buildingId = b.m_parentBuilding;
                b          = bm.m_buildings.m_buffer[buildingId];
            }
            InstanceID iid = default(InstanceID);

            iid.Building    = buildingId;
            serviceFound    = b.Info?.GetService() ?? default(ItemClass.Service);
            subserviceFound = b.Info?.GetSubService() ?? default(ItemClass.SubService);
            TLMCW.ConfigIndex index = GameServiceExtensions.toConfigIndex(serviceFound, subserviceFound);
            if (index == TLMCW.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG)
            {
                var tsd = TransportSystemDefinition.from(b.Info.GetAI());
                index = tsd.toConfigIndex();
            }
            prefix = index.getPrefixTextNaming()?.Trim();

            return(bm.GetBuildingName(buildingId, iid));
        }
Esempio n. 26
0
 public IncomeExpensesPoll(ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, string incomeFieldName, string expensesFieldName)
 {
     this.m_Service           = service;
     this.m_SubService        = subService;
     this.m_Level             = level;
     this.m_ExpensesFieldName = expensesFieldName;
 }
        public static int GetAreaIndex(ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, int width, int length, BuildingInfo.ZoningMode zoningMode)
        {
            int privateSubServiceIndex = ItemClass.GetPrivateSubServiceIndex(subService);
            int num = (int)((privateSubServiceIndex == -1 ? ItemClass.GetPrivateServiceIndex(service) : 8 + privateSubServiceIndex) * 5 + level);

            return(zoningMode != BuildingInfo.ZoningMode.CornerRight ? (int)(((num * 4 + width - 1) * 4 + length - 1) * 2 + zoningMode) : ((num * 4 + length - 1) * 4 + width - 1) * 2 + 1);
        }
        public int GetTileNodeCount(int x, int z, ItemClass.Service service, ItemClass.SubService subService)
        {
            int publicServiceIndex = ItemClass.GetPublicServiceIndex(service);

            if (publicServiceIndex != -1)
            {
                //begin mod
                int tileIndex = FakeGameAreaManager.GetTileIndex(x, z); //This method gets inlined and can't be detoured
                //end mod
                if (tileIndex != -1)
                {
                    int num = tileIndex * 22;
                    int publicSubServiceIndex = ItemClass.GetPublicSubServiceIndex(subService);
                    //begin mod
                    if (m_tileNodesCount == null)
                    {
                        Init();
                    }
                    var index0 = publicSubServiceIndex == -1 ? num + publicServiceIndex : num + (publicSubServiceIndex + 12);
                    return(m_tileNodesCount[index0]);
                    //end mod
                }
            }
            return(0);
        }
Esempio n. 29
0
        private static int GetBuildingWorkShiftCount(ItemClass.Service service)
        {
            switch (service)
            {
            case ItemClass.Service.Office:
            case ItemClass.Service.Garbage:
            case ItemClass.Service.Education:
                return(1);

            case ItemClass.Service.Road:
            case ItemClass.Service.Beautification:
            case ItemClass.Service.Monument:
            case ItemClass.Service.Citizen:
                return(2);

            case ItemClass.Service.Commercial:
            case ItemClass.Service.Industrial:
            case ItemClass.Service.Tourism:
            case ItemClass.Service.Electricity:
            case ItemClass.Service.Water:
            case ItemClass.Service.HealthCare:
            case ItemClass.Service.PoliceDepartment:
            case ItemClass.Service.FireDepartment:
            case ItemClass.Service.PublicTransport:
            case ItemClass.Service.Disaster:
            case ItemClass.Service.Natural:
                return(3);

            default:
                return(1);
            }
        }
Esempio n. 30
0
        public static int GetIndex(ItemClass.Service service, ItemClass.SubService sub)
        {
            switch (service)
            {
            case ItemClass.Service.Residential:
            case ItemClass.Service.Commercial:
            case ItemClass.Service.Industrial:
                int index = (int)sub;

                if (index <= 6)
                {
                    return(index);
                }

                if (index <= 9)
                {
                    return(6);    // specialized industry
                }
                if (index == 18 || index == 19)
                {
                    return(7);    // specialized commerce
                }
                return(0);

            case ItemClass.Service.Office:
                return(8);

            default:
                return(0);
            }
        }