// spawn rjw stuff
 public static void SpawnThingsFromHediffs(Pawn pawn, BodyPartRecord part, IntVec3 pos, Map map)
 {
     if (!pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Contains(part))
     {
         return;
     }
     if (pawn.Dead)
     {
         return;
     }
     IEnumerable<Hediff> enumerable = from x in pawn.health.hediffSet.hediffs
                                      where x.Part == part
                                      select x;
     //RJW parts and other implants?
     foreach (Hediff current in enumerable)
     {
         if (current.def.spawnThingOnRemoved != null)
         {
             //rjw implants/parts
             Thing thing = GenSpawn.Spawn(current.def.spawnThingOnRemoved, pos, map);
             //Log.Message("SpawnThingsFromHediffs test 1 " + current);
             //current.ExposeData();
             //thing.ExposeData();
             //Log.Message("SpawnThingsFromHediffs test 2 " + current);
             //Scribe_Values.Look<float>(ref part.Size, "size", 1);
             //Log.Message("SpawnThingsFromHediffs test 3 " + current);
         }
     }
     //spawn sub parts? not sure why would it call itself but w/e
     for (int i = 0; i < part.parts.Count; i++)
     {
         MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part.parts[i], pos, map);
     }
 }
        /// <summary>
        /// spawn rjw parts after operation
        /// </summary>
        /// <param name="pawn"></param>
        /// <param name="part"></param>
        /// <param name="pos"></param>
        /// <param name="map"></param>
        public static void SpawnThingsFromHediffs(Pawn pawn, BodyPartRecord part, IntVec3 pos, Map map)
        {
            if (!pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Contains(part))
            {
                return;
            }
            if (pawn.Dead)
            {
                return;
            }
            IEnumerable <Hediff> enumerable = from x in pawn.health.hediffSet.hediffs
                                              where x.Part == part
                                              select x;

            //RJW parts and other implants?
            foreach (Hediff current in enumerable)
            {
                if (current.def.spawnThingOnRemoved != null)
                {
                    //Thing thing = GenSpawn.Spawn(current.def.spawnThingOnRemoved, pos, map);

                    //spawn thing
                    GenSpawn.Spawn(SexPartAdder.recipePartRemover(current), pos, map);
                }
            }
            //spawn sub parts? not sure why would it call itself but w/e
            for (int i = 0; i < part.parts.Count; i++)
            {
                MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part.parts[i], pos, map);
            }
        }
Exemple #3
0
 public static Thing SpawnNaturalPartIfClean(Pawn pawn, BodyPartRecord part, IntVec3 pos, Map map)
 {
     if (MedicalRecipesUtility.IsCleanAndDroppable(pawn, part))
     {
         return(GenSpawn.Spawn(part.def.spawnThingOnRemoved, pos, map));
     }
     return(null);
 }
Exemple #4
0
        public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
        {
            IEnumerable <BodyPartRecord> parts = pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined);

            foreach (BodyPartRecord part in parts)
            {
                if (pawn.health.hediffSet.HasDirectlyAddedPartFor(part))
                {
                    yield return(part);
                }
                if (MedicalRecipesUtility.IsCleanAndDroppable(pawn, part))
                {
                    yield return(part);
                }
                if (part != pawn.RaceProps.body.corePart && !part.def.dontSuggestAmputation && pawn.health.hediffSet.hediffs.Any((Hediff d) => !(d is Hediff_Injury) && d.def.isBad && d.Visible && d.Part == part))
                {
                    yield return(part);
                }
            }
        }
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = MedicalRecipesUtility.IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
                {
                    billDoer,
                    pawn
                });
                MedicalRecipesUtility.SpawnNaturalPartIfClean(pawn, part, billDoer.Position, billDoer.Map);
                MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part, billDoer.Position, billDoer.Map);
            }
            DamageDef surgicalCut      = DamageDefOf.SurgicalCut;
            float     amount           = 99999f;
            float     armorPenetration = 999f;

            pawn.TakeDamage(new DamageInfo(surgicalCut, amount, armorPenetration, -1f, null, part, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
            if (flag)
            {
                if (pawn.Dead)
                {
                    ThoughtUtility.GiveThoughtsForPawnExecuted(pawn, PawnExecutionKind.OrganHarvesting);
                }
                ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
            }
            if (flag2 && pawn.Faction != null && billDoer != null && billDoer.Faction != null)
            {
                Faction          faction    = pawn.Faction;
                Faction          faction2   = billDoer.Faction;
                string           reason     = "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort);
                GlobalTargetInfo?lookTarget = pawn;
                faction.TryAffectGoodwillWith(faction2, ViolationGoodwillImpact, true, true, reason, lookTarget);
            }
        }
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
         {
             DamageDef surgicalCut = DamageDefOf.SurgicalCut;
             float amount = 99999f;
             float armorPenetration = 999f;
             pawn.TakeDamage(new DamageInfo(surgicalCut, amount, armorPenetration, -1f, null, part, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
     }
     pawn.health.AddHediff(recipe.addsHediff, part, null, null);
 }
Exemple #7
0
        public static void SpawnThingsFromHediffs(Pawn pawn, BodyPartRecord part, IntVec3 pos, Map map)
        {
            if (!pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Contains(part))
            {
                return;
            }
            IEnumerable <Hediff> enumerable = from x in pawn.health.hediffSet.hediffs
                                              where x.Part == part
                                              select x;

            foreach (Hediff current in enumerable)
            {
                if (current.def.spawnThingOnRemoved != null)
                {
                    GenSpawn.Spawn(current.def.spawnThingOnRemoved, pos, map);
                }
            }
            for (int i = 0; i < part.parts.Count; i++)
            {
                MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part.parts[i], pos, map);
            }
        }
Exemple #8
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = this.IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
                {
                    billDoer,
                    pawn
                });
                MedicalRecipesUtility.SpawnNaturalPartIfClean(pawn, part, billDoer.Position, billDoer.Map);
                MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part, billDoer.Position, billDoer.Map);
            }
            pawn.TakeDamage(new DamageInfo(DamageDefOf.SurgicalCut, 99999, -1f, null, part, null));
            if (flag)
            {
                if (pawn.Dead)
                {
                    ThoughtUtility.GiveThoughtsForPawnExecuted(pawn, PawnExecutionKind.OrganHarvesting);
                }
                else
                {
                    ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
                }
            }
            if (flag2)
            {
                pawn.Faction.AffectGoodwillWith(billDoer.Faction, -20f);
            }
        }