Example #1
0
        public static ItemClass.Zone GetBlockZoneOverride(ref ZoneBlock block, int x, int z, ItemClass.Zone zone1, ItemClass.Zone zone2)
        {
            ItemClass.Zone targetZone = block.GetZone(x, z);
            switch ((int)targetZone)
            {
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
                if (ZMController.m_ghostMode)
                {
                    ItemClass.Zone newValue = CustomZoneData.Instance[targetZone].HasZone(zone1) ? zone1 : CustomZoneData.Instance[targetZone].HasZone(zone2) ? zone2 : CustomZoneData.Instance[targetZone].GetLowerestZone();
                    block.SetZone(x, z, newValue);
                    block.RefreshZoning(0);
                    return(newValue);
                }
                else
                {
                    return(CustomZoneData.Instance[targetZone].HasZone(zone1) ? zone1 : CustomZoneData.Instance[targetZone].HasZone(zone2) ? zone2 : targetZone);
                }

            default:
                return(targetZone);
            }
        }
Example #2
0
        public double GetPollutionScore(Building data, ItemClass.Zone zone)
        {
            byte resourceRate13;

            Singleton <NaturalResourceManager> .instance.CheckPollution(data.m_position, out resourceRate13);

            return(ImmaterialResourceManager.CalculateResourceEffect((int)resourceRate13, 50, 255, 50, 100));
        }
Example #3
0
        private static void CheckZoning(ref Building _this, ItemClass.Zone zone1, ItemClass.Zone zone2, ref uint validCells, ref bool secondary, ref ZoneBlock block)
        {
            BuildingInfo.ZoningMode zoningMode = _this.Info.m_zoningMode;
            int     width       = _this.Width;
            int     length      = _this.Length;
            Vector3 vector3_1   = new Vector3(Mathf.Cos(_this.m_angle), 0.0f, Mathf.Sin(_this.m_angle)) * 8f;
            Vector3 vector3_2   = new Vector3(vector3_1.z, 0.0f, -vector3_1.x);
            int     rowCount    = block.RowCount;
            int     columnCount = ZoneBlockDetour.GetColumnCount(ref block); // modified
            Vector3 vector3_3   = new Vector3(Mathf.Cos(block.m_angle), 0.0f, Mathf.Sin(block.m_angle)) * 8f;
            Vector3 vector3_4   = new Vector3(vector3_3.z, 0.0f, -vector3_3.x);
            Vector3 vector3_5   = block.m_position - _this.m_position + vector3_1 * (float)((double)width * 0.5 - 0.5) + vector3_2 * (float)((double)length * 0.5 - 0.5);

            for (int z = 0; z < rowCount; ++z)
            {
                Vector3 vector3_6 = ((float)z - 3.5f) * vector3_4;
                for (int x = 0; (long)x < columnCount; ++x) // modified
                {
                    if (((long)block.m_valid & ~(long)block.m_shared & 1L << (z << 3 | x)) != 0L)
                    {
                        ItemClass.Zone zone  = block.GetZone(x, z);
                        bool           flag1 = zone == zone1;
                        if (zone == zone2 && zone2 != ItemClass.Zone.None)
                        {
                            flag1     = true;
                            secondary = true;
                        }
                        if (flag1)
                        {
                            Vector3 vector3_7 = ((float)x - 3.5f) * vector3_3;
                            Vector3 vector3_8 = vector3_5 + vector3_7 + vector3_6;
                            float   num1      = (float)((double)vector3_1.x * (double)vector3_8.x + (double)vector3_1.z * (double)vector3_8.z);
                            float   num2      = (float)((double)vector3_2.x * (double)vector3_8.x + (double)vector3_2.z * (double)vector3_8.z);
                            int     num3      = Mathf.RoundToInt(num1 / 64f);
                            int     num4      = Mathf.RoundToInt(num2 / 64f);
                            bool    flag2     = false;
                            if (zoningMode == BuildingInfo.ZoningMode.Straight)
                            {
                                flag2 = num4 == 0;
                            }
                            else if (zoningMode == BuildingInfo.ZoningMode.CornerLeft)
                            {
                                flag2 = num4 == 0 && num3 >= width - 2 || num4 <= 1 && num3 == width - 1;
                            }
                            else if (zoningMode == BuildingInfo.ZoningMode.CornerRight)
                            {
                                flag2 = num4 == 0 && num3 <= 1 || num4 <= 1 && num3 == 0;
                            }
                            if ((!flag2 || x == 0) && (num3 >= 0 && num4 >= 0) && (num3 < width && num4 < length))
                            {
                                validCells = validCells | (uint)(1 << (num4 << 3) + num3);
                            }
                        }
                    }
                }
            }
        }
        public static bool NewZoneCheck(ref Building buildingData, ItemClass.Zone zone1, ItemClass.Zone zone2, bool allowCollapse)
        {
            // Check if this building is RICO or not.
            bool isRICO = RICOUtils.IsRICOAI(buildingData.Info.GetAI() as PrivateBuildingAI);

            // Check if the relevant 'ignore zoning' setting is set.
            if ((ModSettings.noZonesOther && !isRICO) || (ModSettings.noZonesRico && isRICO))
            {
                // It is - return true (tell the game we're in a valid zone).
                return(true);
            }

            // If we got here, this isn't a building covered by our settings: call original method and return its result.
            return(buildingData.CheckZoning(zone1, zone2, allowCollapse));
        }
Example #5
0
 public double GetPollutionFactor(ItemClass.Zone zone)
 {
     if (zone == ItemClass.Zone.ResidentialHigh || zone == ItemClass.Zone.ResidentialLow)
     {
         return(-0.2);
     }
     else if (zone == ItemClass.Zone.Office)
     {
         return(-0.25);
     }
     else
     {
         return(-0.1667);
     }
 }
