public static bool mineOut(Map map, IntVec3 pos) { Designator_Mine mine = Find.ReverseDesignatorDatabase.Get <Designator_Mine>(); if (mine != null && mine.CanDesignateCell(pos).Equals(AcceptanceReport.WasAccepted)) { mine.DesignateSingleCell(pos); return(true); } return(false); }
static void Postfix(Pawn pawn) { // A cell grid around the mining pawn covering an area two cells away from it var cellsAround = GenAdj.CellsOccupiedBy(pawn.Position, pawn.Rotation, new IntVec2(5, 5)); var dm = new Designator_Mine(); foreach (IntVec3 cell in cellsAround) { // Find out what Thing, of the Bulding, category is on the cell Thing thing = pawn.Map.thingGrid.ThingAt(cell, ThingCategory.Building); if ( thing != null && IsOre(thing.def) && HasntBeenDesignatedYet(dm, cell) && CanReach(pawn, cell) ) { // "Order" the cell to be mined dm.DesignateSingleCell(cell); } } }
//Patch to cancel engraving on mining designation public static void DesignateSingleCell(Designator_Mine __instance, IntVec3 loc) { __instance.Map.designationManager.TryRemoveDesignation(loc, DesignationDefOf.EngraveWall); }
// Wether an mine "Order" hassn't been placed on the cell yet private static bool HasntBeenDesignatedYet(Designator_Mine dm, IntVec3 cell) { return(dm.CanDesignateCell(cell).Accepted); }