public static FloatMenu MakeModeMenu(Building_Quarry __instance)
        {
            List <FloatMenuOption> floatMenu = new List <FloatMenuOption>();

            if (__instance.mineModeToggle != MiningMode.Resources)
            {
                floatMenu.Add(new FloatMenuOption(Static.LabelMineResources, delegate()
                {
                    __instance.mineModeToggle = MiningMode.Resources;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            if (__instance.mineModeToggle != MiningMode.Blocks && QuarryDefOf.Stonecutting.IsFinished)
            {
                floatMenu.Add(new FloatMenuOption(Static.LabelMineBlocks, delegate()
                {
                    __instance.mineModeToggle = MiningMode.Blocks;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            if (__instance.mineModeToggle != MiningMode.Chunks)
            {
                floatMenu.Add(new FloatMenuOption(Static.LabelMineChunks, delegate()
                {
                    __instance.mineModeToggle = MiningMode.Chunks;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }

            return(new FloatMenu(floatMenu));
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_Quarry quarry = t as Building_Quarry;

            // Make sure a permitted quarry is found, and that it has resources, and does not have too many workers
            if (quarry == null || quarry.IsForbidden(pawn) || quarry.Depleted)
            {
                return(null);
            }

            if (!quarry.Unowned && !quarry.AssignedPawns.Contains(pawn))
            {
                return(null);
            }

            // Find a cell within the middle of the quarry to mine at
            IntVec3  cell = IntVec3.Invalid;
            CellRect rect = quarry.OccupiedRect().ContractedBy(quarry.WallThickness);

            foreach (IntVec3 c in rect.Cells.InRandomOrder())
            {
                if (pawn.Map.reservationManager.CanReserve(pawn, c, 1))
                {
                    cell = c;
                    break;
                }
            }
            // If a cell wasn't found, fail
            if (!cell.IsValid)
            {
                return(null);
            }

            return(new Job(QuarryDefOf.QRY_MineQuarry, cell));
        }
Exemple #3
0
 private static void MineModeChunks(Building_Quarry __instance)
 {
     __instance.mineModeToggle = MiningMode.Chunks;
 }
Exemple #4
0
 private static void MineModeResources(Building_Quarry __instance)
 {
     __instance.mineModeToggle = MiningMode.Resources;
 }