/// <summary>
        /// Checks to see if a building should be demolished if it's not in a district with the relevant specialisation.
        /// Called via Harmony Transpiler patches.
        /// </summary>
        /// <param name="buildingData">Building instance data</param>
        internal static void CheckSpecial(ref Building buildingData)
        {
            bool isRICO = RICOUtils.IsRICOAI(buildingData.Info.GetAI() as PrivateBuildingAI);

            // Check if the relevant 'ignore specialisation' setting is set.
            // If it is, we just don't do anything.  Otherwise, we mimic the base game's code for this ocurrence.
            if (!(ModSettings.noSpecOther && !isRICO) && !(ModSettings.noSpecRico && isRICO))
            {
                buildingData.m_flags |= Building.Flags.Demolishing;
                Singleton <SimulationManager> .instance.m_currentBuildIndex++;
            }
        }
        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 #3
0
        /// <summary>
        /// Harmony Postfix patch to skip 'gradual construction' for plopped RICO growables, and/or to apply the 'Make Historical' and/or 'Lock level' settings on building creation, accoriding to settings.
        /// </summary>
        /// <param name="__result">Original method result (unchanged)</param>
        /// <param name="info">BuildingInfo prefab for this building (unchanged)</param>
        /// <param name="position">Building position (ignored)</param>
        /// <param name="angle">Building rotation (ignored)</param>
        /// <param name="relocating">Building relocation (ignored)</param>
        /// <param name="needMoney">Is money needed (ignored)</param>
        /// <param name="fixedHeight">Fixed height (ignored)</param>
        internal static void Postfix(ref ushort __result, ref BuildingInfo info, Vector3 position, float angle, int relocating, bool needMoney, bool fixedHeight)
        {
            // Check that we have a valid building ID.
            if (__result == 0)
            {
                return;
            }

            // Get building AI.
            PrivateBuildingAI buildingAI = info.GetAI() as PrivateBuildingAI;

            // Only interested in private building AI.
            if (buildingAI != null)
            {
                // Check if AI is a RICO custom AI type.
                bool isRICO = RICOUtils.IsRICOAI(buildingAI);

                // Check if it's a RICO custom AI type.
                // Enable 'ploppable growables' if option is set.
                if ((ModSettings.plopOther && !isRICO) || (ModSettings.plopRico && isRICO))
                {
                    // Check to see if construction time is greater than zero.
                    if (buildingAI.m_constructionTime > 0)
                    {
                        Singleton <BuildingManager> .instance.m_buildings.m_buffer[__result].m_frame0.m_constructState = byte.MaxValue;
                        BuildingCompletedRev(buildingAI, __result, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[__result]);

                        // Have to do this manually as CommonBuildingAI.BuildingCompleted won't if construction time isn't zero.
                        Singleton <BuildingManager> .instance.UpdateBuildingRenderer(__result, updateGroup : true);
                    }
                }

                // Enable 'Make Historical' if option is set.
                if ((ModSettings.historicalOther && !isRICO) || (ModSettings.historicalRico && isRICO))
                {
                    info.m_buildingAI.SetHistorical(__result, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[__result], historical: true);
                }

                // Enable ABLC level lock if option is set and ABLC is running.
                if (ModUtils.ablcLockBuildingLevel != null && ((ModSettings.lockLevelOther && !isRICO) || (ModSettings.lockLevelRico && isRICO)))
                {
                    ModUtils.ablcLockBuildingLevel.Invoke(null, new object[] { __result, Singleton <BuildingManager> .instance.m_buildings.m_buffer[__result].m_level });
                }
            }
        }
 /// <summary>
 /// Checks to see whether or not the specified building is a Ploppable RICO building.
 /// </summary>
 /// <param name="buildingID">Building instance ID</param>
 /// <returns>True if this is a Ploppable RICO building, false otherwise</returns>
 private bool IsRICOBuilding(ushort buildingID) => RICOUtils.IsRICOAI(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as PrivateBuildingAI);