public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (t.Faction != pawn.Faction) { return(false); } Building building = t as Building; if (building == null) { return(false); } if (building.IsForbidden(pawn)) { return(false); } LocalTargetInfo target = building; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } CompMineShaft compMiningPlatform = building.TryGetComp <CompMineShaft>(); return(compMiningPlatform.CanMine() && building.Map.designationManager.DesignationOn(building, DesignationDefOf.Deconstruct) == null && !building.IsBurning()); }
protected override IEnumerable <Toil> MakeNewToils() { CompMineShaft compMiningPlatform = this.job.targetA.Thing.TryGetComp <CompMineShaft>(); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOnThingHavingDesignation(TargetIndex.A, DesignationDefOf.Deconstruct); this.FailOn(delegate() { return(!compMiningPlatform.CanMine()); }); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); yield return(MineStuffFromMine()); if (compMiningPlatform.ProspectMode) { yield return(ProspectFirst()); } else { yield return(MineShaftYieldStuff()); } yield return(ApplyHeDiff()); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOnThingHavingDesignation(TargetIndex.A, DesignationDefOf.Deconstruct); this.FailOn(delegate() { CompMineShaft compMiningPlatform = this.job.targetA.Thing.TryGetComp <CompMineShaft>(); return(!compMiningPlatform.CanMine()); }); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil work = new Toil(); work.tickAction = delegate() { Pawn actor = work.actor; Building building = (Building)actor.CurJob.targetA.Thing; CompMineShaft comp = building.GetComp <CompMineShaft>(); var hungerOnPawn = work.actor?.health?.hediffSet?.GetFirstHediffOfDef(OreDefOf.MinersHunger); if (hungerOnPawn == null) { Hediff hediff = HediffMaker.MakeHediff(OreDefOf.MinersHunger, work.actor, null); hediff.Severity = 0.01f; work.actor.health.AddHediff(hediff, null, null); } else { hungerOnPawn.Severity += 0.01f; } /* * if (comp.ProspectMode) * { * comp.Prospecting(actor); * } * else * { * comp.MiningWorkDone(actor); * } */ actor.skills.Learn(SkillDefOf.Mining, 0.065f, false); }; work.defaultCompleteMode = ToilCompleteMode.Never; work.WithEffect(EffecterDefOf.Drill, TargetIndex.A); work.WithEffect(EffecterDefOf.Mine, TargetIndex.B); work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); work.activeSkill = (() => SkillDefOf.Mining); yield return(work); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOnThingHavingDesignation(TargetIndex.A, DesignationDefOf.Deconstruct); this.FailOn(delegate() { CompMineShaft compMiningPlatform = this.job.targetA.Thing.TryGetComp <CompMineShaft>(); return(!compMiningPlatform.CanMine()); }); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil work = new Toil(); work.tickAction = delegate() { Pawn actor = work.actor; Building building = (Building)actor.CurJob.targetA.Thing; CompMineShaft comp = building.GetComp <CompMineShaft>(); if (comp.ProspectMode) { comp.Prospecting(actor); } else { comp.MiningWorkDone(actor); } actor.skills.Learn(SkillDefOf.Mining, 0.065f, false); }; work.defaultCompleteMode = ToilCompleteMode.Never; work.WithEffect(EffecterDefOf.Drill, TargetIndex.A); work.WithEffect(EffecterDefOf.Mine, TargetIndex.B); work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); work.activeSkill = (() => SkillDefOf.Mining); yield return(work); yield break; }