Exemple #1
0
        //when the building is destroyed:
        public override void DestroyFactionEntityLocal(bool upgrade)
        {
            base.DestroyFactionEntityLocal(upgrade);

            if (building.IsFree() == false)        //if this is not a free building
            {
                if (building.BorderComp)           //if it has a border component:
                {
                    building.BorderComp.Disable(); //deactivate the border component
                }
                else
                {
                    if (building.CurrentCenter != null) //If the building is not a center then we'll check if it occupies a place in the defined buildings for its center:
                    {
                        building.CurrentCenter.UnegisterBuilding(building);
                    }
                }

                building.RemovePopulationSlots(); //remove population added by this building when destroyed

                //Remove bonuses from nearby resources:
                building.ToggleResourceBonus(false);
            }

            if (upgrade == false)
            {
                CustomEvents.OnBuildingDestroyed(building);
                //Check if it's the capital building, it's not getting upgraded and the faction defeated condition is set to capital destructionss
                if (building.FactionCapital == true && gameMgr.GetDefeatCondition() == DefeatConditions.destroyCapital)
                {
                    gameMgr.OnFactionDefeated(building.FactionID);
                }
            }
        }