Example #6
0
        //Used in PrivateBuildingAI simulation step; move to module later.
        private static void CheckNearbyBuildingZones(Vector3 position)
        {
            int num  = Mathf.Max((int)((position.x - 35f) / 64f + 135f), 0);
            int num2 = Mathf.Max((int)((position.z - 35f) / 64f + 135f), 0);
            int num3 = Mathf.Min((int)((position.x + 35f) / 64f + 135f), 269);
            int num4 = Mathf.Min((int)((position.z + 35f) / 64f + 135f), 269);
            Array16 <Building> buildings = Singleton <BuildingManager> .instance.m_buildings;

            ushort[] buildingGrid = Singleton <BuildingManager> .instance.m_buildingGrid;
            for (int i = num2; i <= num4; i++)
            {
                for (int j = num; j <= num3; j++)
                {
                    ushort num5 = buildingGrid[i * 270 + j];
                    int    num6 = 0;
                    while (num5 != 0)
                    {
                        ushort         nextGridBuilding = buildings.m_buffer[(int)num5].m_nextGridBuilding;
                        Building.Flags flags            = buildings.m_buffer[(int)num5].m_flags;
                        if ((flags & (Building.Flags.Created | Building.Flags.Deleted | Building.Flags.Demolishing)) == Building.Flags.Created)
                        {
                            BuildingInfo info = buildings.m_buffer[(int)num5].Info;
                            if (info != null && info.m_placementStyle == ItemClass.Placement.Automatic)
                            {
                                ItemClass.Zone zone = info.m_class.GetZone();
                                if (zone != ItemClass.Zone.None && (buildings.m_buffer[(int)num5].m_flags & Building.Flags.ZonesUpdated) != Building.Flags.None && VectorUtils.LengthSqrXZ(buildings.m_buffer[(int)num5].m_position - position) <= 1225f)
                                {
                                    Building[] expr_198_cp_0 = buildings.m_buffer;
                                    ushort     expr_198_cp_1 = num5;
                                    expr_198_cp_0[(int)expr_198_cp_1].m_flags = (expr_198_cp_0[(int)expr_198_cp_1].m_flags & ~Building.Flags.ZonesUpdated);
                                    if (!buildings.m_buffer[(int)num5].CheckZoning(zone))
                                    {
                                        Singleton <BuildingManager> .instance.ReleaseBuilding(num5);
                                    }
                                }
                            }
                        }
                        num5 = nextGridBuilding;
                        if (++num6 >= 32768)
                        {
                            CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                            break;
                        }
                    }
                }
            }
        }
        private static void CheckNearbyBuildingZones(Vector3 position)
        {
            int num1 = Mathf.Max((int)(((double)position.x - 35.0) / 64.0 + 135.0), 0);
            int num2 = Mathf.Max((int)(((double)position.z - 35.0) / 64.0 + 135.0), 0);
            int num3 = Mathf.Min((int)(((double)position.x + 35.0) / 64.0 + 135.0), 269);
            int num4 = Mathf.Min((int)(((double)position.z + 35.0) / 64.0 + 135.0), 269);
            Array16 <Building> array16 = Singleton <BuildingManager> .instance.m_buildings;

            ushort[] numArray = Singleton <BuildingManager> .instance.m_buildingGrid;
            for (int index1 = num2; index1 <= num4; ++index1)
            {
                for (int index2 = num1; index2 <= num3; ++index2)
                {
                    ushort building = numArray[index1 * 270 + index2];
                    int    num5     = 0;
                    while ((int)building != 0)
                    {
                        ushort num6 = array16.m_buffer[(int)building].m_nextGridBuilding;
                        if ((array16.m_buffer[(int)building].m_flags & (Building.Flags.Created | Building.Flags.Deleted | Building.Flags.Demolishing)) == Building.Flags.Created)
                        {
                            BuildingInfo info = array16.m_buffer[(int)building].Info;
                            if (info != null && info.m_placementStyle == ItemClass.Placement.Automatic)
                            {
                                ItemClass.Zone zone          = info.m_class.GetZone();
                                ItemClass.Zone secondaryZone = info.m_class.GetSecondaryZone();
                                if (zone != ItemClass.Zone.None && (array16.m_buffer[(int)building].m_flags & Building.Flags.ZonesUpdated) != Building.Flags.None && (double)VectorUtils.LengthSqrXZ(array16.m_buffer[(int)building].m_position - position) <= 1225.0)
                                {
                                    array16.m_buffer[(int)building].m_flags &= ~Building.Flags.ZonesUpdated;
                                    if (!array16.m_buffer[(int)building].CheckZoning(zone, secondaryZone))
                                    {
                                        Singleton <BuildingManager> .instance.ReleaseBuilding(building);
                                    }
                                }
                            }
                        }
                        building = num6;
                        if (++num5 >= 49152)
                        {
                            CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace);

                            break;
                        }
                    }
                }
            }
        }
        private string GetName(ushort buildingId, ItemClass.Zone zone, ItemClass.SubService ss)
        {
            Randomizer randomizer = new Randomizer(Singleton <SimulationManager> .instance.m_metaData.m_gameInstanceIdentifier.GetHashCode() - buildingId);

            if (buildingId % 6 != 0)
            {
                Markov markov = null;
                if (!this.buildingNames.TryGetValue(ss.ToString(), out markov))
                {
                    this.buildingNames.TryGetValue(zone.ToString(), out markov);
                }
                if (markov != null)
                {
                    return(markov.GetText(ref randomizer, 6, 16, true, true));
                }
            }
            return(this.buildingName.text);
        }
        private string GetDescription(string bName, ushort buildingId, ItemClass.Zone zone, ItemClass.SubService ss)
        {
            Randomizer randomizer = new Randomizer(Singleton <SimulationManager> .instance.m_metaData.m_gameInstanceIdentifier.GetHashCode() - buildingId);
            var        year       = 2015 - buildingId % 200;
            Markov     markov     = null;

            if (!this.buildingDescriptions.TryGetValue(ss.ToString(), out markov))
            {
                this.buildingDescriptions.TryGetValue(zone.ToString(), out markov);
            }
            if (markov != null)
            {
                var text     = markov.GetText(ref randomizer, 100, 200, true);
                var cityName = Singleton <SimulationManager> .instance.m_metaData.m_CityName.Trim();

                text = text.Replace("COMPANY", bName).Replace("DATE", year.ToString()).Replace("SITY", cityName);
                return(text);
            }
            return("");
        }
Example #10
0
        private bool WillBuildingDespawn(ushort building)
        {
            BuildingInfo info = buildingBuffer[building].Info;

            ItemClass.Zone zone1 = info.m_class.GetZone();
            ItemClass.Zone zone2 = info.m_class.GetSecondaryZone();

            if (info.m_placementStyle != ItemClass.Placement.Automatic || zone1 == ItemClass.Zone.None)
            {
                return(false);
            }

            info.m_buildingAI.CheckRoadAccess(building, ref buildingBuffer[building]);
            if ((buildingBuffer[building].m_problems & Notification.Problem.RoadNotConnected) == Notification.Problem.RoadNotConnected ||
                !buildingBuffer[building].CheckZoning(zone1, zone2, true))
            {
                return(true);
            }

            return(false);
        }
