protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil extractStack = Toils_General.Wait(120, 0); ToilEffects.WithProgressBarToilDelay(extractStack, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(extractStack, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(extractStack, TargetIndex.A, PathEndMode.OnCell); yield return(extractStack); yield return(new Toil { initAction = delegate() { Corpse corpse = (Corpse)TargetThingA; Hediff_CorticalStack hediff = corpse.InnerPawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.def.defName == "AC_CorticalStack") as Hediff_CorticalStack; if (hediff != null) { if (hediff.def.spawnThingOnRemoved != null) { var corticalStack = ThingMaker.MakeThing(hediff.def.spawnThingOnRemoved) as CorticalStack; if (hediff.hasPawn) { corticalStack.SavePawnFromHediff(hediff); } else { corticalStack.SavePawnToCorticalStack(corpse.InnerPawn); } GenPlace.TryPlaceThing(corticalStack, TargetThingA.Position, GetActor().Map, ThingPlaceMode.Near); ACUtils.ACTracker.RegisterStack(corticalStack); ACUtils.ACTracker.RegisterSleeve(corpse.InnerPawn, corticalStack.stackGroupID); } var head = corpse.InnerPawn.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Head); if (head != null) { Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, head); hediff_MissingPart.lastInjury = HediffDefOf.SurgicalCut; hediff_MissingPart.IsFresh = true; corpse.InnerPawn.health.AddHediff(hediff_MissingPart); } corpse.InnerPawn.health.RemoveHediff(hediff); if (pawn.Map.designationManager.DesignationOn(corpse).def == AlteredCarbonDefOf.AC_ExtractStackDesignation) { pawn.Map.designationManager.TryRemoveDesignationOn(corpse, AlteredCarbonDefOf.AC_ExtractStackDesignation); } } } }); }
public void SavePawnFromHediff(Hediff_CorticalStack hediff) { this.name = hediff.name; this.origPawn = hediff.origPawn; this.hostilityMode = hediff.hostilityMode; this.areaRestriction = hediff.areaRestriction; this.ageChronologicalTicks = hediff.ageChronologicalTicks; this.medicalCareCategory = hediff.medicalCareCategory; this.selfTend = hediff.selfTend; this.foodRestriction = hediff.foodRestriction; this.outfit = hediff.outfit; this.drugPolicy = hediff.drugPolicy; this.times = hediff.times; this.thoughts = hediff.thoughts; this.faction = hediff.faction; this.isFactionLeader = hediff.isFactionLeader; this.traits = hediff.traits; this.relations = hediff.relations; this.relatedPawns = hediff.relatedPawns; this.skills = hediff.skills; this.childhood = hediff.childhood; this.adulthood = hediff.adulthood; this.priorities = hediff.priorities; this.hasPawn = true; if (this.gender == Gender.None) { this.gender = hediff.gender; } this.pawnID = hediff.pawnID; if (ModLister.RoyaltyInstalled) { this.royalTitles = hediff.royalTitles; this.favor = hediff.favor; this.heirs = hediff.heirs; this.bondedThings = hediff.bondedThings; } this.isCopied = hediff.isCopied; this.stackGroupID = hediff.stackGroupID; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil extractStack = Toils_General.Wait(120, 0); ToilEffects.WithProgressBarToilDelay(extractStack, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(extractStack, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(extractStack, TargetIndex.A, PathEndMode.OnCell); yield return(extractStack); yield return(new Toil { initAction = delegate() { Corpse corpse = (Corpse)TargetThingA; Hediff_CorticalStack hediff = corpse.InnerPawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.def.defName == "AC_CorticalStack") as Hediff_CorticalStack; if (hediff != null) { if (hediff.def.spawnThingOnRemoved != null) { var corticalStack = ThingMaker.MakeThing(hediff.def.spawnThingOnRemoved) as CorticalStack; if (hediff.hasPawn) { corticalStack.SavePawnFromHediff(hediff); } else { corticalStack.SavePawnToCorticalStack(corpse.InnerPawn); } GenPlace.TryPlaceThing(corticalStack, TargetThingA.Position, GetActor().Map, ThingPlaceMode.Near); ACUtils.ACTracker.RegisterStack(corticalStack); ACUtils.ACTracker.RegisterSleeve(corpse.InnerPawn); } corpse.InnerPawn.health.RemoveHediff(hediff); } } }); }
public void SavePawnFromHediff(Hediff_CorticalStack hediff) { this.name = hediff.name; this.origPawn = hediff.origPawn; this.hostilityMode = hediff.hostilityMode; this.areaRestriction = hediff.areaRestriction; this.ageChronologicalTicks = hediff.ageChronologicalTicks; this.medicalCareCategory = hediff.medicalCareCategory; this.selfTend = hediff.selfTend; this.foodRestriction = hediff.foodRestriction; this.outfit = hediff.outfit; this.drugPolicy = hediff.drugPolicy; this.times = hediff.times; this.thoughts = hediff.thoughts; this.faction = hediff.faction; this.isFactionLeader = hediff.isFactionLeader; this.traits = hediff.traits; this.relations = hediff.relations; this.relatedPawns = hediff.relatedPawns; this.skills = hediff.skills; if (hediff.negativeSkillsOffsets != null) { foreach (var negativeOffset in hediff.negativeSkillsOffsets) { var skill = this.skills.Where(x => x.def == negativeOffset.skill).FirstOrDefault(); if (skill != null) { skill.Level += negativeOffset.offset; } } } if (hediff.negativeSkillPassionsOffsets != null) { foreach (var negativeOffset in hediff.negativeSkillPassionsOffsets) { var skill = this.skills.Where(x => x.def == negativeOffset.skill).FirstOrDefault(); if (skill != null) { var finalValue = (int)skill.passion + negativeOffset.offset + 1; //Log.Message("finalValue: " + finalValue, true); if (finalValue <= 2) { switch (finalValue) { case 0: skill.passion = Passion.None; //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None"); break; case 1: skill.passion = Passion.Minor; //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.Minor"); break; case 2: skill.passion = Passion.Major; //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.Major"); break; default: skill.passion = Passion.None; //Log.Message("default: " + skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None"); break; } } else { skill.passion = Passion.None; //Log.Message("2 default: " + skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None"); } } } } this.childhood = hediff.childhood; this.adulthood = hediff.adulthood; this.priorities = hediff.priorities; this.hasPawn = true; if (this.gender == Gender.None) { this.gender = hediff.gender; } if (this.race == null) { this.race = hediff.race; } this.pawnID = hediff.pawnID; if (ModLister.RoyaltyInstalled) { this.royalTitles = hediff.royalTitles; this.favor = hediff.favor; this.heirs = hediff.heirs; this.bondedThings = hediff.bondedThings; this.permitPoints = hediff.permitPoints; this.factionPermits = hediff.factionPermits; } this.isCopied = hediff.isCopied; this.stackGroupID = hediff.stackGroupID; this.sexuality = hediff.sexuality; this.romanceFactor = hediff.romanceFactor; this.psychologyData = hediff.psychologyData; }