예제 #1
0
            public void AfterDeserialize(DataSerializer s)
            {
                Singleton <LoadingManager> .instance.WaitUntilEssentialScenesLoaded();

                DistrictManager instance = Singleton <DistrictManager> .instance;

                District[]             buffer       = instance.m_districts.m_buffer;
                DistrictManager.Cell[] districtGrid = FakeDistrictManager.districtGrid;
                int num = districtGrid.Length;

                for (int i = 0; i < num; i++)
                {
                    DistrictManager.Cell cell         = districtGrid[i];
                    District[]           expr_60_cp_0 = buffer;
                    byte expr_60_cp_1 = cell.m_district1;
                    expr_60_cp_0[(int)expr_60_cp_1].m_totalAlpha = expr_60_cp_0[(int)expr_60_cp_1].m_totalAlpha + (uint)cell.m_alpha1;
                    District[] expr_80_cp_0 = buffer;
                    byte       expr_80_cp_1 = cell.m_district2;
                    expr_80_cp_0[(int)expr_80_cp_1].m_totalAlpha = expr_80_cp_0[(int)expr_80_cp_1].m_totalAlpha + (uint)cell.m_alpha2;
                    District[] expr_A0_cp_0 = buffer;
                    byte       expr_A0_cp_1 = cell.m_district3;
                    expr_A0_cp_0[(int)expr_A0_cp_1].m_totalAlpha = expr_A0_cp_0[(int)expr_A0_cp_1].m_totalAlpha + (uint)cell.m_alpha3;
                    District[] expr_C0_cp_0 = buffer;
                    byte       expr_C0_cp_1 = cell.m_district4;
                    expr_C0_cp_0[(int)expr_C0_cp_1].m_totalAlpha = expr_C0_cp_0[(int)expr_C0_cp_1].m_totalAlpha + (uint)cell.m_alpha4;
                }
                instance.m_districtCount = (int)(instance.m_districts.ItemCount() - 1u);
                instance.AreaModified(0, 0, 511, 511, true);
                instance.NamesModified();
            }
        public ActionResult Delete(int id)
        {
            Student student = studentManager.GetSingleRow(id);

            ViewBag.Id           = student.Id;
            ViewBag.Name         = student.Name;
            ViewBag.DepartmentId = student.DepartmentId;

            DepartmentManager departmentManager = new DepartmentManager();
            List <Department> singleDepartment  = departmentManager.GetSingleRow(ViewBag.DepartmentId);

            foreach (var department in singleDepartment)
            {
                ViewBag.Department = department.Name;
            }


            Devision devision = new DevisionManager().GetSingleDivision(student.DivisionId);

            ViewBag.Division = devision.Name;

            District district = new DistrictManager().GetSinlgleDistrict(student.DistrictId);

            ViewBag.District = district.Name;

            Thana thana = new ThanaManager().GetSingleThana(student.ThanaId);

            ViewBag.Thana = thana.Name;


            return(View());
        }
예제 #3
0
        /// <summary>
        /// Clear building settings button event handler.
        /// <param name="control">Calling component (unused)</param>
        /// <param name="mouseEvent">Mouse event (unused)</param>
        /// </summary>
        private void ClearBuildings(UIComponent control, UIMouseEventParameter mouseEvent)
        {
            // List of building IDs to remove.
            List <ushort> buildingIDs = new List <ushort>();

            // Local references.
            Building[]      buildingBuffer  = Singleton <BuildingManager> .instance.m_buildings.m_buffer;
            DistrictManager districtManager = Singleton <DistrictManager> .instance;

            Logging.Message("clearing building settings from district ", districtManager.GetDistrictName(targetID));

            // Iterate though each building with custom settings.
            foreach (ushort buildingID in BuildingsABLC.levelRanges.Keys)
            {
                // Check if the building is in this district.
                if (districtManager.GetDistrict(buildingBuffer[buildingID].m_position) == targetID)
                {
                    // It is - add to list of custom settings to remove (can't remove them now because we're enumerating).
                    buildingIDs.Add(buildingID);
                }
            }

            // Now remove from our custom settings dictionary all building IDs that we've collected.
            foreach (ushort buildingID in buildingIDs)
            {
                BuildingsABLC.levelRanges.Remove(buildingID);
            }
        }
예제 #4
0
        private static void FixNotInParkProblem <T>(Notification.Problem problem, Func <byte, Building, byte> getParkFunction) where T : PlayerBuildingAI
        {
            for (uint i = 0; i < BuildingManager.instance.m_buildings.m_size; i++)
            {
                var data = BuildingManager.instance.m_buildings.m_buffer[i];
                if (data.Info == null || !(data.Info.m_buildingAI is T))
                {
                    continue;
                }
                DistrictManager instance = Singleton <DistrictManager> .instance;
                if ((data.m_problems & problem) != Notification.Problem.None)
                {
                    byte park = instance.GetPark(data.m_position);
                    if (park != (byte)0)
                    {
                        park = getParkFunction(park, data);
                    }

                    if (park != 0)
                    {
                        BuildingManager.instance.m_buildings.m_buffer[i].m_problems = Notification.RemoveProblems(data.m_problems,
                                                                                                                  problem);
                    }
                }
            }
        }
예제 #5
0
 private void listBoxControlStreet_DoubleClick(object sender, EventArgs e)
 {
     shreet = this.listBoxControlStreet.SelectedValue as Shreet;
     if (shreet != null)
     {
         this.textEditStreet.Text = shreet.ShreetName;
         IList <District> dListDistrict = DistrictManager.GetDistrictByID(shreet.DistrictId);
         if (dListDistrict != null)
         {
             this.textEditDistrict.Text = dListDistrict[0].DistrictName;
             if (dListDistrict[0].City != null)
             {
                 this.textEditCity.Text    = dListDistrict[0].City.CityName;
                 this.textEditAddress.Text = dListDistrict[0].City.CityName + dListDistrict[0].DistrictName + shreet.ShreetName;
             }
             else
             {
                 this.textEditAddress.Text = dListDistrict[0].DistrictName + shreet.ShreetName;
             }
         }
         else
         {
             this.textEditAddress.Text = shreet.ShreetName;
         }
     }
     else
     {
         this.textEditStreet.Text  = "";
         this.textEditAddress.Text = "";
     }
 }
예제 #6
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);
        }
예제 #7
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }
        bool     Updating  = false;
        District oDistrict = null;

        if (DistrictID > 0)
        {
            oDistrict = DistrictManager.GetDistrictByID(DistrictID);
            Updating  = oDistrict != null;
        }
        if (!Updating)
        {
            oDistrict = new District();
        }

        oDistrict.CityID       = this.ddlCityID.SelectedValue.ToInt();
        oDistrict.DistrictName = this.txtDistrictName.Text;
        bool bSuccess = Updating ? DistrictManager.UpdateDistrict(oDistrict) : DistrictManager.InsertDistrict(oDistrict);

        if (bSuccess)
        {
            Redirect("/district-list?s=1");
        }
        else
        {
            base.Warn("error.save");
        }
    }
        public static void ProcessLandFeeOffice(Building building, ushort buildingID, int totalWorkerCount)
        {
            DistrictManager instance = Singleton <DistrictManager> .instance;
            byte            district = instance.GetDistrict(building.m_position);

            DistrictPolicies.Services servicePolicies  = instance.m_districts.m_buffer[district].m_servicePolicies;
            DistrictPolicies.Taxation taxationPolicies = instance.m_districts.m_buffer[district].m_taxationPolicies;

            int landFee = totalWorkerCount * 10;
            int taxRate;

            taxRate = Singleton <EconomyManager> .instance.GetTaxRate(building.Info.m_class, taxationPolicies);

            if (instance.IsPolicyLoaded(DistrictPolicies.Policies.ExtraInsulation))
            {
                if ((servicePolicies & DistrictPolicies.Services.ExtraInsulation) != DistrictPolicies.Services.None)
                {
                    landFee = landFee * 95 / 100;
                }
            }
            if ((servicePolicies & DistrictPolicies.Services.Recycling) != DistrictPolicies.Services.None)
            {
                landFee = landFee * 95 / 100;
            }

            if (BuildingData.buildingMoney[buildingID] >= 0)
            {
                BuildingData.buildingMoney[buildingID] = (BuildingData.buildingMoney[buildingID] - (float)(landFee * taxRate) / 100);
                Singleton <EconomyManager> .instance.AddPrivateIncome(landFee, building.Info.m_class.m_service, building.Info.m_class.m_subService, building.Info.m_class.m_level, taxRate * 100);
            }
        }