Example #11
0
 public static bool GetBlockZoneSanitize(ref ZoneBlock block, int x, int z)
 {
     ItemClass.Zone targetZone = block.GetZone(x, z);
     switch ((int)targetZone)
     {
     case 8:
     case 9:
     case 10:
     case 11:
     case 12:
     case 13:
     case 14:
         if (ZMController.m_ghostMode)
         {
             ItemClass.Zone newValue = CustomZoneData.Instance[targetZone].GetLowerestZone();
             block.SetZone(x, z, newValue);
             return(true);
         }
         break;
     }
     return(false);
 }
Example #12
0
        public static int GetCurrentDemandFor(ref ItemClass.Zone zone, byte district)
        {
            DistrictManager instance2 = DistrictManager.instance;
            ZoneManager     instance  = Singleton <ZoneManager> .instance;

            return(zone switch
            {
                ItemClass.Zone.ResidentialLow => GetDistrictLResDemand(district, instance2, instance),
                ItemClass.Zone.ResidentialHigh => GetDistrictHResDemand(district, instance2, instance),
                ItemClass.Zone.CommercialLow => GetDistrictLComDemand(district, instance2, instance),
                ItemClass.Zone.CommercialHigh => GetDistrictHComDemand(district, instance2, instance),
                ItemClass.Zone.Industrial => GetDistrictIndtDemand(district, instance2, instance),
                ItemClass.Zone.Office => GetDistrictOffcDemand(district, instance2, instance),
                (ItemClass.Zone) 8 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 9 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 10 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 11 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 12 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 13 => GetHighestDemand(ref zone, district, instance2, instance),
                (ItemClass.Zone) 14 => GetHighestDemand(ref zone, district, instance2, instance),
                _ => 0,
            });
Example #13
0
        public int GetServiceThreshhold(ItemClass.Level level, ItemClass.Zone zone)
        {
            if (level == ItemClass.Level.None)
            {
                return(0);
            }

            ItemClass.Level maxLevel = ItemClass.Level.Level5;
            int             multiplier = 0, start = 0;

            switch (zone)
            {
            case ItemClass.Zone.ResidentialLow:
            case ItemClass.Zone.ResidentialHigh:
                multiplier = 15;
                break;

            case ItemClass.Zone.CommercialLow:
            case ItemClass.Zone.CommercialHigh:
                start      = 1;
                multiplier = 20;
                break;

            case ItemClass.Zone.Industrial:
                multiplier = 30;
                break;

            case ItemClass.Zone.Office:
                multiplier = 45;
                break;
            }
            if (level == maxLevel)
            {
                return(int.MaxValue);
            }

            return(((int)level + 1) * multiplier + start);
        }
Example #14
0
        public int GetEducationThreshhold(ItemClass.Level level, ItemClass.Zone zone)
        {
            if (level == ItemClass.Level.None)
            {
                return(0);
            }

            ItemClass.Level maxLevel = ItemClass.Level.Level5;
            int             start    = 0;

            switch (zone)
            {
            case ItemClass.Zone.CommercialLow:
            case ItemClass.Zone.CommercialHigh:
                start = 15;
                break;
            }
            if (level == maxLevel)
            {
                return(int.MaxValue);
            }

            return(((int)level + 1) * 15 + start);
        }
Example #15
0
        public double GetFactor(ItemClass.Zone zone, ImmaterialResourceManager.Resource resource)
        {
            if (zone == ItemClass.Zone.Industrial)
            {
                switch (resource)
                {
                case ImmaterialResourceManager.Resource.PublicTransport:
                    return(0.3333);

                case ImmaterialResourceManager.Resource.PoliceDepartment:
                case ImmaterialResourceManager.Resource.HealthCare:
                case ImmaterialResourceManager.Resource.DeathCare:
                    return(0.2);

                case ImmaterialResourceManager.Resource.FireDepartment:
                    return(0.5);

                case ImmaterialResourceManager.Resource.Entertainment:
                case ImmaterialResourceManager.Resource.EducationElementary:
                case ImmaterialResourceManager.Resource.EducationHighSchool:
                case ImmaterialResourceManager.Resource.EducationUniversity:
                    return(0.125);

                case ImmaterialResourceManager.Resource.CargoTransport:
                    return(1);

                case ImmaterialResourceManager.Resource.NoisePollution:
                case ImmaterialResourceManager.Resource.Abandonment:
                    return(-0.1429);
                }
            }
            else if (zone == ItemClass.Zone.Office)
            {
                switch (resource)
                {
                case ImmaterialResourceManager.Resource.PublicTransport:
                    return(0.3333);

                case ImmaterialResourceManager.Resource.PoliceDepartment:
                case ImmaterialResourceManager.Resource.HealthCare:
                case ImmaterialResourceManager.Resource.DeathCare:
                case ImmaterialResourceManager.Resource.FireDepartment:
                    return(0.2);

                case ImmaterialResourceManager.Resource.Entertainment:
                    return(0.1667);

                case ImmaterialResourceManager.Resource.EducationElementary:
                case ImmaterialResourceManager.Resource.EducationHighSchool:
                case ImmaterialResourceManager.Resource.EducationUniversity:
                    return(0.1429);

                case ImmaterialResourceManager.Resource.NoisePollution:
                    return(-0.25);

                case ImmaterialResourceManager.Resource.Abandonment:
                    return(-0.3333);
                }
            }
            else
            {
                switch (resource)
                {
                case ImmaterialResourceManager.Resource.EducationElementary:
                case ImmaterialResourceManager.Resource.EducationHighSchool:
                case ImmaterialResourceManager.Resource.EducationUniversity:
                case ImmaterialResourceManager.Resource.HealthCare:
                case ImmaterialResourceManager.Resource.FireDepartment:
                case ImmaterialResourceManager.Resource.PoliceDepartment:
                case ImmaterialResourceManager.Resource.PublicTransport:
                case ImmaterialResourceManager.Resource.DeathCare:
                case ImmaterialResourceManager.Resource.Entertainment:
                case ImmaterialResourceManager.Resource.CargoTransport:
                    return(1);

                case ImmaterialResourceManager.Resource.NoisePollution:
                case ImmaterialResourceManager.Resource.CrimeRate:
                case ImmaterialResourceManager.Resource.FireHazard:
                case ImmaterialResourceManager.Resource.Abandonment:
                    return(-1);
                }
            }
            return(0);
        }
Example #16
0
 public int GetEducationThreshhold(ItemClass.Level level, ItemClass.Zone zone)
 {
     if (level == ItemClass.Level.None)
     {
         return(0);
     }
     if (zone == ItemClass.Zone.ResidentialHigh || zone == ItemClass.Zone.ResidentialLow)
     {
         if (level == ItemClass.Level.Level1)
         {
             return(15);
         }
         else if (level == ItemClass.Level.Level2)
         {
             return(30);
         }
         else if (level == ItemClass.Level.Level3)
         {
             return(45);
         }
         else if (level == ItemClass.Level.Level4)
         {
             return(60);
         }
         else
         {
             return(int.MaxValue);
         }
     }
     else if (zone == ItemClass.Zone.Industrial)
     {
         if (level == ItemClass.Level.Level1)
         {
             return(15);
         }
         else if (level == ItemClass.Level.Level2)
         {
             return(30);
         }
         else
         {
             return(int.MaxValue);
         }
     }
     else if (zone == ItemClass.Zone.CommercialLow || zone == ItemClass.Zone.CommercialHigh)
     {
         if (level == ItemClass.Level.Level1)
         {
             return(30);
         }
         else if (level == ItemClass.Level.Level2)
         {
             return(45);
         }
         else
         {
             return(int.MaxValue);
         }
     }
     else
     {
         if (level == ItemClass.Level.Level1)
         {
             return(15);
         }
         else if (level == ItemClass.Level.Level2)
         {
             return(30);
         }
         else
         {
             return(int.MaxValue);
         }
     }
 }
Example #17
0
        public int GetServiceThreshhold(ItemClass.Level level, ItemClass.Zone zone)
        {
            switch (zone)
            {
            case ItemClass.Zone.Office:
                if (level == ItemClass.Level.None)
                {
                    return(0);
                }
                else if (level == ItemClass.Level.Level1)
                {
                    return(45);
                }
                else if (level == ItemClass.Level.Level2)
                {
                    return(90);
                }
                else
                {
                    return(int.MaxValue);
                }

            case ItemClass.Zone.Industrial:
                if (level == ItemClass.Level.None)
                {
                    return(0);
                }
                else if (level == ItemClass.Level.Level1)
                {
                    return(30);
                }
                else if (level == ItemClass.Level.Level2)
                {
                    return(60);
                }
                else
                {
                    return(int.MaxValue);
                }

            case ItemClass.Zone.ResidentialLow:
            case ItemClass.Zone.ResidentialHigh:
                if (level == ItemClass.Level.None)
                {
                    return(0);
                }
                else if (level == ItemClass.Level.Level1)
                {
                    return(6);
                }
                else if (level == ItemClass.Level.Level2)
                {
                    return(21);
                }

                else if (level == ItemClass.Level.Level3)
                {
                    return(41);
                }

                else if (level == ItemClass.Level.Level4)
                {
                    return(61);
                }
                else
                {
                    return(int.MaxValue);
                }

            case ItemClass.Zone.CommercialLow:
            case ItemClass.Zone.CommercialHigh:
                if (level == ItemClass.Level.None)
                {
                    return(0);
                }
                else if (level == ItemClass.Level.Level1)
                {
                    return(21);
                }
                else if (level == ItemClass.Level.Level2)
                {
                    return(41);
                }
                else
                {
                    return(int.MaxValue);
                }
            }
            return(int.MaxValue);
        }
Example #18
0
 private static void UsedZone(ZoneTool z, ItemClass.Zone zone)
 {
     UnityEngine.Debug.Log($"{z}-{zone}");
 }
Example #19
0
        public void GetEducationHappyScore(ushort buildingID, out float education, out float happy, out float commute)
        {
            Citizen.BehaviourData behaviour = default(Citizen.BehaviourData);
            Building data = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)buildingID];

            ItemClass.Zone zone = data.Info.m_class.GetZone();

            commute = 0;

            int alive             = 0;
            int total             = 0;
            int COMPANYCount      = 0;
            int aliveCOMPANYCount = 0;
            int emptyCOMPANY      = 0;

            if (zone == ItemClass.Zone.ResidentialLow || zone == ItemClass.Zone.ResidentialHigh)
            {
                CitizenHelper.instance.GetHomeBehaviour(buildingID, data, ref behaviour, ref alive, ref total, ref COMPANYCount, ref aliveCOMPANYCount, ref emptyCOMPANY);
                if (alive > 0)
                {
                    int num  = behaviour.m_educated1Count + behaviour.m_educated2Count * 2 + behaviour.m_educated3Count * 3;
                    int num2 = behaviour.m_teenCount + behaviour.m_youngCount * 2 + behaviour.m_adultCount * 3 + behaviour.m_seniorCount * 3;
                    if (num2 != 0)
                    {
                        education = (num * 72 + (num2 >> 1)) / num2;
                        happy     = behaviour.m_wellbeingAccumulation / (float)alive;
                        return;
                    }
                }
            }
            else if (zone == ItemClass.Zone.CommercialHigh || zone == ItemClass.Zone.CommercialLow)
            {
                CitizenHelper.instance.GetVisitBehaviour(buildingID, data, ref behaviour, ref alive, ref total);
                if (alive > 0)
                {
                    int num = num = behaviour.m_wealth1Count + behaviour.m_wealth2Count * 2 + behaviour.m_wealth3Count * 3;
                    education = (num * 18 + (alive >> 1)) / alive;
                    happy     = behaviour.m_wellbeingAccumulation / (float)alive;
                    commute   = 0;
                    return;
                }
            }
            else if (zone == ItemClass.Zone.Office)
            {
                CitizenHelper.instance.GetWorkBehaviour(buildingID, data, ref behaviour, ref alive, ref total);
                int num = behaviour.m_educated1Count + behaviour.m_educated2Count * 2 + behaviour.m_educated3Count * 3;
                if (alive > 0)
                {
                    education = (num * 12 + (alive >> 1)) / alive;
                    happy     = behaviour.m_wellbeingAccumulation / (float)alive;
                    return;
                }
            }
            else
            {
                CitizenHelper.instance.GetWorkBehaviour(buildingID, data, ref behaviour, ref alive, ref total);
                int num = behaviour.m_educated1Count + behaviour.m_educated2Count * 2 + behaviour.m_educated3Count * 3;
                if (alive > 0)
                {
                    education = num = (num * 20 + (alive >> 1)) / alive;
                    happy     = behaviour.m_wellbeingAccumulation / (float)alive;
                    return;
                }
            }

            education = 0;
            happy     = 0;
            commute   = 0;
        }
