Exemplo n.º 1
0
        public override int CalculateHomeCount(Randomizer r, int width, int length)
        {
            BuildingInfo item        = this.m_info;
            int          returnValue = 1;

            if (!DataStore.prefabHouseHolds.TryGetValue(item.gameObject.GetHashCode(), out returnValue))
            {
                returnValue = AI_Utils.calculatePrefabHousehold(width, length, ref item);
                DataStore.prefabHouseHolds.Add(item.gameObject.GetHashCode(), returnValue);
            }
            return(returnValue);
        }
        public override int CalculateHomeCount(ItemClass.Level level, Randomizer r, int width, int length)
        {
            BuildingInfo item        = this.m_info;
            int          returnValue = 0;

            if (!DataStore.prefabHouseHolds.TryGetValue(item.gameObject.GetHashCode(), out returnValue))
            {
                int[] array = GetArray(this.m_info, (int)level);
                returnValue = AI_Utils.CalculatePrefabHousehold(width, length, ref item, ref array, (int)level);
                DataStore.prefabHouseHolds.Add(item.gameObject.GetHashCode(), returnValue);
            }
            return(returnValue);
        }
        public override int CalculateHomeCount(Randomizer r, int width, int length)
        {
            BuildingInfo item        = this.m_info;
            int          returnValue = 0;

            if (!DataStore.prefabHouseHolds.TryGetValue(item.gameObject.GetHashCode(), out returnValue))
            {
                int   level = (int)(item.m_class.m_level >= 0 ? item.m_class.m_level : 0); // Force it to 0 if the level was set to None
                int[] array = GetArray(this.m_info, level);
                returnValue = AI_Utils.CalculatePrefabHousehold(width, length, ref item, ref array, level);
                DataStore.prefabHouseHolds.Add(item.gameObject.GetHashCode(), returnValue);
            }
            return(returnValue);
        }
        public override void CalculateWorkplaceCount(ItemClass.Level level, Randomizer r, int width, int length, out int level0, out int level1, out int level2, out int level3)
        {
            BuildingInfo item = this.m_info;

            PrefabEmployStruct output;

            // If not seen prefab, calculate
            if (!DataStore.prefabWorkerVisit.TryGetValue(item.gameObject.GetHashCode(), out output))
            {
                int[] array = getArray(item, EXTRACT_LEVEL);
                AI_Utils.CalculateprefabWorkerVisit(width, length, ref item, 3, ref array, out output);
                DataStore.prefabWorkerVisit.Add(item.gameObject.GetHashCode(), output);
            }

            level0 = output.level0;
            level1 = output.level1;
            level2 = output.level2;
            level3 = output.level3;
        }
        public override void GetConsumptionRates(Randomizer r, int productionRate, out int electricityConsumption, out int waterConsumption, out int sewageAccumulation, out int garbageAccumulation, out int incomeAccumulation)
        {
            ItemClass item  = this.m_info.m_class;
            int       level = (int)(item.m_level >= 0 ? item.m_level : 0); // Force it to 0 if the level was set to None

            electricityConsumption = DataStore.office[level][DataStore.POWER];
            waterConsumption       = DataStore.office[level][DataStore.WATER];
            sewageAccumulation     = DataStore.office[level][DataStore.SEWAGE];
            garbageAccumulation    = DataStore.office[level][DataStore.GARBAGE];

            int landVal = AI_Utils.getLandValueIncomeComponent(r.seed);

            incomeAccumulation = DataStore.office[level][DataStore.INCOME] + landVal;

            electricityConsumption = Mathf.Max(100, productionRate * electricityConsumption) / 100;
            waterConsumption       = Mathf.Max(100, productionRate * waterConsumption) / 100;
            sewageAccumulation     = Mathf.Max(100, productionRate * sewageAccumulation) / 100;
            garbageAccumulation    = Mathf.Max(100, productionRate * garbageAccumulation) / 100;
            incomeAccumulation     = productionRate * incomeAccumulation;
        }
        public override void CalculateWorkplaceCount(Randomizer r, int width, int length, out int level0, out int level1, out int level2, out int level3)
        {
            ulong        seed  = r.seed;
            BuildingInfo item  = this.m_info;
            int          level = (int)(item.m_class.m_level >= 0 ? item.m_class.m_level : 0); // Force it to 0 if the level was set to None

            prefabEmployStruct output;

            // If not seen prefab, calculate
            if (!DataStore.prefabWorkerVisit.TryGetValue(item.gameObject.GetHashCode(), out output))
            {
                AI_Utils.calculateprefabWorkerVisit(width, length, ref item, 10, ref DataStore.office[level], out output);
                DataStore.prefabWorkerVisit.Add(item.gameObject.GetHashCode(), output);
            }

            level0 = output.level0;
            level1 = output.level1;
            level2 = output.level2;
            level3 = output.level3;
        }
        public override void GetConsumptionRates(Randomizer r, int productionRate, out int electricityConsumption, out int waterConsumption, out int sewageAccumulation, out int garbageAccumulation, out int incomeAccumulation)
        {
            ulong     seed = r.seed;
            ItemClass item = this.m_info.m_class;

            int[] array = getArray(this.m_info, EXTRACT_LEVEL);

            electricityConsumption = array[DataStore.POWER];
            waterConsumption       = array[DataStore.WATER];
            sewageAccumulation     = array[DataStore.SEWAGE];
            garbageAccumulation    = array[DataStore.GARBAGE];

            int landVal = AI_Utils.getLandValueIncomeComponent(r.seed);

            incomeAccumulation = array[DataStore.INCOME] + landVal;

            electricityConsumption = Mathf.Max(100, productionRate * electricityConsumption) / 100;
            waterConsumption       = Mathf.Max(100, productionRate * waterConsumption) / 100;
            sewageAccumulation     = Mathf.Max(100, productionRate * sewageAccumulation) / 100;
            garbageAccumulation    = Mathf.Max(100, productionRate * garbageAccumulation) / 100;
            incomeAccumulation     = productionRate * incomeAccumulation;
        }
        public override void GetConsumptionRates(ItemClass.Level level, Randomizer r, int productionRate, out int electricityConsumption, out int waterConsumption, out int sewageAccumulation, out int garbageAccumulation, out int incomeAccumulation, out int mailAccumulation)
        {
            ItemClass item = this.m_info.m_class;

            int[] array = GetArray(this.m_info, (int)level);
            electricityConsumption = array[DataStore.POWER];
            waterConsumption       = array[DataStore.WATER];
            sewageAccumulation     = array[DataStore.SEWAGE];
            garbageAccumulation    = array[DataStore.GARBAGE];
            mailAccumulation       = array[DataStore.MAIL];

            int landVal = AI_Utils.GetLandValueIncomeComponent(r.seed);

            incomeAccumulation = array[DataStore.INCOME] + landVal;

            electricityConsumption = Mathf.Max(100, productionRate * electricityConsumption) / 100;
            waterConsumption       = Mathf.Max(100, productionRate * waterConsumption) / 100;
            sewageAccumulation     = Mathf.Max(100, productionRate * sewageAccumulation) / 100;
            garbageAccumulation    = Mathf.Max(100, productionRate * garbageAccumulation) / 100;
            incomeAccumulation     = productionRate * incomeAccumulation;
            mailAccumulation       = Mathf.Max(100, productionRate * mailAccumulation) / 100;
        }