예제 #1
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            RemoveAllOwners();

            CellRect rect = this.OccupiedRect();
            // Remove this area from the quarry grid. Quarries can never be built here again
            //     Map.GetComponent<QuarryGrid>().RemoveFromGrid(rect);

            //    Log.Message("Quarry at "+ QuarryPercent+ " "+ (int)(rect.Count() * (QuarryPercent / 100)) + " of " + rect.Count()+" cells should retain their quarrability");
            List <IntVec3> cells = GenAdj.CellsOccupiedBy(this).ToList();

            for (int i = 0; i < cells.Count; i++)
            {
                IntVec3 c = cells[i];
                if (rect.Count() * (QuarryPercent / 100) == 0 || rect.Count() * (QuarryPercent / 100) < i)
                {
                    Map.GetComponent <QuarryGrid>().RemoveFromGrid(c);
                }
                // Change the terrain here back to quarried stone, removing the walls
                Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround);
            }
            if (!QuarrySettings.letterSent && !TutorSystem.AdaptiveTrainingEnabled)
            {
                Find.LetterStack.ReceiveLetter(Static.LetterLabel, Static.LetterText, QuarryDefOf.CuproLetter, new RimWorld.Planet.GlobalTargetInfo(Position, Map));
                QuarrySettings.letterSent = true;
            }
            if (TutorSystem.AdaptiveTrainingEnabled)
            {
                LessonAutoActivator.TeachOpportunity(QuarryDefOf.QRY_ReclaimingSoil, OpportunityType.GoodToKnow);
            }
            base.Destroy(mode);
        }