Example #20
0
 public double GetServiceScore(ImmaterialResourceManager.Resource resource, ItemClass.Zone zone, ushort[] array, int num, ref int rawValue, ref int maxLimit)
 {
     rawValue = array[num + (int)resource];
     return(GetServiceScore(rawValue, resource, zone, ref maxLimit));
 }
 private static void CheckZoning(ref Building b, ItemClass.Zone zone1, ItemClass.Zone zone2, ref uint validCells, ref bool secondary, ref ZoneBlock block)
 {
     UnityEngine.Debug.LogError("FakeBuilding - Failed to redirect reverse CheckZoning()");
 }
Example #22
0
        private static void CalculateFillBuffer(ZoneTool zt, Vector3 position, Vector3 direction, float angle, ushort blockIndex, ref ZoneBlock block, ItemClass.Zone requiredZone, bool occupied1, bool occupied2)
        {
            var m_fillBuffer1 = (ulong[])typeof(ZoneTool).GetField("m_fillBuffer1", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(zt);

            float f1   = Mathf.Abs(block.m_angle - angle) * 0.6366197f;
            float num1 = f1 - Mathf.Floor(f1);

            if ((double)num1 >= 0.00999999977648258 && (double)num1 <= 0.990000009536743)
            {
                return;
            }
            int     rowCount  = block.RowCount;
            Vector3 vector3_1 = new Vector3(Mathf.Cos(block.m_angle), 0.0f, Mathf.Sin(block.m_angle)) * 8f;
            Vector3 vector3_2 = new Vector3(vector3_1.z, 0.0f, -vector3_1.x);

            for (int z = 0; z < rowCount; ++z)
            {
                Vector3 vector3_3 = ((float)z - 3.5f) * vector3_2;
                for (int x = 0; x < 4; ++x)
                {
                    if (((long)block.m_valid & 1L << (z << 3 | x)) != 0L && block.GetZone(x, z) == requiredZone)
                    {
                        if (occupied1)
                        {
                            if (requiredZone == ItemClass.Zone.Unzoned && ((long)block.m_occupied1 & 1L << (z << 3 | x)) == 0L)
                            {
                                continue;
                            }
                        }
                        else if (occupied2)
                        {
                            if (requiredZone == ItemClass.Zone.Unzoned && ((long)block.m_occupied2 & 1L << (z << 3 | x)) == 0L)
                            {
                                continue;
                            }
                        }
                        else if ((((long)block.m_occupied1 | (long)block.m_occupied2) & 1L << (z << 3 | x)) != 0L)
                        {
                            continue;
                        }
                        Vector3 vector3_4 = ((float)x - 3.5f) * vector3_1;
                        Vector3 vector3_5 = block.m_position + vector3_4 + vector3_3 - position;
                        float   f2        = (float)(((double)vector3_5.x * (double)direction.x + (double)vector3_5.z * (double)direction.z) * 0.125 + 32.0);
                        float   f3        = (float)(((double)vector3_5.x * (double)direction.z - (double)vector3_5.z * (double)direction.x) * 0.125 + 32.0);
                        int     num2      = Mathf.RoundToInt(f2);
                        int     index     = Mathf.RoundToInt(f3);
                        if (num2 >= 0 && num2 < 64 && (index >= 0 && index < 64) && ((double)Mathf.Abs(f2 - (float)num2) < 0.0125000001862645 && (double)Mathf.Abs(f3 - (float)index) < 0.0125000001862645))
                        {
                            m_fillBuffer1[index] |= (ulong)(1L << num2);
                        }
                    }
                }
            }
        }
Example #23
0
        private static bool CalculateFillBuffer(ZoneTool z, Vector3 position, Vector3 direction, ItemClass.Zone requiredZone, bool occupied1, bool occupied2)
        {
            var m_fillBuffer1 = (ulong[])typeof(ZoneTool).GetField("m_fillBuffer1", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(z);

            for (int index = 0; index < 64; ++index)
            {
                m_fillBuffer1[index] = 0UL;
            }
            if (!occupied2)
            {
                float       angle    = Mathf.Atan2(-direction.x, direction.z);
                float       num1     = position.x - 256f;
                float       num2     = position.z - 256f;
                float       num3     = position.x + 256f;
                float       num4     = position.z + 256f;
                int         num5     = Mathf.Max((int)((num1 - 46f) / 64f + FakeZoneManager.HALFGRID), 0);
                int         num6     = Mathf.Max((int)((num2 - 46f) / 64f + FakeZoneManager.HALFGRID), 0);
                int         num7     = Mathf.Min((int)((num3 + 46f) / 64f + FakeZoneManager.HALFGRID), FakeZoneManager.GRIDSIZE - 1);
                int         num8     = Mathf.Min((int)((num4 + 46f) / 64f + FakeZoneManager.HALFGRID), FakeZoneManager.GRIDSIZE - 1);
                ZoneManager instance = Singleton <ZoneManager> .instance;
                for (int index1 = num6; index1 <= num8; ++index1)
                {
                    for (int index2 = num5; index2 <= num7; ++index2)
                    {
                        ushort blockIndex = instance.m_zoneGrid[index1 * FakeZoneManager.GRIDSIZE + index2];
                        int    num9       = 0;
                        while ((int)blockIndex != 0)
                        {
                            Vector3 vector3 = instance.m_blocks.m_buffer[(int)blockIndex].m_position;
                            if ((double)Mathf.Max(Mathf.Max(num1 - 46f - vector3.x, num2 - 46f - vector3.z), Mathf.Max((float)((double)vector3.x - (double)num3 - 46.0), (float)((double)vector3.z - (double)num4 - 46.0))) < 0.0)
                            {
                                CalculateFillBuffer(z, position, direction, angle, blockIndex, ref instance.m_blocks.m_buffer[(int)blockIndex], requiredZone, occupied1, occupied2);
                            }
                            blockIndex = instance.m_blocks.m_buffer[(int)blockIndex].m_nextGridBlock;
                            if (++num9 >= ZoneManager.MAX_BLOCK_COUNT)
                            {
                                CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace);

                                break;
                            }
                        }
                    }
                }
            }
            if (((long)m_fillBuffer1[32] & 4294967296L) != 0L)
            {
                m_fillPositions.Clear();
                int     num1 = 0;
                int     num2 = 32;
                int     num3 = 32;
                int     num4 = 32;
                int     num5 = 32;
                FillPos fillPos1;
                fillPos1.m_x = (byte)32;
                fillPos1.m_z = (byte)32;
                m_fillPositions.Add(fillPos1);
                m_fillBuffer1[32] &= 18446744069414584319UL;
                while (num1 < m_fillPositions.m_size)
                {
                    FillPos fillPos2 = m_fillPositions.m_buffer[num1++];
                    if ((int)fillPos2.m_z > 0)
                    {
                        FillPos fillPos3 = fillPos2;
                        --fillPos3.m_z;
                        if (((long)m_fillBuffer1[(int)fillPos3.m_z] & 1L << (int)fillPos3.m_x) != 0L)
                        {
                            m_fillPositions.Add(fillPos3);
                            m_fillBuffer1[(int)fillPos3.m_z] &= (ulong)~(1L << (int)fillPos3.m_x);
                            if ((int)fillPos3.m_z < num3)
                            {
                                num3 = (int)fillPos3.m_z;
                            }
                        }
                    }
                    if ((int)fillPos2.m_x > 0)
                    {
                        FillPos fillPos3 = fillPos2;
                        --fillPos3.m_x;
                        if (((long)m_fillBuffer1[(int)fillPos3.m_z] & 1L << (int)fillPos3.m_x) != 0L)
                        {
                            m_fillPositions.Add(fillPos3);
                            m_fillBuffer1[(int)fillPos3.m_z] &= (ulong)~(1L << (int)fillPos3.m_x);
                            if ((int)fillPos3.m_x < num2)
                            {
                                num2 = (int)fillPos3.m_x;
                            }
                        }
                    }
                    if ((int)fillPos2.m_x < 63)
                    {
                        FillPos fillPos3 = fillPos2;
                        ++fillPos3.m_x;
                        if (((long)m_fillBuffer1[(int)fillPos3.m_z] & 1L << (int)fillPos3.m_x) != 0L)
                        {
                            m_fillPositions.Add(fillPos3);
                            m_fillBuffer1[(int)fillPos3.m_z] &= (ulong)~(1L << (int)fillPos3.m_x);
                            if ((int)fillPos3.m_x > num4)
                            {
                                num4 = (int)fillPos3.m_x;
                            }
                        }
                    }
                    if ((int)fillPos2.m_z < 63)
                    {
                        FillPos fillPos3 = fillPos2;
                        ++fillPos3.m_z;
                        if (((long)m_fillBuffer1[(int)fillPos3.m_z] & 1L << (int)fillPos3.m_x) != 0L)
                        {
                            m_fillPositions.Add(fillPos3);
                            m_fillBuffer1[(int)fillPos3.m_z] &= (ulong)~(1L << (int)fillPos3.m_x);
                            if ((int)fillPos3.m_z > num5)
                            {
                                num5 = (int)fillPos3.m_z;
                            }
                        }
                    }
                }
                for (int index = 0; index < 64; ++index)
                {
                    m_fillBuffer1[index] = 0UL;
                }
                for (int index = 0; index < m_fillPositions.m_size; ++index)
                {
                    FillPos fillPos2 = m_fillPositions.m_buffer[index];
                    m_fillBuffer1[(int)fillPos2.m_z] |= (ulong)(1L << (int)fillPos2.m_x);
                }
                return(true);
            }
            for (int index = 0; index < 64; ++index)
            {
                m_fillBuffer1[index] = 0UL;
            }
            return(false);
        }
Example #24
0
        protected override void StartActions()
        {
            if (m_ghostMode)
            {
                for (ushort a = 1; a < BuildingManager.instance.m_buildings.m_buffer.Length; a++)
                {
                    if (BuildingManager.instance.m_buildings.m_buffer[a].Info.m_buildingAI is PrivateBuildingAI)
                    {
                        Vector3            position     = BuildingManager.instance.m_buildings.m_buffer[a].m_position;
                        int                num          = Mathf.Max((int)((position.x - 35f) / 64f + 135f), 0);
                        int                num2         = Mathf.Max((int)((position.z - 35f) / 64f + 135f), 0);
                        int                num3         = Mathf.Min((int)((position.x + 35f) / 64f + 135f), 269);
                        int                num4         = Mathf.Min((int)((position.z + 35f) / 64f + 135f), 269);
                        Array16 <Building> buildings    = Singleton <BuildingManager> .instance.m_buildings;
                        ushort[]           buildingGrid = Singleton <BuildingManager> .instance.m_buildingGrid;
                        for (int i = num2; i <= num4; i++)
                        {
                            for (int j = num; j <= num3; j++)
                            {
                                ushort num5 = buildingGrid[i * 270 + j];
                                int    num6 = 0;
                                while (num5 != 0)
                                {
                                    ushort         nextGridBuilding = buildings.m_buffer[num5].m_nextGridBuilding;
                                    Building.Flags flags            = buildings.m_buffer[num5].m_flags;
                                    if ((flags & (Building.Flags.Created | Building.Flags.Deleted | Building.Flags.Demolishing | Building.Flags.Collapsed)) == Building.Flags.Created)
                                    {
                                        BuildingInfo info = buildings.m_buffer[num5].Info;
                                        if (info != null && info.m_placementStyle == ItemClass.Placement.Automatic)
                                        {
                                            ItemClass.Zone zone          = info.m_class.GetZone();
                                            ItemClass.Zone secondaryZone = info.m_class.GetSecondaryZone();
                                            if (zone != ItemClass.Zone.None && VectorUtils.LengthSqrXZ(buildings.m_buffer[num5].m_position - position) <= 1225f)
                                            {
                                                buildings.m_buffer[num5].CheckZoning(zone, secondaryZone, true);
                                            }
                                        }
                                    }
                                    num5 = nextGridBuilding;
                                    if (++num6 >= 49152)
                                    {
                                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                for (ushort i = 1; i < ZoneManager.instance.m_blocks.m_buffer.Length; i++)
                {
                    bool changed = false;
                    for (int x = 0; x < 4; x++)
                    {
                        for (int z = 0; z < 8; z++)
                        {
                            changed = ZoneMixerOverrides.GetBlockZoneSanitize(ref ZoneManager.instance.m_blocks.m_buffer[i], x, z) | changed;
                        }
                    }
                    if (changed)
                    {
                        ZoneManager.instance.m_blocks.m_buffer[i].RefreshZoning(i);
                    }
                }

                K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                {
                    icon        = ZoneMixerMod.Instance.IconName,
                    title       = Locale.Get("K45_ZM_GHOST_MODE_MODAL_TITLE"),
                    message     = Locale.Get("K45_ZM_GHOST_MODE_MODAL_MESSAGE"),
                    showButton1 = true,
                    textButton1 = Locale.Get("K45_ZM_OK_BUTTON")
                }, (x) => true);
            }
        }
 private static bool CanShowZonedResource(ImmaterialResourceManager.Resource res, ItemClass.Zone zone)
 => res == ImmaterialResourceManager.Resource.EducationElementary ||
 res == ImmaterialResourceManager.Resource.EducationHighSchool ||
 res == ImmaterialResourceManager.Resource.EducationUniversity ||
 res == ImmaterialResourceManager.Resource.HealthCare ||
 res == ImmaterialResourceManager.Resource.FireDepartment ||
 res == ImmaterialResourceManager.Resource.PoliceDepartment ||
 res == ImmaterialResourceManager.Resource.PublicTransport ||
 res == ImmaterialResourceManager.Resource.DeathCare ||
 res == ImmaterialResourceManager.Resource.Entertainment ||
 res == ImmaterialResourceManager.Resource.CrimeRate ||
 res == ImmaterialResourceManager.Resource.FireHazard ||
 res == ImmaterialResourceManager.Resource.PostService ||
 zone != ItemClass.Zone.ResidentialLow && zone != ItemClass.Zone.ResidentialHigh &&
 res == ImmaterialResourceManager.Resource.CargoTransport ||
 Singleton <LoadingManager> .instance.SupportsExpansion(Expansion.NaturalDisasters) &&
 (res == ImmaterialResourceManager.Resource.DisasterCoverage ||
  res == ImmaterialResourceManager.Resource.EarthquakeCoverage ||
  res == ImmaterialResourceManager.Resource.FirewatchCoverage ||
  res == ImmaterialResourceManager.Resource.RadioCoverage) ||
 Singleton <LoadingManager> .instance.SupportsExpansion(Expansion.Parks) &&
 (zone == ItemClass.Zone.ResidentialLow || zone == ItemClass.Zone.ResidentialHigh) &&
 (res == ImmaterialResourceManager.Resource.Attractiveness ||
  res == ImmaterialResourceManager.Resource.TourCoverage);
Example #26
0
 public bool CheckZoning(ItemClass.Zone zone1, ItemClass.Zone zone2, bool allowCollapsed)
 {
     //Its always true!
     return(true);
 }
Example #27
0
        public void ExportZones()
        {
            if (!confloaded)
            {
                return;
            }

            string columns = "Id,Boundary,Zone";
            //var a_type = typeof(ZoneBlock);
            //var properties = a_type.GetProperties();
            //foreach (var prop in properties)
            //{
            //    columns += string.Format(",{0}", prop.Name);
            //}

            List <string> txtLines = new List <string>
            {
                columns
            };

            var    zm       = ZoneManager.instance;
            string debugMsg = "";

            for (int i = 0; i < zm.m_blocks.m_buffer.Length; i++)
            {
                var zoneBlock = zm.m_blocks.m_buffer[i];
                var pos       = zoneBlock.m_position;
                if (pos == Vector3.zero)
                {
                    continue;
                }

                if (!WithinExportCoords(pos))
                {
                    continue;
                }

                Dictionary <ItemClass.Zone, ushort> zones_count = new Dictionary <ItemClass.Zone, ushort>();
                //int num = (int)((zoneBlock.m_flags & 65280u) >> 8);
                for (int z = 0; z < zoneBlock.RowCount; z++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        var zone = zoneBlock.GetZone(x, z);
                        if (!zones_count.ContainsKey(zone))
                        {
                            zones_count.Add(zone, 0);
                        }
                        zones_count[zone] += 1;
                    }
                }

                ItemClass.Zone zoneMax     = ItemClass.Zone.Unzoned;
                ushort         zoneMax_cnt = 0;
                foreach (KeyValuePair <ItemClass.Zone, ushort> a_zoneCount in zones_count)
                {
                    if (a_zoneCount.Value > zoneMax_cnt)
                    {
                        zoneMax_cnt = a_zoneCount.Value;
                        zoneMax     = a_zoneCount.Key;
                    }
                }

                int width  = 4;
                int length = zoneBlock.RowCount;

                Vector3   a              = new Vector3(Mathf.Cos(zoneBlock.m_angle), 0f, Mathf.Sin(zoneBlock.m_angle)) * 8f;
                Vector3   a2             = new Vector3(a.z, 0f, -a.x);
                Vector3   startEndcorner = pos - (float)width * 0.5f * a - (float)length * 0.5f * a2;
                Vector3[] corners        = new Vector3[]
                {
                    startEndcorner,
                    pos + (float)width * 0.5f * a - (float)length * 0.5f * a2,
                    pos + (float)width * 0.5f * a + (float)length * 0.5f * a2,
                    pos - (float)width * 0.5f * a + (float)length * 0.5f * a2,
                    startEndcorner
                };

                LatLng[] cornersLL = new LatLng[corners.Length];
                for (int j = 0; j < corners.Length; j++)
                {
                    LatLng a_cornerLL = GamePosition2LatLng(corners[j]);
                    cornersLL[j] = a_cornerLL;
                }

                var boundaryWkt = CreateWkt(cornersLL);

                string rowTxt = string.Format("{0},{1},{2}", i, boundaryWkt, zoneMax);

                txtLines.Add(rowTxt);
            }

            StreamWriter outputFile = new StreamWriter("Files/zones_cs.csv", false, new UTF8Encoding(true));

            foreach (var lineTxt in txtLines)
            {
                outputFile.WriteLine(lineTxt);
            }
            outputFile.Close();

            panel.SetMessage("GeoSkylines", "Zones export completed. ", false);

            //Debug.Log(debugMsg);
        }
Example #28
0
        public double GetServiceScore(int resourceRate, ImmaterialResourceManager.Resource resource, ItemClass.Zone zone, ref int maxLimit)
        {
            if (zone == ItemClass.Zone.ResidentialHigh || zone == ItemClass.Zone.ResidentialLow || zone == ItemClass.Zone.CommercialHigh || zone == ItemClass.Zone.CommercialLow)
            {
                switch (resource)
                {
                case ImmaterialResourceManager.Resource.NoisePollution:
                case ImmaterialResourceManager.Resource.CrimeRate:
                    maxLimit = 100;
                    return(ImmaterialResourceManager.CalculateResourceEffect(resourceRate, 10, 100, 0, 100));

                case ImmaterialResourceManager.Resource.FireHazard:
                    maxLimit = 100;
                    return(ImmaterialResourceManager.CalculateResourceEffect(resourceRate, 50, 100, 10, 50));

                case ImmaterialResourceManager.Resource.Abandonment:
                    maxLimit = 50;
                    return(ImmaterialResourceManager.CalculateResourceEffect(resourceRate, 15, 50, 100, 200));
                }
            }
            maxLimit = 500;
            return(ImmaterialResourceManager.CalculateResourceEffect(resourceRate, 100, 500, 50, 100));
        }
        public static bool CheckZoning(ref Building b, ItemClass.Zone zone1, ItemClass.Zone zone2, bool allowCollapsed)
        {
            int     width     = b.Width;
            int     length    = b.Length;
            Vector3 vector3_1 = new Vector3(Mathf.Cos(b.m_angle), 0.0f, Mathf.Sin(b.m_angle));
            Vector3 vector3_2 = new Vector3(vector3_1.z, 0.0f, -vector3_1.x);
            Vector3 vector3_3 = vector3_1 * ((float)width * 4f);
            Vector3 vector3_4 = vector3_2 * ((float)length * 4f);
            Quad3   quad3     = new Quad3();

            quad3.a = b.m_position - vector3_3 - vector3_4;
            quad3.b = b.m_position + vector3_3 - vector3_4;
            quad3.c = b.m_position + vector3_3 + vector3_4;
            quad3.d = b.m_position - vector3_3 + vector3_4;
            Vector3 vector3_5 = quad3.Min();
            Vector3 vector3_6 = quad3.Max();
            //begin mod
            int num1 = Mathf.Max((int)(((double)vector3_5.x - 46.0) / 64.0 + FakeZoneManager.HALFGRID), 0);
            int num2 = Mathf.Max((int)(((double)vector3_5.z - 46.0) / 64.0 + FakeZoneManager.HALFGRID), 0);
            int num3 = Mathf.Min((int)(((double)vector3_6.x + 46.0) / 64.0 + FakeZoneManager.HALFGRID), FakeZoneManager.GRIDSIZE - 1);
            int num4 = Mathf.Min((int)(((double)vector3_6.z + 46.0) / 64.0 + FakeZoneManager.HALFGRID), FakeZoneManager.GRIDSIZE - 1);
            //end mod
            bool        secondary  = false;
            uint        validCells = 0;
            ZoneManager instance   = Singleton <ZoneManager> .instance;

            for (int index1 = num2; index1 <= num4; ++index1)
            {
                for (int index2 = num1; index2 <= num3; ++index2)
                {
                    //begin mod
                    ushort num5 = instance.m_zoneGrid[index1 * FakeZoneManager.GRIDSIZE + index2];
                    //end mod
                    int num6 = 0;
                    while ((int)num5 != 0)
                    {
                        if (allowCollapsed || ((int)instance.m_blocks.m_buffer[(int)num5].m_flags & 4) == 0)
                        {
                            Vector3 vector3_7 = instance.m_blocks.m_buffer[(int)num5].m_position;
                            if ((double)Mathf.Max(Mathf.Max(vector3_5.x - 46f - vector3_7.x, vector3_5.z - 46f - vector3_7.z), Mathf.Max((float)((double)vector3_7.x - (double)vector3_6.x - 46.0), (float)((double)vector3_7.z - (double)vector3_6.z - 46.0))) < 0.0)
                            {
                                CheckZoning(ref b, zone1, zone2, ref validCells, ref secondary, ref instance.m_blocks.m_buffer[(int)num5]);
                            }
                        }
                        num5 = instance.m_blocks.m_buffer[(int)num5].m_nextGridBlock;
                        if (++num6 >= 49152)
                        {
                            CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace);

                            break;
                        }
                    }
                }
            }
            for (int index1 = 0; index1 < length; ++index1)
            {
                for (int index2 = 0; index2 < width; ++index2)
                {
                    if (((int)validCells & 1 << (index1 << 3) + index2) == 0)
                    {
                        return(false);
                    }
                }
            }
            if (!secondary ? zone1 == ItemClass.Zone.CommercialHigh || zone1 == ItemClass.Zone.ResidentialHigh : zone2 == ItemClass.Zone.CommercialHigh || zone2 == ItemClass.Zone.ResidentialHigh)
            {
                b.m_flags |= Building.Flags.HighDensity;
            }
            else
            {
                b.m_flags &= ~Building.Flags.HighDensity;
            }
            return(true);
        }
Example #30
0
        private void AddCheckboxZone(int idx, UIHelperExtension uiHelperExt, ItemClass.Zone zone)
        {
            UITextureAtlas thumbAtlas   = FindObjectOfType <ZoningPanel>().GetComponentInChildren <UIScrollablePanel>().atlas;
            UICheckBox     checkLR      = uiHelperExt.AddCheckboxNoLabel($"ConfigZ{idx}{zone}");
            var            checkedObj   = (UISprite)checkLR.checkedBoxObject;
            UISprite       uncheckedObj = checkLR.Find <UISprite>("Unchecked");

            checkedObj.spriteName         = $"Zoning{zone}";
            uncheckedObj.spriteName       = $"Zoning{zone}Disabled";
            checkedObj.atlas              = thumbAtlas;
            uncheckedObj.atlas            = thumbAtlas;
            checkLR.size                  = new Vector2(47, 32);
            checkedObj.size               = new Vector2(47, 32);
            uncheckedObj.size             = new Vector2(47, 32);
            checkedObj.relativePosition   = default;
            uncheckedObj.relativePosition = default;

            checkLR.tooltip = Locale.Get("ZONEDBUILDING_TITLE", zone.ToString());

            checkLR.isChecked          = CustomZoneData.Instance[idx].HasZone(zone);
            checkLR.eventCheckChanged += (x, y) =>
            {
                if (!m_loading)
                {
                    if (y)
                    {
                        CustomZoneData.Instance[idx].AddToZone(zone);
                    }
                    else
                    {
                        CustomZoneData.Instance[idx].RemoveFromZone(zone);
                    }
                }
            };

            CustomZoneData.EventOneChanged += (x) =>
            {
                if (x == idx)
                {
                    try
                    {
                        m_loading         = true;
                        checkLR.isChecked = CustomZoneData.Instance[idx].HasZone(zone);
                    }
                    finally
                    {
                        m_loading = false;
                    }
                }
            };

            CustomZoneData.EventAllChanged += () =>
            {
                try
                {
                    m_loading         = true;
                    checkLR.isChecked = CustomZoneData.Instance[idx].HasZone(zone);
                }
                finally
                {
                    m_loading = false;
                }
            };
        }