예제 #9
0
        //Method based on GetUpgradeInfo from PrivateBuildingAI
        public static BuildingInfo GetInfoForLevel(ushort buildingID, ref Building data, ItemClass.Level level)
        {
            Randomizer randomizer;

            //fully randomize first level building
            if (level == 0)
            {
                randomizer = Singleton <SimulationManager> .instance.m_randomizer;
            }
            else //building based on level and id, as in original code
            {
                randomizer = new Randomizer((int)buildingID);
                for (int i = 0; i <= (int)(level - 1); i++)
                {
                    randomizer.Int32(1000u);
                }
            }



            DistrictManager instance = Singleton <DistrictManager> .instance;
            byte            district = instance.GetDistrict(data.m_position);
            ushort          style    = instance.m_districts.m_buffer[(int)district].m_Style;

            return(Singleton <BuildingManager> .instance.GetRandomBuildingInfo(ref randomizer, data.Info.m_buildingAI.m_info.m_class.m_service, data.Info.m_buildingAI.m_info.m_class.m_subService, level, data.Width, data.Length, data.Info.m_buildingAI.m_info.m_zoningMode, (int)style));
        }
예제 #10
0
        private void ExportDistricts()
        {
            if (MapperOptionsManager.OptionChecked("districts", MapperOptionsManager.exportOptions))
            {
                DistrictManager districtManager = Singleton <DistrictManager> .instance;
                District[]      districts       = districtManager.m_districts.m_buffer;
                int             districtId      = 0;

                foreach (District district in districts)
                {
                    District.Flags districtFlags = district.m_flags;

                    if (districtFlags.IsFlagSet(District.Flags.Created))
                    {
                        OSMNode generatedNode = CreateDistrict(districtId, district);

                        if (generatedNode != null)
                        {
                            osmNodes.Add(generatedNode);
                        }
                    }

                    ++districtId;
                }
            }
        }
예제 #11
0
        private void PopulateList()
        {
            buildings.Clear();
            buildingMap.Clear();
            string          filter          = m_search.text.Trim().ToLower();
            BuildingManager buildingManager = Singleton <BuildingManager> .instance;
            DistrictManager districtManager = Singleton <DistrictManager> .instance;

            for (int i = 0; i < kServices.Length; i++)
            {
                if (_tabstrip.selectedIndex == i)
                {
                    GetServiceBuildings(buildingManager, districtManager, kServices[i].enumValue, filter);
                }
            }

            // !!! Temporaary. Make buildings an array.
            var prefabList = buildings.ToArray();

            //Array.Sort(prefabList, CompareByNames);

            m_itemList.RowsData.m_buffer = prefabList;
            m_itemList.RowsData.m_size   = prefabList.Length;

            m_itemList.DisplayAt(0);
        }
예제 #12
0
        public void UpdateDate_5()  // 5 秒  -- 天数据
        {
            DistrictManager DM = Singleton <DistrictManager> .instance;

            // 失业率
            Unemployment.value = DM.m_districts.m_buffer[0].GetUnemployment();
            Unemployment.text  = FormatPercentage((int)Unemployment.value);
            // 车辆
            VehicleCount.value  = Singleton <VehicleManager> .instance.m_vehicleCount;
            VehicleParked.value = Singleton <VehicleManager> .instance.m_parkedCount;
            VehicleCount.text   = FormatScientific((int)VehicleCount.value, false);
            VehicleParked.text  = FormatScientific((int)VehicleParked.value, false);
            // 天气
            //if (WeatherRainIntensity == 0)
            //{
            //    if (Singleton<WeatherManager>.exists)
            //        Singleton<WeatherManager>.instance.m_targetRain = 0;
            //}
            // 游客
            int num1 = (int)DM.m_districts.m_buffer[0].m_tourist1Data.m_averageCount;
            int num2 = (int)DM.m_districts.m_buffer[0].m_tourist2Data.m_averageCount;
            int num3 = (int)DM.m_districts.m_buffer[0].m_tourist3Data.m_averageCount;

            TouristsAverage.value = (num1 + num2) + num3;
            TouristsAverage.text  = FormatScientific((int)TouristsAverage.value, false);
        }
        private static List<string> GetDistrictsForLine(TransportLine transportLine, NetManager theNetworkManager, DistrictManager theDistrictManager, out int stopCount)
        {
            var stop = TransportLine.GetPrevStop(transportLine.m_stops);
            var firstStop = stop;
            stopCount = 0;
            var districts = new List<string>();
            while (stop != 0)
            {
                stopCount++;
                var position = theNetworkManager.m_nodes.m_buffer[stop].m_position;
                var district = theDistrictManager.GetDistrict(position);
                if (district != 0)
                {
                    var districtName = theDistrictManager.GetDistrictName(district);
                    districtName = districtName.Trim();
                    if (districts.Contains(districtName) == false)
                        districts.Add(districtName);
                }
                else
                {
                    if (districts.Contains(string.Empty) == false)
                        districts.Add(string.Empty);
                }

                stop = TransportLine.GetNextStop(stop);
                if (stop == firstStop)
                    break;
            }
            return districts;
        }
예제 #14
0
#pragma warning disable IDE0051 // Remover membros privados não utilizados
        private static bool GenerateName(int district, DistrictManager __instance, ref string __result)
        {
            if (AddressesMod.Controller == null)
            {
                return(true);
            }

            Randomizer randomizer = new Randomizer(__instance.m_districts.m_buffer[district].m_randomSeed);
            string     format, arg;
            string     filenamePrefix = AdrController.CurrentConfig.GlobalConfig.AddressingConfig.DistrictsConfig.QualifierFile;
            string     filenameName   = AdrController.CurrentConfig.GlobalConfig.AddressingConfig.DistrictsConfig.NamesFile;

            if (AdrController.LoadedLocalesDistrictPrefix.ContainsKey(filenamePrefix ?? ""))
            {
                int arrLen = AdrController.LoadedLocalesDistrictPrefix[filenamePrefix].Length;
                format = AdrController.LoadedLocalesDistrictPrefix[filenamePrefix][randomizer.Int32((uint)arrLen)];
            }
            else
            {
                format = Locale.Get("DISTRICT_PATTERN", randomizer.Int32(Locale.Count("DISTRICT_PATTERN")));
            }

            if (AdrController.LoadedLocalesDistrictName.ContainsKey(filenameName ?? ""))
            {
                int arrLen = AdrController.LoadedLocalesDistrictName[filenameName].Length;
                arg = AdrController.LoadedLocalesDistrictName[filenameName][randomizer.Int32((uint)arrLen)];
            }
            else
            {
                arg = Locale.Get("DISTRICT_NAME", randomizer.Int32(Locale.Count("DISTRICT_NAME")));
            }

            __result = StringUtils.SafeFormat(format, arg);
            return(false);
        }
