protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); Toil gaze = new Toil(); gaze.initAction = delegate() { this.pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; }; gaze.tickAction = delegate() { float num = this.pawn.Map.gameConditionManager.AggregateSkyGazeJoyGainFactor(this.pawn.Map); Pawn pawn = this.pawn; float extraJoyGainFactor = num; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, null); }; gaze.defaultCompleteMode = ToilCompleteMode.Delay; gaze.defaultDuration = this.job.def.joyDuration; gaze.FailOn(() => this.pawn.Position.Roofed(this.pawn.Map)); gaze.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); yield return(gaze); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil research = new Toil(); research.tickAction = delegate { Pawn actor = research.actor; float num = 1.1f * actor.GetStatValue(StatDefOf.ResearchSpeed, true); num *= this.$this.TargetThingA.GetStatValue(StatDefOf.ResearchSpeedFactor, true); Find.ResearchManager.ResearchPerformed(num, actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.11f, false); actor.GainComfortFromCellIfPossible(); }; research.FailOn(() => this.$this.Project == null); research.FailOn(() => !this.$this.Project.CanBeResearchedAt(this.$this.ResearchBench, false)); research.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); research.WithEffect(EffecterDefOf.Research, TargetIndex.A); research.WithProgressBar(TargetIndex.A, delegate { ResearchProjectDef project = this.$this.Project; if (project == null) { return(0f); } return(project.ProgressPercent); }, false, -0.5f); research.defaultCompleteMode = ToilCompleteMode.Delay; research.defaultDuration = 4000; yield return(research); yield return(Toils_General.Wait(2)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); if (TargetThingA.def.building != null && TargetThingA.def.building.isSittable) { isSitting = true; yield return(Toils_General.Do(delegate { job.SetTarget(TargetIndex.B, TargetThingA.InteractionCell + TargetThingA.Rotation.FacingCell); })); } Toil governToil = new Toil(); governToil.tickAction = Govern_TickAction; governToil.FailOn(() => Utility.RimocracyComp.Governance >= Utility.RimocracyComp.GovernanceTarget); governToil.FailOn(() => !pawn.IsLeader()); governToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); governToil.defaultCompleteMode = ToilCompleteMode.Delay; governToil.defaultDuration = GenDate.TicksPerHour * 2; governToil.activeSkill = () => SkillDefOf.Social; yield return(governToil); yield return(Toils_General.Wait(2, TargetIndex.None)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_General.Do(delegate { job.SetTarget(TargetIndex.B, Throne.InteractionCell + Throne.Rotation.FacingCell); })); Toil toil = new Toil(); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); toil.FailOn(() => Throne.AssignedPawn != pawn); toil.FailOn(() => RoomRoleWorker_ThroneRoom.Validate(Throne.GetRoom()) != null); toil.tickAction = delegate { pawn.GainComfortFromCellIfPossible(); pawn.skills.Learn(SkillDefOf.Social, 0.3f); if (pawn.IsHashIntervalTick(MoteInterval.RandomInRange)) { MoteMaker.MakeSpeechBubble(pawn, moteIcon); } rotateToFace = TargetIndex.B; }; toil.defaultCompleteMode = ToilCompleteMode.Never; yield return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); Toil toil = new Toil { initAction = delegate { //pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; pawn.rotationTracker.FaceCell(TargetB.Cell); //pawn.jobs. }, tickAction = delegate { float extraJoyGainFactor = thrownRockNum * .2f; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor); TickAction(); }, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = job.def.joyDuration }; toil.FailOn(() => pawn.Position.Roofed(pawn.Map)); toil.FailOn(() => !JoyUtility.EnjoyableOutsideNow(pawn)); yield return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil research = new Toil(); research.tickAction = delegate { Pawn actor = research.actor; float statValue = actor.GetStatValue(StatDefOf.ResearchSpeed); statValue *= base.TargetThingA.GetStatValue(StatDefOf.ResearchSpeedFactor); Find.ResearchManager.ResearchPerformed(statValue, actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.1f); actor.GainComfortFromCellIfPossible(chairsOnly: true); }; research.FailOn(() => Project == null); research.FailOn(() => !Project.CanBeResearchedAt(ResearchBench, ignoreResearchBenchPowerStatus: false)); research.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); research.WithEffect(EffecterDefOf.Research, TargetIndex.A); research.WithProgressBar(TargetIndex.A, () => Project?.ProgressPercent ?? 0f); research.defaultCompleteMode = ToilCompleteMode.Delay; research.defaultDuration = 4000; research.activeSkill = () => SkillDefOf.Intellectual; yield return(research); yield return(Toils_General.Wait(2)); }
/* * public static Building_HackingTable HackingTable(this Pawn pawn) * { * List<Thing> thingList = pawn.Position.GetThingList(pawn.Map); * Building_HackingTable hackingTable = null; * for (int i = 0; i < thingList.Count; i++) * { * hackingTable = (thingList[i] as Building_HackingTable); * if (hackingTable != null) * { * break; * } * } * if (hackingTable == null) * { * return null; * } * if(hackingTable.GetCurOccupant(0) == pawn) * { * return hackingTable; * } * return null; * } */ /* * public static bool OnHackingTable(this Pawn pawn) * { * if(pawn.HackingTable() != null) * { * return true; * } * return false; * } */ public static void FailOnPlatformNoLongerUsable(this Toil toil, TargetIndex bedIndex) { toil.FailOnDespawnedOrNull(bedIndex); toil.FailOn(() => ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).IsBurning()); toil.FailOn(() => !HealthAIUtility.ShouldSeekMedicalRest(toil.actor) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(toil.actor) && ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).Medical); toil.FailOn(() => toil.actor.IsColonist && !toil.actor.CurJob.ignoreForbidden && !toil.actor.Downed && toil.actor.CurJob.GetTarget(bedIndex).Thing.IsForbidden(toil.actor)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_General.Do(delegate { job.SetTarget(TargetIndex.B, Throne.InteractionCell + Throne.Rotation.FacingCell); })); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil toil = new Toil(); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); toil.FailOn(() => Throne.AssignedPawn != pawn); toil.FailOn(() => RoomRoleWorker_ThroneRoom.Validate(Throne.GetRoom()) != null); toil.FailOn(() => !MeditationUtility.CanMeditateNow(pawn) || !MeditationUtility.SafeEnvironmentalConditions(pawn, base.TargetLocA, base.Map)); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = job.def.joyDuration; toil.tickAction = delegate { if (pawn.mindState.applyThroneThoughtsTick == 0) { pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 10000; } else if (pawn.mindState.applyThroneThoughtsTick <= Find.TickManager.TicksGame) { pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 60000; ThoughtDef thoughtDef = null; if (Throne.GetRoom().Role == RoomRoleDefOf.ThroneRoom) { thoughtDef = ThoughtDefOf.ReignedInThroneroom; } if (thoughtDef != null) { int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(Throne.GetRoom().GetStat(RoomStatDefOf.Impressiveness)); if (thoughtDef.stages[scoreStageIndex] != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex)); } } } rotateToFace = TargetIndex.B; MeditationTick(); if (job.ignoreJoyTimeAssignment && pawn.IsHashIntervalTick(300)) { pawn.jobs.CheckForJobOverride(); } }; yield return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { JobDriver_CultResearch jobDriver_Research = this; this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil research = new Toil(); research.tickAction = delegate { Pawn actor = research.actor; float statValue = actor.GetStatValue(StatDefOf.ResearchSpeed); statValue *= jobDriver_Research.TargetThingA.GetStatValue(StatDefOf.ResearchSpeedFactor); Find.ResearchManager.ResearchPerformed(statValue, actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.1f); actor.GainComfortFromCellIfPossible(chairsOnly: true); // -- new code -- if (Find.ResearchManager.currentProj != null && Find.ResearchManager.currentProj.HasModExtension <ForbiddenResearchExtension>()) { Spirituality need = pawn.needs.TryGetNeed <Spirituality>(); if (need != null) { need.Gain(); } } // --- ------ --- }; research.FailOn(() => jobDriver_Research.Project == null); research.FailOn(() => !jobDriver_Research.Project.CanBeResearchedAt(jobDriver_Research.ResearchBench, ignoreResearchBenchPowerStatus: false)); // -- new code -- research.FailOn(() => !Find.ResearchManager.currentProj.HasModExtension <ForbiddenResearchExtension>() && jobDriver_Research.ResearchBench.def.defName == "Cults_OccultResearchBench" ); // --- ------ --- research.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); research.WithEffect(EffecterDefOf.Research, TargetIndex.A); research.WithProgressBar(TargetIndex.A, () => jobDriver_Research.Project?.ProgressPercent ?? 0f); research.defaultCompleteMode = ToilCompleteMode.Delay; research.defaultDuration = 4000; research.activeSkill = (() => SkillDefOf.Intellectual); yield return(research); yield return(Toils_General.Wait(2)); }
public override IEnumerable <Toil> MakeNewToils() { Toil toil = new Toil(); toil.defaultCompleteMode = ToilCompleteMode.Never; toil.FailOn(() => pawn.UnableToControl() || this.Mech.DestroyedOrNull() || this.Mech.Downed); toil.initAction = new Action(delegate { pawn.pather.StopDead(); }); toil.tickAction = new Action(delegate { int radius = Utilities.GetRemoteControlRadius(pawn) - 5; if (Utilities.QuickDistanceSquared(pawn.Position, this.Mech.Position) > radius * radius) { ReadyForNextToil(); return; } if (GenSight.LineOfSight(pawn.Position, Mech.Position, Mech.Map, false, null, 0, 0)) { pawn.CurJob.targetC = this.Mech; rotateToFace = TargetIndex.C; } }); yield return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); var gaze = new Toil { initAction = delegate { pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; }, tickAction = delegate { BrrrGlobals.JoyTickOohCheckEnd(pawn); }, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = job.def.joyDuration }; gaze.FailOn(() => pawn.Position.Roofed(pawn.Map)); gaze.AddFailCondition(delegate { var actor = gaze.actor; var needs = actor.needs; if (needs?.food == null) { return(false); } var needs2 = actor.needs; var num = needs2 != null ? new float?(needs2.food.CurLevelPercentage) : null; var percentageThreshHungry = actor.needs.food.PercentageThreshHungry; if ((num.GetValueOrDefault() < percentageThreshHungry) & (num != null)) { return(true); } return(false); }); yield return(gaze); }
protected override IEnumerable <Toil> MakeNewToils() { Pawn target = this.TargetA.Thing as Pawn; float xp = 5f * Mathf.Pow(5f, target.RaceProps.wildness); this.FailOnDestroyedNullOrForbidden(TargetIndex.A); yield return(DSFIToils_Moving.GotoNearTarget(TargetIndex.A, Danger.Some, moveDistance, lookDistance)); Toil observing = Toils_General.Wait(1500); observing.FailOnDestroyedOrNull(TargetIndex.A); observing.socialMode = RandomSocialMode.SuperActive; observing.handlingFacing = true; observing.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); observing.tickAction = () => { if (pawn.IsHashIntervalTick(20)) { pawn.skills.Learn(SkillDefOf.Animals, 5f); pawn.rotationTracker.FaceTarget(target); if (!pawn.CanSee(target) || !pawn.Position.InHorDistOf(target.Position, lookDistance)) { this.ReadyForNextToil(); } } }; yield return(observing); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(() => OtherFiance.Drafted || !pawn.Position.AdjacentTo8WayOrInside(OtherFiance)); Toil toil = new Toil(); toil.initAction = delegate { ticksLeftToMarry = 2500; }; toil.tickAction = delegate { ticksLeftToMarry--; if (ticksLeftToMarry <= 0) { ticksLeftToMarry = 0; ReadyForNextToil(); } }; toil.defaultCompleteMode = ToilCompleteMode.Never; toil.FailOn(() => !pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, OtherFiance)); yield return(toil); Toil toil2 = new Toil(); toil2.defaultCompleteMode = ToilCompleteMode.Instant; toil2.initAction = delegate { if (pawn.thingIDNumber < OtherFiance.thingIDNumber) { MarriageCeremonyUtility.Married(pawn, OtherFiance); } }; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { Toil toil = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell); toil.AddPreTickAction(delegate { if (job.exitMapOnArrival && pawn.Map.exitMapGrid.IsExitCell(pawn.Position)) { TryExitMap(); } }); toil.FailOn(() => job.failIfCantJoinOrCreateCaravan && !CaravanExitMapUtility.CanExitMapAndJoinOrCreateCaravanNow(pawn)); yield return(toil); Toil toil2 = new Toil(); toil2.initAction = delegate { if (pawn.mindState != null && pawn.mindState.forcedGotoPosition == base.TargetA.Cell) { pawn.mindState.forcedGotoPosition = IntVec3.Invalid; } if (job.exitMapOnArrival && (pawn.Position.OnEdge(pawn.Map) || pawn.Map.exitMapGrid.IsExitCell(pawn.Position))) { TryExitMap(); } }; toil2.defaultCompleteMode = ToilCompleteMode.Instant; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { var followAndAttack = new Toil(); followAndAttack.initAction = delegate() { var actor = followAndAttack.actor; var curJob = actor.jobs.curJob; var thing = curJob.GetTarget(this.a).Thing; var pawn1 = thing as Pawn; pawn1.pather.StopDead(); pawn1.TakeDamage(new DamageInfo(PurpleIvyDefOf.PI_ToxicExplosion, 3, 0f, -1f, actor, null, null)); PurpleIvyUtils.DoExplosion(pawn1.Position, actor.Map, 3f, PurpleIvyDefOf.PI_ToxicExplosion, actor); if (actor.jobs.curJob != null) { actor.jobs.curDriver.Notify_PatherArrived(); } actor.jobs.TryTakeOrderedJob(PurpleIvyUtils.MeleeAttackJob(actor, pawn1)); }; followAndAttack.defaultCompleteMode = ToilCompleteMode.Never; followAndAttack.EndOnDespawnedOrNull <Toil>(this.a, JobCondition.Succeeded); followAndAttack.FailOn <Toil>(new Func <bool>(this.hunterIsKilled)); yield return(followAndAttack); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); Toil throwing = Toils_General.Wait(2000, TargetIndex.A); throwing.socialMode = RandomSocialMode.Normal; throwing.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null) || this.TargetB.Cell.IsForbidden(this.pawn)); throwing.handlingFacing = true; throwing.initAction = () => { pawn.rotationTracker.FaceCell(TargetLocA); }; throwing.tickAction = () => { if (this.pawn.IsHashIntervalTick(400)) { pawn.skills.Learn(SkillDefOf.Shooting, 5f); FleckMaker.ThrowStone(pawn, TargetLocA); } }; yield return(throwing); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedNullOrForbidden(TargetIndex.A); Toil mending = new Toil(); mending.defaultCompleteMode = ToilCompleteMode.Never; mending.socialMode = RandomSocialMode.SuperActive; mending.WithProgressBar(TargetIndex.A, () => workDone / mendingWorks); mending.PlaySustainerOrSound(SoundDefOf.Interact_CleanFilth); mending.FailOn(() => this.pawn.Position.IsForbidden(this.pawn)); mending.tickAction = () => { workDone++; if (workDone >= mendingWorks) { var thing = this.job.targetA.Thing; float repairRateMin = 1f / SkillRecord.MaxLevel * 0.1f; float repairRateMax = Math.Max(1, pawn.skills.GetSkill(SkillDefOf.Crafting).Level) / (float)SkillRecord.MaxLevel * 0.1f; float repairRate = Rand.Range(repairRateMin, repairRateMax); thing.HitPoints = Math.Min(thing.MaxHitPoints, thing.HitPoints + (int)(thing.MaxHitPoints * repairRate)); this.ReadyForNextToil(); } }; yield return(mending); yield break; }
// OLD /* public static Toil CollectInInventory(TargetIndex HaulableInd) * { * * Toil toil = new Toil(); * toil.initAction = () => * { * Pawn actor = toil.actor; * Job curJob = actor.jobs.curJob; * Thing haulThing = curJob.GetTarget(HaulableInd).Thing; * * //Check haulThing is human_corpse. If other race has apparel, It need to change * if (haulThing.ThingID.IndexOf("Human_Corpse") <= -1 ? false : true) * { * Corpse corpse = (Corpse)haulThing; * List<Apparel> wornApparel = corpse.innerPawn.apparel.WornApparel; * * //Drop wornApparel. wornApparel cannot Add to container directly because it will be duplicated. * corpse.innerPawn.apparel.DropAll(corpse.innerPawn.Position, false); * * //Transfer in container * foreach (Thing apparel in wornApparel) * { * if (actor.inventory.container.TryAdd(apparel)) * { * apparel.holder = actor.inventory.GetContainer(); * apparel.holder.owner = actor.inventory; * } * } * } * //Collecting TargetIndex ind * if (actor.inventory.container.TryAdd(haulThing)) * { * haulThing.holder = actor.inventory.GetContainer(); * haulThing.holder.owner = actor.inventory; * } * * }; * toil.FailOn(() => * { * Pawn actor = toil.actor; * Job curJob = actor.jobs.curJob; * Thing haulThing = curJob.GetTarget(HaulableInd).Thing; * * if (!actor.inventory.container.CanAcceptAnyOf(haulThing)) * return true; * * * * return false; * }); * return toil; * } */ public static Toil CollectInBackpack(TargetIndex HaulableInd, Apparel_Backpack backpack) { Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; //Collecting TargetIndex ind if (backpack.slotsComp.slots.TryAdd(haulThing)) { haulThing.holder = backpack.slotsComp.GetContainer(); haulThing.holder.owner = backpack.slotsComp; } }; toil.FailOn(() => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; if (!backpack.slotsComp.slots.CanAcceptAnyOf(haulThing)) { return(true); } return(false); }); return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.B); yield return(Toils_Goto.Goto(TargetIndex.B, PathEndMode)); Toil doWork = new Toil(); doWork.initAction = delegate { workLeft = 65f; }; doWork.tickAction = delegate { float num = doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed) * 1.7f; workLeft -= num; if (workLeft <= 0f) { DoEffect(); ReadyForNextToil(); } }; doWork.FailOnCannotTouch(TargetIndex.B, PathEndMode); doWork.PlaySoundAtStart(SoundDefOf.Roof_Start); doWork.PlaySoundAtEnd(SoundDefOf.Roof_Finish); doWork.WithEffect(EffecterDefOf.RoofWork, TargetIndex.A); doWork.FailOn(DoWorkFailOn); doWork.WithProgressBar(TargetIndex.A, () => 1f - workLeft / 65f); doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.activeSkill = () => SkillDefOf.Construction; yield return(doWork); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil doWork = new Toil(); doWork.initAction = delegate { workLeft = 2300f; }; doWork.tickAction = delegate { workLeft -= doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed) * 1.7f; if (workLeft <= 0f) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Snowman); thing.SetFaction(pawn.Faction); GenSpawn.Spawn(thing, base.TargetLocA, base.Map); ReadyForNextToil(); } else { JoyUtility.JoyTickCheckEnd(pawn); } }; doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(pawn)); doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(() => ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0038: stateMachine*/)._0024this.OtherFiance.Drafted || !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0038: stateMachine*/)._0024this.pawn.Position.AdjacentTo8WayOrInside(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0038: stateMachine*/)._0024this.OtherFiance)); Toil marry = new Toil { initAction = delegate { ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_005b: stateMachine*/)._0024this.ticksLeftToMarry = 2500; }, tickAction = delegate { ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0072: stateMachine*/)._0024this.ticksLeftToMarry--; if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0072: stateMachine*/)._0024this.ticksLeftToMarry <= 0) { ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0072: stateMachine*/)._0024this.ticksLeftToMarry = 0; ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0072: stateMachine*/)._0024this.ReadyForNextToil(); } }, defaultCompleteMode = ToilCompleteMode.Never }; marry.FailOn(() => !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0095: stateMachine*/)._0024this.pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0095: stateMachine*/)._0024this.OtherFiance)); yield return(marry); /*Error: Unable to find new state assignment for yield return*/; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(() => this.$this.OtherFiance.Drafted || !this.$this.pawn.Position.AdjacentTo8WayOrInside(this.$this.OtherFiance)); Toil marry = new Toil(); marry.initAction = delegate { this.$this.ticksLeftToMarry = 2500; }; marry.tickAction = delegate { this.$this.ticksLeftToMarry--; if (this.$this.ticksLeftToMarry <= 0) { this.$this.ticksLeftToMarry = 0; this.$this.ReadyForNextToil(); } }; marry.defaultCompleteMode = ToilCompleteMode.Never; marry.FailOn(() => !this.$this.pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, this.$this.OtherFiance)); yield return(marry); yield return(new Toil { defaultCompleteMode = ToilCompleteMode.Instant, initAction = delegate { if (this.$this.pawn.thingIDNumber < this.$this.OtherFiance.thingIDNumber) { MarriageCeremonyUtility.Married(this.$this.pawn, this.$this.OtherFiance); } } }); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); Toil toil = Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell); toil.AddPreTickAction(delegate { if (base.Map.exitMapGrid.IsExitCell(pawn.Position)) { pawn.ExitMap(allowedToJoinOrCreateCaravan: true, CellRect.WholeMap(base.Map).GetClosestEdge(pawn.Position)); } }); toil.FailOn(() => job.failIfCantJoinOrCreateCaravan && !CaravanExitMapUtility.CanExitMapAndJoinOrCreateCaravanNow(pawn)); yield return(toil); Toil toil2 = new Toil(); toil2.initAction = delegate { if (pawn.Position.OnEdge(pawn.Map) || pawn.Map.exitMapGrid.IsExitCell(pawn.Position)) { pawn.ExitMap(allowedToJoinOrCreateCaravan: true, CellRect.WholeMap(base.Map).GetClosestEdge(pawn.Position)); } }; toil2.FailOn(() => job.failIfCantJoinOrCreateCaravan && !CaravanExitMapUtility.CanExitMapAndJoinOrCreateCaravanNow(pawn)); toil2.defaultCompleteMode = ToilCompleteMode.Instant; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); pawn.Rotation = Rot4.Random; Toil waiting = Toils_General.Wait(job.def.joyDuration); waiting.socialMode = RandomSocialMode.Quiet; waiting.FailOn(() => !MeditationUtility.CanMeditateNow(pawn) || !MeditationUtility.SafeEnvironmentalConditions(pawn, TargetB.Cell, base.Map)); waiting.tickAction = () => { pawn.GainComfortFromCellIfPossible(); if (pawn.needs.joy != null) { JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None, 0.2f); } waiting.handlingFacing = true; if (pawn.IsHashIntervalTick(400)) { MakeThinkingBubble(pawn, TargetA.Pawn); } }; yield return(waiting); yield break; }
public static Toil SipWater(Pawn drinker, Need_Water pawnNeed, CompWaterContainer waterContainer, bool wornByActor) { var toil = new Toil(); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = sipTicks; toil.initAction = delegate { bool fromThing = toil.actor.jobs.curJob.GetTarget(TargetIndex.A).HasThing; if (fromThing) { toil.FailOnForbidden(TargetIndex.A); if (!wornByActor) { toil.FailOnDespawned(TargetIndex.A); } } float wantDrink = Math.Min(pawnNeed.HydrationWantedLitres, sipLitres); float didDrink = pawnNeed.DrinkFrom(waterContainer, wantDrink); }; toil.FailOn(() => waterContainer.IsEmpty); // TODO: toil.WithEffect(); toil.WithSustainer(delegate { if (drinker.RaceProps.Humanlike) { return DefDatabase<SoundDef>.GetNamed(drinkSoundName); } return null; }); return toil; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.B); yield return(Toils_Goto.Goto(TargetIndex.B, this.PathEndMode)); Toil doWork = new Toil(); doWork.initAction = delegate() { this.workLeft = 65f; }; doWork.tickAction = delegate() { float statValue = doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed, true); this.workLeft -= statValue; if (this.workLeft <= 0f) { this.DoEffect(); this.ReadyForNextToil(); } }; doWork.FailOnCannotTouch(TargetIndex.B, this.PathEndMode); doWork.PlaySoundAtStart(SoundDefOf.Roof_Start); doWork.PlaySoundAtEnd(SoundDefOf.Roof_Finish); doWork.WithEffect(EffecterDefOf.RoofWork, TargetIndex.A); doWork.FailOn(new Func <bool>(this.DoWorkFailOn)); doWork.WithProgressBar(TargetIndex.A, () => 1f - this.workLeft / 65f, false, -0.5f); doWork.defaultCompleteMode = ToilCompleteMode.Never; yield return(doWork); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil doWork = new Toil(); doWork.initAction = delegate() { this.workLeft = 2300f; }; doWork.tickAction = delegate() { this.workLeft -= doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed, true); if (this.workLeft <= 0f) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Snowman, null); thing.SetFaction(this.pawn.Faction, null); GenSpawn.Spawn(thing, this.TargetLocA, this.Map, WipeMode.Vanish); this.ReadyForNextToil(); return; } JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f, null); }; doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(BedInd); this.FailOnDespawnedOrNull(PartnerInd); this.FailOn(() => !Partner.health.capacities.CanBeAwake); this.KeepLyingDown(BedInd); yield return(Toils_Bed.ClaimBedIfNonMedical(BedInd)); yield return(Toils_Bed.GotoBed(BedInd)); Toil toil = new Toil(); toil.initAction = delegate { if (Partner.CurJob == null || Partner.CurJob.def != JobDefOf.Lovin) { Job newJob = JobMaker.MakeJob(JobDefOf.Lovin, pawn, Bed); Partner.jobs.StartJob(newJob, JobCondition.InterruptForced); ticksLeft = (int)(2500f * Mathf.Clamp(Rand.Range(0.1f, 1.1f), 0.1f, 2f)); } else { ticksLeft = 9999999; } }; toil.defaultCompleteMode = ToilCompleteMode.Instant; yield return(toil); Toil toil2 = Toils_LayDown.LayDown(BedInd, hasBed: true, lookForOtherJobs: false, canSleep: false, gainRestAndHealth: false); toil2.FailOn(() => Partner.CurJob == null || Partner.CurJob.def != JobDefOf.Lovin); toil2.AddPreTickAction(delegate { ticksLeft--; if (ticksLeft <= 0) { ReadyForNextToil(); } else if (pawn.IsHashIntervalTick(100)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); } }); toil2.AddFinishAction(delegate { Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin); if ((pawn.health != null && pawn.health.hediffSet != null && pawn.health.hediffSet.hediffs.Any((Hediff h) => h.def == HediffDefOf.LoveEnhancer)) || (Partner.health != null && Partner.health.hediffSet != null && Partner.health.hediffSet.hediffs.Any((Hediff h) => h.def == HediffDefOf.LoveEnhancer))) { thought_Memory.moodPowerFactor = 1.5f; } if (pawn.needs.mood != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, Partner); } pawn.mindState.canLovinTick = Find.TickManager.TicksGame + GenerateRandomMinTicksToNextLovin(pawn); }); toil2.socialMode = RandomSocialMode.Off; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { //--Log.Message("JobDriver_JoinInBed::MakeNewToils() called"); this.FailOnDespawnedOrNull(ipartner); this.FailOnDespawnedOrNull(ibed); this.FailOn(() => !Partner.health.capacities.CanBeAwake); this.FailOn(() => !(Partner.InBed() || xxx.in_same_bed(Partner, Top))); this.FailOn(() => pawn.Drafted); yield return(Toils_Reserve.Reserve(ipartner, xxx.max_rapists_per_prisoner, 0)); yield return(Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell)); yield return(new Toil { initAction = delegate { //--Log.Message("JobDriver_JoinInBed::MakeNewToils() - setting initAction"); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); ticks_left = (int)(2500.0f * Rand.Range(0.30f, 1.30f)); Job gettin_loved = new Job(xxx.gettin_loved, Top, Bed); Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced); }, defaultCompleteMode = ToilCompleteMode.Instant }); Toil do_lovin = new Toil { defaultCompleteMode = ToilCompleteMode.Never }; do_lovin.FailOn(() => (Partner.CurJob == null) || (Partner.CurJob.def != xxx.gettin_loved)); do_lovin.AddPreTickAction(delegate { --ticks_left; xxx.reduce_rest(Partner, 1); xxx.reduce_rest(Top, 2); if (ticks_left <= 0) { ReadyForNextToil(); } else if (Top.IsHashIntervalTick(ticks_between_hearts)) { MoteMaker.ThrowMetaIcon(Top.Position, Top.Map, ThingDefOf.Mote_Heart); } }); do_lovin.socialMode = RandomSocialMode.Off; yield return(do_lovin); yield return(new Toil { initAction = delegate { // Trying to add some interactions and social logs SexUtility.ProcessSex(Top, Partner, false /*rape*/, false /*isCoreLovin*/, false /*whoring*/); }, defaultCompleteMode = ToilCompleteMode.Instant }); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(() => base.OtherFiance.Drafted || !this.pawn.Position.AdjacentTo8WayOrInside(base.OtherFiance)); marry = new Toil(); marry.initAction = delegate() { this.ticksLeftToMarry = 2500; }; marry.tickAction = delegate() { this.ticksLeftToMarry--; if (this.ticksLeftToMarry <= 0) { this.ticksLeftToMarry = 0; base.ReadyForNextToil(); } }; marry.defaultCompleteMode = ToilCompleteMode.Never; marry.FailOn(() => !this.pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, base.OtherFiance)); this.$current = marry; if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: { Toil finalize = new Toil(); finalize.defaultCompleteMode = ToilCompleteMode.Instant; finalize.initAction = delegate() { if (this.pawn.thingIDNumber < base.OtherFiance.thingIDNumber) { MarriageCeremonyUtility.Married(this.pawn, base.OtherFiance); } }; this.$current = finalize; if (!this.$disposing) { this.$PC = 2; } return(true); } case 2u: this.$PC = -1; break; } return(false); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.$current = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell); if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: gaze = new Toil(); gaze.initAction = delegate() { this.pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; }; gaze.tickAction = delegate() { float num2 = this.pawn.Map.gameConditionManager.AggregateSkyGazeJoyGainFactor(this.pawn.Map); Pawn pawn = this.pawn; float extraJoyGainFactor = num2; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, null); }; gaze.defaultCompleteMode = ToilCompleteMode.Delay; gaze.defaultDuration = this.job.def.joyDuration; gaze.FailOn(() => this.pawn.Position.Roofed(this.pawn.Map)); gaze.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); this.$current = gaze; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$PC = -1; break; } return(false); }
protected override IEnumerable<Toil> MakeNewToils() { //Set what will cause the job to fail this.FailOnBurningImmobile(RepairStationIndex); this.FailOnDestroyedOrForbidden(RepairStationIndex); this.FailOn(delegate { return Repairee == null || !Repairee.ShouldGetRepairs; }); //Reserve the repair station yield return Toils_Reserve.Reserve(RepairStationIndex); //Go to the repair station interaction cell yield return Toils_Goto.GotoThing(RepairStationIndex, PathEndMode.InteractionCell); //Make a new toil that sets the droid to repair mode, then wait until fully repaired Toil toil = new Toil(); toil.FailOnDestroyedOrForbidden(RepairStationIndex); toil.FailOn(() => { return Repairee == null || RPS == null || Repairee.Pawn.Position != TargetThingA.InteractionCell || !RPS.IsAvailable(Repairee); }); toil.initAction = () => { //Log.Message("initAction"); Repairee.BeingRepaired = true; RPS.RegisterRepairee(Repairee); }; toil.defaultCompleteMode = ToilCompleteMode.Never; toil.AddFinishAction(delegate { //Log.Message("Finish action"); RPS.DeregisterRepairee(Repairee); Repairee.BeingRepaired = false; }); toil.AddEndCondition(() => { if (Repairee.ShouldGetRepairs) return JobCondition.Ongoing; return JobCondition.Succeeded; }); toil.WithEffect(DefDatabase<EffecterDef>.GetNamed("Repair"), TargetIndex.A); toil.WithSustainer(() => { return DefDatabase<SoundDef>.GetNamed("Interact_Repair"); }); yield return toil; }
public Toil BashIt() { Toil bashIt = new Toil(); bashIt.tickAction = delegate { Pawn actor = bashIt.actor; Job curJob = actor.jobs.curJob; Thing t = curJob.GetTarget(TargetIndex.B).Thing; if (actor.natives.TryMeleeAttack(t)) { this.numMeleeAttacksLanded++; if (numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks) { EndJobWith(JobCondition.Succeeded); } } }; bashIt.defaultCompleteMode = ToilCompleteMode.Never; bashIt.EndOnDespawned(TargetIndex.B, JobCondition.Succeeded); bashIt.FailOn(hunterIsKilled); return bashIt; }
protected override IEnumerable<Toil> MakeNewToils() { //this.EndOnDespawned(TargetIndex.A, JobCondition.Succeeded); //this.FailOn(hunterIsKilled); //yield return Toils_Combat.TrySetJobToUseAttackVerb(); //Toil gotoPosition = Toils_Combat.GotoCastPosition(TargetIndex.A); //yield return gotoPosition; //Toil jump = Toils_Jump.JumpIfTargetNotHittable(TargetIndex.A, gotoPosition); //yield return jump; //Log.Message(string.Concat(pawn, " trying to kill ", TargetA)); //yield return Toils_Combat.TrySetJobToUseAttackVerb(); //yield return Toils_Combat.CastVerb(TargetIndex.A); //yield return Toils_Jump.Jump(jump); Toil followAndAttack = new Toil(); followAndAttack.tickAction = () => { Pawn actor = followAndAttack.actor; Job curJob = actor.jobs.curJob; Thing t = curJob.GetTarget(TargetIndex.A).Thing; Pawn pawn2 = t as Pawn; if (pawn.Faction != Faction.OfColony) { actor.mindState.broken.StartBrokenState(DefDatabase<SK_Enviro.AI.BrokenStateDef>.GetNamed("HungerState")); } if (t.Faction == Faction.OfColony) { Find.TickManager.slower.SignalForceNormalSpeedShort(); } if ((t != actor.pather.Destination.Thing) || (!pawn.pather.Moving && !pawn.Position.AdjacentTo8WayOrInside(t))) { actor.pather.StartPath(t, PathEndMode.Touch); } else if (pawn.Position.AdjacentTo8WayOrInside(t)) { if (((t is Pawn) && pawn2.Downed) && !curJob.killIncappedTarget) { EndJobWith(JobCondition.Succeeded); } if (actor.natives.TryMeleeAttack(t)) { this.numMeleeAttacksLanded++; if (numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks) { EndJobWith(JobCondition.Succeeded); } } } }; followAndAttack.defaultCompleteMode = ToilCompleteMode.Never; followAndAttack.EndOnDespawned(TargetIndex.A, JobCondition.Succeeded); followAndAttack.FailOn(hunterIsKilled); yield return followAndAttack; }
public static Toil CollectInCarrier(TargetIndex CarrierInd, TargetIndex HaulableInd) { Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; Vehicle_Cart carrier = curJob.GetTarget(CarrierInd).Thing as Vehicle_Cart; //Check haulThing is human_corpse. If other race has apparel, It need to change Find.DesignationManager.RemoveAllDesignationsOn(haulThing); if ((haulThing.ThingID.IndexOf("Human_Corpse") <= -1) ? false : true) { Corpse corpse = (Corpse)haulThing; var wornApparel = corpse.innerPawn.apparel.WornApparel; //Drop wornApparel. wornApparel cannot Add to container directly because it will be duplicated. corpse.innerPawn.apparel.DropAll(corpse.innerPawn.Position, false); //Transfer in container foreach (Thing apparel in wornApparel) { if (carrier.storage.TryAdd(apparel)) { apparel.holder = carrier.GetContainer(); apparel.holder.owner = carrier; } } } //Collecting TargetIndex ind if (carrier.storage.TryAdd(haulThing)) { haulThing.holder = carrier.GetContainer(); haulThing.holder.owner = carrier; } List<TargetInfo> thingList = curJob.GetTargetQueue(HaulableInd); for (int i = 0; i < thingList.Count; i++) if (actor.Position.AdjacentTo8Way(thingList[i].Thing.Position)) { if (carrier.storage.TryAdd(thingList[i].Thing)) { thingList[i].Thing.holder = carrier.GetContainer(); thingList[i].Thing.holder.owner = carrier; } thingList.RemoveAt(i); i--; } }; toil.FailOn(() => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; Vehicle_Cart carrier = curJob.GetTarget(CarrierInd).Thing as Vehicle_Cart; if (!carrier.storage.CanAcceptAnyOf(haulThing) && actor.Position.IsAdjacentTo8WayOrInside(haulThing.Position, haulThing.Rotation, haulThing.RotatedSize)) return true; return false; }); toil.FailOnDespawned(CarrierInd); return toil; }
protected override IEnumerable<Toil> MakeNewToils() { //Set what will cause the job to fail this.FailOnBurningImmobile(RepairStationIndex); this.FailOnDestroyedOrForbidden(RepairStationIndex); this.FailOn(delegate { return Droid != null && !Droid.ShouldGetRepairs; }); //Reserve the repair station yield return Toils_Reserve.Reserve(RepairStationIndex); //Go to the repair station interaction cell yield return Toils_Goto.GotoThing(RepairStationIndex, PathEndMode.InteractionCell); //Make a new toil that sets the droid to repair mode, then wait until fully repaired IRepairable droid = pawn as IRepairable; Building_RepairStation rps = TargetThingA as Building_RepairStation; Toil toil = new Toil(); toil.FailOnDestroyedOrForbidden(RepairStationIndex); toil.FailOn(() => { Pawn p = toil.GetActor(); Building_RepairStation rps2 = TargetThingA as Building_RepairStation; if (!(p is IRepairable)) return true; if (p.Position != TargetThingA.InteractionCell) return true; if (rps2 == null || !rps2.IsAvailable(p)) return true; return false; }); toil.initAction = () => { //Log.Message("initAction"); droid.BeingRepaired = true; rps.RegisterRepairee(droid); }; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = rps.Def.ticksPerRepairCycle * droid.RepairsNeededCount + 1; toil.tickAction = () => { //Log.Message("Toil tick"); if ( droid.RepairStation != null && Find.TickManager.TicksGame % droid.RepairStation.Def.ticksPerRepairCycle == 0) { if (droid.RepairStation.Power != null && !droid.RepairStation.Power.PowerOn) { return; } //Log.Message("Repaired"); droid.RepairTick(); } }; toil.AddFinishAction(delegate { //Log.Message("Finish action"); rps.DeregisterRepairee(droid); droid.BeingRepaired = false; }); toil.WithEffect(DefDatabase<EffecterDef>.GetNamed("Repair"), TargetIndex.A); toil.WithSustainer(() => { return DefDatabase<SoundDef>.GetNamed("Interact_Repair"); }); yield return toil; }
public static Toil CollectInInventory(TargetIndex HaulableInd) { Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; //Check haulThing is human_corpse. If other race has apparel, It need to change if ((haulThing.ThingID.IndexOf("Human_Corpse") <= -1)? false : true) { Corpse corpse = (Corpse)haulThing; var wornApparel = corpse.innerPawn.apparel.WornApparel; //Drop wornApparel. wornApparel cannot Add to container directly because it will be duplicated. corpse.innerPawn.apparel.DropAll(corpse.innerPawn.Position, false); //Transfer in container foreach (Thing apparel in wornApparel) { if (actor.inventory.container.TryAdd(apparel)) { apparel.holder = actor.inventory.GetContainer(); apparel.holder.owner = actor.inventory; } } } //Collecting TargetIndex ind if (actor.inventory.container.TryAdd(haulThing)) { haulThing.holder = actor.inventory.GetContainer(); haulThing.holder.owner = actor.inventory; } }; toil.FailOn(() => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing haulThing = curJob.GetTarget(HaulableInd).Thing; if (!actor.inventory.container.CanAcceptAnyOf(haulThing)) return true; return false; }); return toil; }