예제 #15
0
 private void listBoxControlCity_Click(object sender, EventArgs e)
 {
     city = this.listBoxControlCity.SelectedValue as City;
     if (city != null)
     {
         this.textEditCity.Text     = city.CityName;
         this.textEditDistrict.Text = "";
         this.textEditStreet.Text   = "";
         IList <District> list  = null;
         DataTable        table = DistrictManager.GetDistrictByCityIDTwo(city.CityId);
         if (table != null)
         {
             if (table.Rows.Count > 0)
             {
                 list = new List <District>();
                 foreach (DataRow row in table.Rows)
                 {
                     District district = new District();
                     district.DistrictId   = int.Parse(row["districtId"].ToString());
                     district.DistrictName = row["districtName"].ToString();
                     district.CityId       = int.Parse(row["cityId"].ToString());
                     list.Add(district);
                 }
             }
         }
         this.bindingSourceDistrict.DataSource = list;
         this.bindingSourceStreet.DataSource   = null;
     }
     else
     {
         this.textEditDistrict.Text = "";
         this.textEditStreet.Text   = "";
         this.textEditCity.Text     = "";
     }
 }
예제 #16
0
        /// <summary>
        /// The original C/O code to loop though the tree array and update m_infoIndex
        /// on all treeinstances with non-null .Info's with updated m_prefabDataIndex values.
        /// </summary>
        public static void DoOriginal()
        {
            TreeManager instance = Singleton <TreeManager> .instance;

            TreeInstance[] buffer = instance.m_trees.m_buffer;
            int            num    = buffer.Length;

            for (int i = 1; i < num; i++)
            {
                if (buffer[i].m_flags != 0)
                {
                    TreeInfo info = buffer[i].Info;
                    if (info != null)
                    {
                        buffer[i].m_infoIndex = (ushort)info.m_prefabDataIndex;
                    }
                    if (buffer[i].GrowState != 0)
                    {
                        DistrictManager instance2 = Singleton <DistrictManager> .instance;
                        byte            park      = instance2.GetPark(buffer[i].Position);
                        ++instance2.m_parks.m_buffer[(int)park].m_treeCount;
                    }
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Logs the objects.
        /// </summary>
        public void LogObjects()
        {
            try
            {
                BuildingManager buildingManager = Singleton <BuildingManager> .instance;
                DistrictManager districtManager = Singleton <DistrictManager> .instance;

                Building[] buildings = buildingManager.m_buildings.m_buffer;

                for (ushort id = 0; id < buildings.Length; id++)
                {
                    if (buildings[id].Info != null)
                    {
                        Log.InfoList info = this.GetBuildingLogInfo(null, buildingManager, districtManager, id, ref buildings[id]);

                        if (info != null)
                        {
                            Log.DevDebug(this, "LogObjects", info);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this, "LogObjects", ex);
            }
        }
        public static void ConstructDistrictsList(this DistrictManager districtManager, out Dictionary <int, string> districtNames, bool includeCityAsDistrict)
        {
            districtNames = new Dictionary <int, string>();
            District[] districts = districtManager.m_districts.m_buffer;
            int        i         = 0;

            foreach (District d in districts)
            {
                string districtName;
                if (i == 0)
                {
                    if (includeCityAsDistrict)
                    {
                        districtName = "[Rest of the city] " + Singleton <SimulationManager> .instance.m_metaData.m_CityName;
                        //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Nazwa distr 0 = " + districtName);
                    }
                    else
                    {
                        districtName = null;
                    }
                }
                else
                {
                    districtName = districtManager.GetDistrictName(i);
                }
                if (d.IsValid() && d.IsAlive() && districtName != null)
                {
                    districtNames[i] = districtName.Replace("\"", string.Empty);
                }
                i++;
            }
        }
예제 #19
0
        static bool Prefix(ref int __result, ushort instanceID, ref CitizenInstance citizenData, Citizen.AgeGroup ageGroup)
        {
            // Cache as best we can. The order of calls is car, bike, taxi
            AIUtils.citizenCache = citizenData.m_citizen;  // Not needed, but just in case

            Citizen citizen      = Singleton <CitizenManager> .instance.m_citizens.m_buffer[(int)((UIntPtr)citizenData.m_citizen)];
            ushort  homeBuilding = citizen.m_homeBuilding;

            ItemClass.SubService subService = ItemClass.SubService.ResidentialLow;
            if (homeBuilding != 0)
            {
                DistrictManager instance = Singleton <DistrictManager> .instance;
                Building        building = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)homeBuilding];
                District        district = instance.m_districts.m_buffer[instance.GetDistrict(building.m_position)];
                DistrictPolicies.CityPlanning cityPlanningPolicies = district.m_cityPlanningPolicies;

                AIUtils.livesInBike = (cityPlanningPolicies & DistrictPolicies.CityPlanning.EncourageBiking) != DistrictPolicies.CityPlanning.None;
                subService          = Singleton <BuildingManager> .instance.m_buildings.m_buffer[homeBuilding].Info.GetSubService();
            }

            // Set the cache
            AIUtils.cacheArray = AIUtils.GetArray(citizen.WealthLevel, subService, ageGroup);

            // Original method return value.
            __result = AIUtils.cacheArray[DataStore.CAR];

            if (Debugging.UseTransportLog)
            {
                Debugging.WriteToLog(Debugging.TransportLogName, citizen.WealthLevel + "-wealth " + ageGroup + " has " + __result + "% chance of driving.");
            }

            // Don't execute base method after this.
            return(false);
        }
예제 #20
0
        private OSMNode CreateDistrict(int index, District district)
        {
            OSMNode         returnNode      = null;
            DistrictManager districtManager = Singleton <DistrictManager> .instance;
            string          districtName    = districtManager.GetDistrictName(index);

            if (districtName != "")
            {
                Vector3           position = district.m_nameLocation;
                List <OSMNodeTag> tags     = new List <OSMNodeTag>();

                returnNode = CreateNode(unindexedNodeOffset++, position);

                tags.Add(new OSMNodeTag()
                {
                    k = "name", v = districtName
                });
                tags.Add(new OSMNodeTag()
                {
                    k = "place", v = "suburb"
                });

                returnNode.tag = tags.ToArray();
            }

            return(returnNode);
        }
예제 #21
0
    // Use this for initialization
    void Start()
    {
        DistrictManager districtManager = DistrictManager.Instance;
        District        sea             = districtManager.seaDistrict;

        txtSeaPoints.text = string.Format("{0} Points", sea.points);
        changeLevelImages(imgSeaLevels, sea);
        btnSea.onClick.AddListener(() => onDistrictTapped("Sea"));

        District foreast = districtManager.forestDistrict;

        btnForest.onClick.RemoveAllListeners();
        if (foreast.unlocked)
        {
            txtForestPoints.text = string.Format("{0} Points", foreast.points);
            changeLevelImages(imgForestLevels, foreast);
            btnForest.image.overrideSprite = polygonGreenImg;
            btnForest.onClick.AddListener(() => onDistrictTapped("Foreast"));
            btnForest.interactable = true;
        }
        else
        {
            txtForestPoints.text           = "Locked";
            btnForest.interactable         = false;
            btnForest.image.overrideSprite = polygonGrayImg;
        }
    }
예제 #22
0
        public virtual BuildingInfo GetUpgradeInfo(ushort buildingID, ref Building data)
        {
            // This method is very fragile, no logging here!

            BuildingInfo info = data.Info;

            Randomizer randomizer = new Randomizer((int)buildingID);

            for (int i = 0; i <= (int)info.m_class.m_level; i++)
            {
                randomizer.Int32(1000u);
            }

            ItemClass.Level level    = info.m_class.m_level + 1;
            DistrictManager instance = Singleton <DistrictManager> .instance;
            byte            district = instance.GetDistrict(data.m_position);
            ushort          style    = instance.m_districts.m_buffer[(int)district].m_Style;

            /*
             * return Singleton<BuildingManager>.instance.GetRandomBuildingInfo(ref randomizer, info.m_class.m_service,
             *  info.m_class.m_subService, level, data.Width, data.Length, info.m_zoningMode);
             */

            return(BuildingManagerDetour.GetRandomBuildingInfo_Upgrade(data.m_position, data.m_infoIndex,
                                                                       ref randomizer, info.m_class.m_service, info.m_class.m_subService, level, data.Width, data.Length, info.m_zoningMode, style));
        }
예제 #23
0
        public static void SetProductionLevelupRequirement()
        {
            GameSpeedManager gsm = Singleton <GameSpeedManager> .instance;
            DistrictManager  dm  = Singleton <DistrictManager> .instance;

            if (dm.m_properties == null || dm.m_properties.m_parkProperties == null)
            {
                return;
            }

            //System.Text.StringBuilder sb = new System.Text.StringBuilder("m_productionLevelupRequirement: ");
            int infosCount = dm.m_properties.m_parkProperties.m_industryLevelInfo.Length;

            industryLevelInfo_orig = new int[infosCount];
            for (int i = 0; i < infosCount; i++)
            {
                //sb.Append(dm.m_properties.m_parkProperties.m_industryLevelInfo[i].m_productionLevelupRequirement.ToString() + ",");
                //Original values: 0,500000,1500000,4500000,13500000,0
                int oldValue = dm.m_properties.m_parkProperties.m_industryLevelInfo[i].m_productionLevelupRequirement;
                int newValue = oldValue / 100 * gsm.Parameters.LevelupRequirement;

                industryLevelInfo_orig[i] = oldValue;
                dm.m_properties.m_parkProperties.m_industryLevelInfo[i].m_productionLevelupRequirement = newValue;

                ModLogger.Add(dm.m_properties.m_parkProperties.name, "productionLevelupRequirement" + i.ToString(), oldValue / 1000, newValue / 1000);
            }
            //Debug.Log(sb.ToString());
        }
예제 #24
0
        static void Main(string[] args)
        {
            var claims = new List <Claim>
            {
                new Claim(100, "00023423", ClaimType.HighRiskClaim),
                new Claim(100000, "00036453", ClaimType.RegularClaim),
                new Claim(1, "00090868", ClaimType.RegularClaim),
                new Claim(1000.5, "00023465", ClaimType.RegularClaim),
                new Claim(999.5, "00057653", ClaimType.RegularClaim),
                new Claim(10000000, "00023515", ClaimType.HighRiskClaim)
            };

            var regManager         = new RegionalManager();
            var distManager        = new DistrictManager();
            var claimsManager      = new ClaimsManager();
            var superClaimsManager = new SuperClaimsManager();

            claimsManager.SetSuccessor(superClaimsManager);
            distManager.SetSuccessor(claimsManager);
            regManager.SetSuccessor(distManager);

            foreach (var claim in claims)
            {
                regManager.HandleClaimRequest(claim);
            }

            Console.ReadLine();
        }
        public ActionResult Details(int id)
        {
            var student = studentManager.GetSingleRow(id);

            ViewBag.Id           = student.Id;
            ViewBag.Name         = student.Name;
            ViewBag.DepartmentId = student.DepartmentId;

            var departmentManager = new DepartmentManager();

            ViewBag.Department = departmentManager.GetSingleRow(ViewBag.DepartmentId);

            Devision devision = new DevisionManager().GetSingleDivision(student.DivisionId);

            ViewBag.Division = devision.Name;

            District district = new DistrictManager().GetSinlgleDistrict(student.DistrictId);

            ViewBag.District = district.Name;

            Thana thana = new ThanaManager().GetSingleThana(student.ThanaId);

            ViewBag.Thana = thana.Name;

            return(View());
        }
예제 #26
0
        public static Byte getDistrictID(ushort buildingID)
        {
            BuildingManager buildingManager = Singleton <BuildingManager> .instance;
            DistrictManager districtManager = Singleton <DistrictManager> .instance;

            return(districtManager.GetDistrict(
                       buildingManager.m_buildings.m_buffer[buildingID].m_position));
        }
예제 #27
0
        /// <summary>
        /// get name of district by world position
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        private static string FindDistrictName(Vector3 position)
        {
            DistrictManager districtManager = Singleton <DistrictManager> .instance;
            byte            districtId      = districtManager.GetDistrict(position);
            string          districtName    = districtManager.GetDistrictName(districtId);

            return((districtName == null || districtName == "") ? ("<undefined>:" + districtId) : (districtName + ":" + districtId));
        }
예제 #28
0
        public int CaculateLandFee(Building building, ushort buildingID)
        {
            DistrictManager instance = Singleton <DistrictManager> .instance;
            byte            district = instance.GetDistrict(building.m_position);

            DistrictPolicies.Services     servicePolicies      = instance.m_districts.m_buffer[district].m_servicePolicies;
            DistrictPolicies.Taxation     taxationPolicies     = instance.m_districts.m_buffer[district].m_taxationPolicies;
            DistrictPolicies.CityPlanning cityPlanningPolicies = instance.m_districts.m_buffer[district].m_cityPlanningPolicies;

            GetLandRent(building, out int landFee);
            float taxRate;

            taxRate = Singleton <EconomyManager> .instance.GetTaxRate(building.Info.m_class, taxationPolicies);

            if (instance.IsPolicyLoaded(DistrictPolicies.Policies.ExtraInsulation))
            {
                if ((servicePolicies & DistrictPolicies.Services.ExtraInsulation) != DistrictPolicies.Services.None)
                {
                    taxRate = taxRate * 95 / 100;
                }
            }
            if ((servicePolicies & DistrictPolicies.Services.Recycling) != DistrictPolicies.Services.None)
            {
                taxRate = taxRate * 95 / 100;
            }

            if (((taxationPolicies & DistrictPolicies.Taxation.DontTaxLeisure) != DistrictPolicies.Taxation.None) && (building.Info.m_class.m_subService == ItemClass.SubService.CommercialLeisure))
            {
                landFee = 0;
            }

            if (BuildingData.buildingMoney[buildingID] > 0)
            {
                if ((building.Info.m_class.m_service == ItemClass.Service.Commercial) || (building.Info.m_class.m_service == ItemClass.Service.Industrial))
                {
                    if (BuildingData.buildingMoney[buildingID] > (taxRate * landFee / 100f))
                    {
                        return((int)(taxRate * landFee / 100f));
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (building.Info.m_class.m_service == ItemClass.Service.Office)
                {
                    Citizen.BehaviourData behaviourData = default;
                    int aliveWorkerCount = 0;
                    int totalWorkerCount = 0;
                    RealCityCommonBuildingAI.InitDelegate();
                    RealCityCommonBuildingAI.GetWorkBehaviour((OfficeBuildingAI)building.Info.m_buildingAI, buildingID, ref building, ref behaviourData, ref aliveWorkerCount, ref totalWorkerCount);
                    return((int)(totalWorkerCount * taxRate / 10f));
                }
            }

            return(0);
        }
예제 #29
0
    // Use this for initialization
    void Start()
    {
        pips        = gameObject.GetComponentsInChildren <Image>();
        districtMan = GameObject.Find("Event Controller").GetComponent <DistrictManager>();
        plus        = GameObject.Find(district + " Plus").GetComponent <Text>();
        plus.color  = new Color(plus.color.r, plus.color.g, plus.color.b, 0f);

        UpdateUnrest();
    }
        public override void SimulationStep(ushort buildingID, ref Building buildingData, ref Building.Frame frameData)
        {
            base.SimulationStep(buildingID, ref buildingData, ref frameData);
            SimulationManager instance  = Singleton <SimulationManager> .instance;
            DistrictManager   instance2 = Singleton <DistrictManager> .instance;
            byte district = instance2.GetDistrict(buildingData.m_position);

            DistrictPolicies.CityPlanning cityPlanningPolicies = instance2.m_districts.m_buffer[(int)district].m_cityPlanningPolicies;
            if ((buildingData.m_flags & (Building.Flags.Completed | Building.Flags.Upgrading)) != Building.Flags.None)
            {
                instance2.m_districts.m_buffer[(int)district].AddResidentialData(buildingData.Width * buildingData.Length, (buildingData.m_flags & Building.Flags.Abandoned) != Building.Flags.None, (buildingData.m_flags & Building.Flags.Collapsed) != Building.Flags.None && frameData.m_fireDamage == 255, (buildingData.m_flags & Building.Flags.Collapsed) != Building.Flags.None && frameData.m_fireDamage != 255, this.m_info.m_class.m_subService);
            }
            if ((buildingData.m_levelUpProgress == 255 || (buildingData.m_flags & Building.Flags.Collapsed) == Building.Flags.None) && buildingData.m_fireIntensity == 0)
            {
/*
 *              if ((this.m_info.m_class.m_subService == ItemClass.SubService.ResidentialHigh || this.m_info.m_class.m_subService == ItemClass.SubService.ResidentialHighEco) &&
 *                  (cityPlanningPolicies & DistrictPolicies.CityPlanning.HighriseBan) != DistrictPolicies.CityPlanning.None && this.m_info.m_class.m_level == ItemClass.Level.Level5 &&
 *                  instance.m_randomizer.Int32(10u) == 0 && Singleton<ZoneManager>.instance.m_lastBuildIndex == instance.m_currentBuildIndex)
 *              {
 *                  District[] expr_184_cp_0 = instance2.m_districts.m_buffer;
 *                  byte expr_184_cp_1 = district;
 *                  expr_184_cp_0[(int)expr_184_cp_1].m_cityPlanningPoliciesEffect = (expr_184_cp_0[(int)expr_184_cp_1].m_cityPlanningPoliciesEffect | DistrictPolicies.CityPlanning.HighriseBan);
 *                  buildingData.m_flags |= Building.Flags.Demolishing;
 *                  instance.m_currentBuildIndex += 1u;
 *              }
 */
                if (instance.m_randomizer.Int32(10u) == 0)
                {
                    DistrictPolicies.Specialization specializationPolicies = instance2.m_districts.m_buffer[(int)district].m_specializationPolicies;
                    DistrictPolicies.Specialization specialization         = this.SpecialPolicyNeeded();
                    if (specialization != DistrictPolicies.Specialization.None)
                    {
                        if ((specializationPolicies & specialization) == DistrictPolicies.Specialization.None)
                        {
                            if (Singleton <ZoneManager> .instance.m_lastBuildIndex == instance.m_currentBuildIndex)
                            {
                                buildingData.m_flags         |= Building.Flags.Demolishing;
                                instance.m_currentBuildIndex += 1u;
                            }
                        }
                        else
                        {
                            District[] expr_240_cp_0 = instance2.m_districts.m_buffer;
                            byte       expr_240_cp_1 = district;
                            expr_240_cp_0[(int)expr_240_cp_1].m_specializationPoliciesEffect = (expr_240_cp_0[(int)expr_240_cp_1].m_specializationPoliciesEffect | specialization);
                        }
                    }
                    else if ((specializationPolicies & DistrictPolicies.Specialization.Selfsufficient) != DistrictPolicies.Specialization.None && Singleton <ZoneManager> .instance.m_lastBuildIndex == instance.m_currentBuildIndex)
                    {
                        buildingData.m_flags         |= Building.Flags.Demolishing;
                        instance.m_currentBuildIndex += 1u;
                    }
                }
            }
        }
        /// <summary>
        /// either update of the panel or let base processing update the panel
        /// </summary>
        /// <returns>whether or not to do base processing</returns>
        public static bool Prefix()
        {
            // assume do base processing
            bool doBaseProcessing = true;

            // check if should exclude mail
            if (!ExcludeMailLoading.IncludeMail())
            {
                // do processing with mail set to zero
                // logic copied from OutsideConnectionsInfoViewPanel.UpdatePanel and then mail was set to zero

                // do imports
                DistrictManager instance       = Singleton <DistrictManager> .instance;
                int             importOil      = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageOil + 99) / 100;
                int             importOre      = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageOre + 99) / 100;
                int             importForestry = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageForestry + 99) / 100;
                int             importGoods    = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageGoods + 99) / 100;
                int             importFarming  = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageAgricultural + 99) / 100;
                int             importMail     = 0;
                int             importTotal    = importOil + importOre + importForestry + importGoods + importFarming + importMail;
                _importTotalLabel.text = StringUtils.SafeFormat(ColossalFramework.Globalization.Locale.Get(_importTotalLabel.localeID), importTotal);
                _importChart.SetValues(
                    GetValue(importOil, importTotal),
                    GetValue(importOre, importTotal),
                    GetValue(importForestry, importTotal),
                    GetValue(importGoods, importTotal),
                    GetValue(importFarming, importTotal),
                    GetValue(importMail, importTotal));

                // do exports
                int exportOil      = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageOil + 99) / 100;
                int exportOre      = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageOre + 99) / 100;
                int exportForestry = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageForestry + 99) / 100;
                int exportGoods    = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageGoods + 99) / 100;
                int exportFarming  = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageAgricultural + 99) / 100;
                int exportMail     = 0;
                int exportFish     = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageFish + 99) / 100;
                int exportTotal    = exportOil + exportOre + exportForestry + exportGoods + exportFarming + exportMail + exportFish;
                _exportTotalLabel.text = StringUtils.SafeFormat(ColossalFramework.Globalization.Locale.Get(_exportTotalLabel.localeID), exportTotal);
                _exportChart.SetValues(
                    GetValue(exportOil, exportTotal),
                    GetValue(exportOre, exportTotal),
                    GetValue(exportForestry, exportTotal),
                    GetValue(exportGoods, exportTotal),
                    GetValue(exportFarming, exportTotal),
                    GetValue(exportMail, exportTotal),
                    GetValue(exportFish, exportTotal));

                // everything was performed here, skip base processing
                doBaseProcessing = false;
            }

            // return whether or not to do the base processing
            return(doBaseProcessing);
        }
        /// <summary>
        /// Gets the name of the district.
        /// </summary>
        /// <param name="districtManager">The district manager.</param>
        /// <param name="district">The district.</param>
        /// <returns>
        /// The name of the district.
        /// </returns>
        private static string GetDistrictName(DistrictManager districtManager, int district)
        {
            if (district == 0)
            {
                return "(no district)";
            }

            try
            {
                string name = districtManager.GetDistrictName(district);

                return String.IsNullOrEmpty(name) ? "(unknown district)" : name;
            }
            catch
            {
                return null;
            }
        }
        /// <summary>
        /// Collects building info for debug use.
        /// </summary>
        /// <param name="buildings">The buildings.</param>
        /// <param name="vehicles">The vehicles.</param>
        /// <param name="districtManager">The district manager.</param>
        /// <param name="citizenManager">The citizen manager.</param>
        /// <param name="buildingId">The building identifier.</param>
        /// <param name="serviceBuilding">The service building.</param>
        /// <param name="targetBuilding">The target building.</param>
        /// <param name="buildingStamp">The building stamp.</param>
        /// <param name="verbose">If set to <c>true</c> include more information.</param>
        /// <returns>The debug information.</returns>
        private static Log.InfoList DebugInfoMsg(
            Building[] buildings,
            Vehicle[] vehicles,
            DistrictManager districtManager,
            CitizenManager citizenManager,
            ushort buildingId,
            ServiceBuildingInfo serviceBuilding,
            TargetBuildingInfo targetBuilding,
            BuildingStamp buildingStamp,
            bool verbose = false)
        {
            Log.InfoList info = new Log.InfoList();

            if (buildingStamp != null)
            {
                info.Add("O", "BuildingStamp");
            }

            if (serviceBuilding != null)
            {
                info.Add("O", "ServiceBuilding");
            }

            if (targetBuilding != null)
            {
                info.Add("O", "TargetBuilding");
            }

            List<TargetBuildingInfo> targetBuildings = null;
            List<ServiceBuildingInfo> serviceBuildings = null;

            if (verbose && Global.Buildings != null)
            {
                targetBuildings = new List<TargetBuildingInfo>();
                serviceBuildings = new List<ServiceBuildingInfo>();

                if (serviceBuilding == null)
                {
                    if (Global.Buildings.GarbageBuildings == null || !Global.Buildings.GarbageBuildings.TryGetValue(buildingId, out serviceBuilding))
                    {
                        serviceBuildings.Add(serviceBuilding);
                    }

                    if (Global.Buildings.DeathCareBuildings == null || !Global.Buildings.DeathCareBuildings.TryGetValue(buildingId, out serviceBuilding))
                    {
                        serviceBuildings.Add(serviceBuilding);
                    }

                    if (Global.Buildings.HealthCareBuildings == null || !Global.Buildings.HealthCareBuildings.TryGetValue(buildingId, out serviceBuilding))
                    {
                        serviceBuildings.Add(serviceBuilding);
                    }
                }

                if (targetBuilding == null)
                {
                    if (Global.Buildings.DeadPeopleBuildings == null || !Global.Buildings.DeadPeopleBuildings.TryGetValue(buildingId, out targetBuilding))
                    {
                        targetBuildings.Add(targetBuilding);
                    }

                    if (Global.Buildings.DirtyBuildings == null || !Global.Buildings.DirtyBuildings.TryGetValue(buildingId, out targetBuilding))
                    {
                        targetBuildings.Add(targetBuilding);
                    }

                    if (Global.Buildings.SickPeopleBuildings == null || !Global.Buildings.SickPeopleBuildings.TryGetValue(buildingId, out targetBuilding))
                    {
                        targetBuildings.Add(targetBuilding);
                    }
                }
            }

            info.Add("BuildingId", buildingId);
            info.Add("AI", buildings[buildingId].Info.m_buildingAI.GetType());
            info.Add("InfoName", buildings[buildingId].Info.name);

            string name = GetBuildingName(buildingId);
            if (!String.IsNullOrEmpty(name) && name != buildings[buildingId].Info.name)
            {
                info.Add("BuildingName", name);
            }

            byte district = districtManager.GetDistrict(buildings[buildingId].m_position);
            info.Add("District", district);
            info.Add("DistrictName", districtManager.GetDistrictName(district));

            if (buildingStamp != null)
            {
                info.Add("Source", buildingStamp.Source);
                info.Add("SimulationTimeStamp", buildingStamp.SimulationTimeStamp);
                info.Add("SimulationTimeDelta", buildingStamp.SimulationTimeDelta);
            }

            if (serviceBuilding != null)
            {
                info.Add("CanReceive", serviceBuilding.CanReceive);
                info.Add("CapacityLevel", serviceBuilding.CapacityLevel);
                info.Add("CapactyFree", serviceBuilding.CapacityFree);
                info.Add("CapactyMax", serviceBuilding.CapacityMax);
                info.Add("CapactyOverflow", serviceBuilding.CapacityOverflow);
                info.Add("Range", serviceBuilding.Range);
                info.Add("VehiclesFree", serviceBuilding.VehiclesFree);
                info.Add("VehiclesSpare", serviceBuilding.VehiclesSpare);
                info.Add("VehiclesMade", serviceBuilding.VehiclesMade);
                info.Add("VehiclesTotal", serviceBuilding.VehiclesTotal);
            }

            if (serviceBuildings != null)
            {
                for (int i = 0; i < serviceBuildings.Count; i++)
                {
                    serviceBuilding = serviceBuildings[i];
                    string n = (i + 1).ToString();

                    info.Add("CanReceive" + n, serviceBuilding.CanReceive);
                    info.Add("CapacityLevel" + n, serviceBuilding.CapacityLevel);
                    info.Add("CapactyFree" + n, serviceBuilding.CapacityFree);
                    info.Add("CapactyMax" + n, serviceBuilding.CapacityMax);
                    info.Add("CapactyOverflow" + n, serviceBuilding.CapacityOverflow);
                    info.Add("Range" + n, serviceBuilding.Range);
                    info.Add("VehiclesFree" + n, serviceBuilding.VehiclesFree);
                    info.Add("VehiclesSpare" + n, serviceBuilding.VehiclesSpare);
                    info.Add("VehiclesMade" + n, serviceBuilding.VehiclesMade);
                    info.Add("VehiclesTotal" + n, serviceBuilding.VehiclesTotal);
                }
            }

            if (targetBuilding != null)
            {
                info.Add("Demand", targetBuilding.Demand);
                info.Add("HasProblem", targetBuilding.HasProblem);
                info.Add("ProblemSize", targetBuilding.ProblemSize);
                info.Add("ProblemValue", targetBuilding.ProblemValue);
            }

            if (targetBuildings != null)
            {
                for (int i = 0; i < targetBuildings.Count; i++)
                {
                    targetBuilding = targetBuildings[i];
                    string n = (i + 1).ToString();

                    info.Add("Demand" + n, targetBuilding.Demand);
                    info.Add("HasProblem" + n, targetBuilding.HasProblem);
                    info.Add("ProblemSize" + n, targetBuilding.ProblemSize);
                    info.Add("ProblemValue" + n, targetBuilding.ProblemValue);
                }
            }

            if (verbose && Global.Buildings != null)
            {
                Double desolate;

                if (Global.Buildings.DesolateBuildings != null && Global.Buildings.DesolateBuildings.TryGetValue(buildingId, out desolate))
                {
                    info.Add("Desolate", desolate);
                }
            }

            int materialMax = 0;
            int materialAmount = 0;
            int serviceVehicleCount = 0;
            if (buildings[buildingId].Info.m_buildingAI is CemeteryAI)
            {
                serviceVehicleCount = ((CemeteryAI)buildings[buildingId].Info.m_buildingAI).m_hearseCount;
                info.Add("CorpseCapacity", ((CemeteryAI)buildings[buildingId].Info.m_buildingAI).m_corpseCapacity);
                info.Add("GraveCount", ((CemeteryAI)buildings[buildingId].Info.m_buildingAI).m_graveCount);
                info.Add("CustomBuffer1", buildings[buildingId].m_customBuffer1); // GraveCapacity?
                info.Add("CustomBuffer2", buildings[buildingId].m_customBuffer2);
                info.Add("PR_HC_Calc", ((buildings[buildingId].m_productionRate * ((CemeteryAI)buildings[buildingId].Info.m_buildingAI).m_hearseCount) + 99) / 100); // Hearse capacity?
                buildings[buildingId].Info.m_buildingAI.GetMaterialAmount(buildingId, ref buildings[buildingId], TransferManager.TransferReason.Dead, out materialAmount, out materialMax);
            }
            else if (buildings[buildingId].Info.m_buildingAI is LandfillSiteAI)
            {
                serviceVehicleCount = ((LandfillSiteAI)buildings[buildingId].Info.m_buildingAI).m_garbageTruckCount;
                buildings[buildingId].Info.m_buildingAI.GetMaterialAmount(buildingId, ref buildings[buildingId], TransferManager.TransferReason.Garbage, out materialAmount, out materialMax);
            }
            else if (buildings[buildingId].Info.m_buildingAI is HospitalAI)
            {
                serviceVehicleCount = ((HospitalAI)buildings[buildingId].Info.m_buildingAI).m_ambulanceCount;
                info.Add("", ((HospitalAI)buildings[buildingId].Info.m_buildingAI).m_patientCapacity);
                buildings[buildingId].Info.m_buildingAI.GetMaterialAmount(buildingId, ref buildings[buildingId], TransferManager.TransferReason.Sick, out materialAmount, out materialMax);
            }
            info.Add("materialMax", materialMax);
            info.Add("materialAmount", materialAmount);
            info.Add("materialFree", materialMax - materialAmount);

            int productionRate = buildings[buildingId].m_productionRate;

            ushort ownVehicleCount = 0;
            ushort madeVehicleCount = 0;
            ushort vehicleId = buildings[buildingId].m_ownVehicles;
            while (vehicleId != 0 && ownVehicleCount < ushort.MaxValue)
            {
                ownVehicleCount++;
                if ((vehicles[vehicleId].m_transferType == (byte)TransferManager.TransferReason.Garbage || vehicles[vehicleId].m_transferType == (byte)TransferManager.TransferReason.Dead) &&
                    vehicles[vehicleId].Info != null &&
                    (vehicles[vehicleId].m_flags & Vehicle.Flags.Created) == Vehicle.Flags.Created &&
                    (vehicles[vehicleId].m_flags & VehicleHelper.VehicleExists) != ~Vehicle.Flags.All)
                {
                    madeVehicleCount++;
                }

                vehicleId = vehicles[vehicleId].m_nextOwnVehicle;
            }
            info.Add("OwnVehicles", ownVehicleCount);
            info.Add("MadeVehicles", madeVehicleCount);

            info.Add("VehicleCount", serviceVehicleCount);
            info.Add("ProductionRate", productionRate);
            info.Add("VehicleCountNominal", ((productionRate * serviceVehicleCount) + 99) / 100);

            int budget = Singleton<EconomyManager>.instance.GetBudget(buildings[buildingId].Info.m_buildingAI.m_info.m_class);
            productionRate = PlayerBuildingAI.GetProductionRate(100, budget);
            int actualVehicleCount = ((productionRate * serviceVehicleCount) + 99) / 100;
            info.Add("Budget", budget);
            info.Add("ProductionRateActual", productionRate);
            info.Add("VehicleCountActual", actualVehicleCount);
            info.Add("SpareVehicles", actualVehicleCount - ownVehicleCount);

            float range = buildings[buildingId].Info.m_buildingAI.GetCurrentRange(buildingId, ref buildings[buildingId]);
            range = range * range * Global.Settings.RangeModifier;
            if (range < Global.Settings.RangeMinimum)
            {
                info.Add("Range", range, Global.Settings.RangeMinimum);
            }
            else if (range > Global.Settings.RangeMaximum)
            {
                info.Add("Range", range, Global.Settings.RangeMaximum);
            }
            else
            {
                info.Add("Range", range);
            }

            List<string> needs = new List<string>();
            if (buildings[buildingId].m_garbageBuffer >= Global.Settings.Garbage.MinimumAmountForDispatch)
            {
                needs.Add("Filthy");
            }
            if (buildings[buildingId].m_garbageBuffer >= Global.Settings.Garbage.MinimumAmountForPatrol)
            {
                needs.Add("Dirty");
            }
            else if (buildings[buildingId].m_garbageBuffer > 0)
            {
                needs.Add("Dusty");
            }
            if (buildings[buildingId].m_deathProblemTimer > 0)
            {
                needs.Add("Dead");
            }
            if (buildings[buildingId].m_garbageBuffer * Dispatcher.ProblemBufferModifier >= Dispatcher.ProblemLimitForgotten ||
                buildings[buildingId].m_deathProblemTimer * Dispatcher.ProblemTimerModifier >= Dispatcher.ProblemLimitForgotten)
            {
                needs.Add("Forgotten");
            }
            info.Add("Needs", needs);

            info.Add("DeathProblemTimer", buildings[buildingId].m_deathProblemTimer);
            info.Add("HealthProblemTimer", buildings[buildingId].m_healthProblemTimer);
            info.Add("MajorProblemTimer", buildings[buildingId].m_majorProblemTimer);

            int citizens = 0;
            int count = 0;
            uint unitId = buildings[buildingId].m_citizenUnits;
            while (unitId != 0)
            {
                CitizenUnit unit = citizenManager.m_units.m_buffer[unitId];
                for (int i = 0; i < 5; i++)
                {
                    uint citizenId = unit.GetCitizen(i);
                    if (citizenId != 0)
                    {
                        Citizen citizen = citizenManager.m_citizens.m_buffer[citizenId];
                        if (citizen.Dead && citizen.GetBuildingByLocation() == buildingId)
                        {
                            citizens++;
                        }
                    }
                }

                count++;
                if (count > (int)ushort.MaxValue * 10)
                {
                    break;
                }

                unitId = unit.m_nextUnit;
            }
            info.Add("DeadCitizens", citizens);

            info.Add("GarbageAmount", buildings[buildingId].Info.m_buildingAI.GetGarbageAmount(buildingId, ref buildings[buildingId]));
            info.Add("GarbageBuffer", buildings[buildingId].m_garbageBuffer);

            string problems = buildings[buildingId].m_problems.ToString();
            if (problems.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }) >= 0)
            {
                foreach (Notification.Problem problem in Enum.GetValues(typeof(Notification.Problem)))
                {
                    if (problem != Notification.Problem.None && (buildings[buildingId].m_problems & problem) == problem)
                    {
                        problems += ", " + problem.ToString();
                    }
                }
            }
            info.Add("Problems", problems);

            string flags = buildings[buildingId].m_flags.ToString();
            if (flags.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }) >= 0)
            {
                foreach (Building.Flags flag in Enum.GetValues(typeof(Building.Flags)))
                {
                    if (flag != Building.Flags.None && (buildings[buildingId].m_flags & flag) == flag)
                    {
                        flags += ", " + flag.ToString();
                    }
                }
            }
            info.Add("Flags", flags);

            string status = buildings[buildingId].Info.m_buildingAI.GetLocalizedStatus(buildingId, ref buildings[buildingId]);
            if (!String.IsNullOrEmpty(status))
            {
                info.Add("Status", status);
            }

            info.Add("AI", buildings[buildingId].Info.m_buildingAI.GetType().AssemblyQualifiedName);

            return info;
        }
 public void ModifyCell(int x, int z, DistrictManager.Cell cell)
 {
     var dm = DistrictManager.instance;
     if (cell.m_alpha2 > cell.m_alpha1)
     {
         Exchange(ref cell.m_alpha1, ref cell.m_alpha2, ref cell.m_district1, ref cell.m_district2);
     }
     if (cell.m_alpha3 > cell.m_alpha1)
     {
         Exchange(ref cell.m_alpha1, ref cell.m_alpha3, ref cell.m_district1, ref cell.m_district3);
     }
     if (cell.m_alpha4 > cell.m_alpha1)
     {
         Exchange(ref cell.m_alpha1, ref cell.m_alpha4, ref cell.m_district1, ref cell.m_district4);
     }
     int num = z * GRID + x;
     DistrictManager.Cell cell2 = m_districtGrid[num];
     m_districtGrid[num] = cell;
     District[] expr_E4_cp_0 = dm.m_districts.m_buffer;
     byte expr_E4_cp_1 = cell.m_district1;
     expr_E4_cp_0[(int)expr_E4_cp_1].m_totalAlpha = expr_E4_cp_0[(int)expr_E4_cp_1].m_totalAlpha + (uint)cell.m_alpha1;
     District[] expr_10E_cp_0 = dm.m_districts.m_buffer;
     byte expr_10E_cp_1 = cell.m_district2;
     expr_10E_cp_0[(int)expr_10E_cp_1].m_totalAlpha = expr_10E_cp_0[(int)expr_10E_cp_1].m_totalAlpha + (uint)cell.m_alpha2;
     District[] expr_138_cp_0 = dm.m_districts.m_buffer;
     byte expr_138_cp_1 = cell.m_district3;
     expr_138_cp_0[(int)expr_138_cp_1].m_totalAlpha = expr_138_cp_0[(int)expr_138_cp_1].m_totalAlpha + (uint)cell.m_alpha3;
     District[] expr_162_cp_0 = dm.m_districts.m_buffer;
     byte expr_162_cp_1 = cell.m_district4;
     expr_162_cp_0[(int)expr_162_cp_1].m_totalAlpha = expr_162_cp_0[(int)expr_162_cp_1].m_totalAlpha + (uint)cell.m_alpha4;
     EraseDistrict(cell2.m_district1, ref dm.m_districts.m_buffer[(int)cell2.m_district1], (uint)cell2.m_alpha1);
     EraseDistrict(cell2.m_district2, ref dm.m_districts.m_buffer[(int)cell2.m_district2], (uint)cell2.m_alpha2);
     EraseDistrict(cell2.m_district3, ref dm.m_districts.m_buffer[(int)cell2.m_district3], (uint)cell2.m_alpha3);
     EraseDistrict(cell2.m_district4, ref dm.m_districts.m_buffer[(int)cell2.m_district4], (uint)cell2.m_alpha4);
 }
 private void SetBitAlphas(DistrictManager.Cell cell, int alpha, ref int b1, ref int b2, ref int b3, ref int b4, ref int b5, ref int b6, ref int b7)
 {
     int num = 0;
     int num2 = 0;
     int num3 = 0;
     int num4 = 0;
     int num5 = 0;
     int num6 = 0;
     int num7 = 0;
     SetBitAlphas((int)cell.m_district1, (int)cell.m_alpha1, ref num, ref num2, ref num3, ref num4, ref num5, ref num6, ref num7);
     SetBitAlphas((int)cell.m_district2, (int)cell.m_alpha2, ref num, ref num2, ref num3, ref num4, ref num5, ref num6, ref num7);
     SetBitAlphas((int)cell.m_district3, (int)cell.m_alpha3, ref num, ref num2, ref num3, ref num4, ref num5, ref num6, ref num7);
     SetBitAlphas((int)cell.m_district4, (int)cell.m_alpha4, ref num, ref num2, ref num3, ref num4, ref num5, ref num6, ref num7);
     b1 += num * alpha;
     b2 += num2 * alpha;
     b3 += num3 * alpha;
     b4 += num4 * alpha;
     b5 += num5 * alpha;
     b6 += num6 * alpha;
     b7 += num7 * alpha;
 }
 /// <summary>
 /// Logs building info for debug use.
 /// </summary>
 /// <param name="buildings">The buildings.</param>
 /// <param name="vehicles">The vehicles.</param>
 /// <param name="districtManager">The district manager.</param>
 /// <param name="citizenManager">The citizen manager.</param>
 /// <param name="buildingId">The building identifier.</param>
 /// <param name="serviceBuilding">The service building.</param>
 /// <param name="targetBuilding">The target building.</param>
 /// <param name="buildingStamp">The building stamp.</param>
 private static void DebugListLog(
     Building[] buildings,
     Vehicle[] vehicles,
     DistrictManager districtManager,
     CitizenManager citizenManager,
     ushort buildingId,
     ServiceBuildingInfo serviceBuilding,
     TargetBuildingInfo targetBuilding,
     BuildingStamp buildingStamp)
 {
     if (buildings[buildingId].Info != null && (buildings[buildingId].m_flags & Building.Flags.Created) == Building.Flags.Created)
     {
         Log.InfoList info = DebugInfoMsg(buildings, vehicles, districtManager, citizenManager, buildingId, serviceBuilding, targetBuilding, buildingStamp);
         Log.DevDebug(typeof(BuildingHelper), "DebugListLog", info.ToString());
     }
 }
 private static void Normalize(ref DistrictManager.Cell cell, int ignoreIndex)
 {
     int num = 0;
     if (ignoreIndex != 1)
     {
         num += (int)cell.m_alpha1;
     }
     if (ignoreIndex != 2)
     {
         num += (int)cell.m_alpha2;
     }
     if (ignoreIndex != 3)
     {
         num += (int)cell.m_alpha3;
     }
     if (ignoreIndex != 4)
     {
         num += (int)cell.m_alpha4;
     }
     if (num != 0)
     {
         int num2 = 255;
         if (ignoreIndex == 1)
         {
             num2 -= (int)cell.m_alpha1;
         }
         if (ignoreIndex == 2)
         {
             num2 -= (int)cell.m_alpha2;
         }
         if (ignoreIndex == 3)
         {
             num2 -= (int)cell.m_alpha3;
         }
         if (ignoreIndex == 4)
         {
             num2 -= (int)cell.m_alpha4;
         }
         if (num > num2)
         {
             if (ignoreIndex != 1)
             {
                 cell.m_alpha1 = (byte)((int)cell.m_alpha1 * num2 / num);
             }
             if (ignoreIndex != 2)
             {
                 cell.m_alpha2 = (byte)((int)cell.m_alpha2 * num2 / num);
             }
             if (ignoreIndex != 3)
             {
                 cell.m_alpha3 = (byte)((int)cell.m_alpha3 * num2 / num);
             }
             if (ignoreIndex != 4)
             {
                 cell.m_alpha4 = (byte)((int)cell.m_alpha4 * num2 / num);
             }
         }
     }
 }
 private static int GetAlpha(ref DistrictManager.Cell cell, byte district)
 {
     if (cell.m_district1 == district)
     {
         return (int)cell.m_alpha1;
     }
     if (cell.m_district2 == district)
     {
         return (int)cell.m_alpha2;
     }
     if (cell.m_district3 == district)
     {
         return (int)cell.m_alpha3;
     }
     if (cell.m_district4 == district)
     {
         return (int)cell.m_alpha4;
     }
     return 0;
 }
 private int GetAlpha(ref DistrictManager.Cell cell, byte district)
 {
     Debug.Log($"{cell}-{district}");
     return 0;
 }
 private void Normalize(ref DistrictManager.Cell cell, int ignoreIndex)
 {
     Debug.Log($"{cell}-{ignoreIndex}");
 }