コード例 #1
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = !PawnGenerator.IsBeingGenerated(pawn) && IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (CheckSurgeryFailCustom(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
                MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
                if (flag && flag2 && part.def.spawnThingOnRemoved != null)
                {
                    ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
                }
                if (flag2)
                {
                    ReportViolation(pawn, billDoer, pawn.FactionOrExtraMiniOrHomeFaction, -70, "GoodwillChangedReason_NeedlesslyInstalledWorseBodyPart".Translate(recipe.addsHediff.label));
                }
            }
            else if (pawn.Map != null)
            {
                MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, pawn.Position, pawn.Map);
            }
            else
            {
                pawn.health.RestorePart(part);
            }
            pawn.health.AddHediff(recipe.addsHediff, part);
        }
コード例 #2
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            // part = brain
            var spine = pawn.health.hediffSet.GetSpine();

            bool isClean     = MedicalRecipesUtility.IsClean(pawn, part);
            bool isViolation = IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }

                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
                GenSpawn.Spawn(AutomataRaceDefOf.PN_Brain, billDoer.Position, billDoer.Map);
            }

            pawn.TakeDamage(new DamageInfo(DamageDefOf.SurgicalCut, 99999f, 999f, -1f, null, part));
            pawn.health.AddHediff(HediffDefOf.MissingBodyPart, spine, new DamageInfo(DamageDefOf.SurgicalCut, 99999f, 999f, -1f, null, spine));

            if (isClean)
            {
                if (pawn.Dead)
                {
                    ThoughtUtility.GiveThoughtsForPawnExecuted(pawn, PawnExecutionKind.OrganHarvesting);
                }
                ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
            }
            if (isViolation)
            {
                ReportViolation(pawn, billDoer, pawn.FactionOrExtraMiniOrHomeFaction, -70, "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort));
            }
        }
コード例 #3
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = !PawnGenerator.IsBeingGenerated(pawn) && IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);

                if (flag && flag2 && part.def.spawnThingOnRemoved != null)
                {
                    ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn, billDoer);
                }
                if (flag2)
                {
                    ReportViolation(pawn, billDoer, pawn.HomeFaction, -70);
                }
                if (ModsConfig.IdeologyActive)
                {
                    Find.HistoryEventsManager.RecordEvent(new HistoryEvent(HistoryEventDefOf.InstalledProsthetic, billDoer.Named(HistoryEventArgsNames.Doer)));
                }
            }

            else
            {
                pawn.health.RestorePart(part);
            }
            pawn.health.AddHediff(recipe.addsHediff, part);

            if (recipe?.addsHediff != null && ingredients != null)
            {
                var hediff = pawn.health?.hediffSet?.hediffs?.FindLast(x => x.def == recipe.addsHediff);

                if (hediff != null)
                {
                    var comp = hediff.TryGetComp <HediffCompImplantQuality>();
                    if (comp != null)
                    {
                        foreach (var ingredient in ingredients)
                        {
                            if (ingredient != null && hediff.def.spawnThingOnRemoved == ingredient.def && ingredient.TryGetQuality(out var qualityCategory))
                            {
                                comp.quality = qualityCategory;
                                comp.SelectSeverity(qualityCategory);
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag1 = 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);
            }

            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 (flag1)
            {
                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;
                int              goodwillChange = -15;
                string           reason         = "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort);
                GlobalTargetInfo?lookTarget     = new GlobalTargetInfo?(pawn);
                faction.TryAffectGoodwillWith(faction2, goodwillChange, true, true, reason, lookTarget);
            }
        }
コード例 #5
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            base.ApplyOnPawn(pawn, part, billDoer, ingredients, 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
                });
                Thing md = ThingMaker.MakeThing(WTH_DefOf.WTH_ExtractedBrainData);
                md.stackCount = 3 + pawn.skills.GetSkill(SkillDefOf.Intellectual).Level;
                GenPlace.TryPlaceThing(md, pawn.Position, pawn.Map, ThingPlaceMode.Near);
            }
            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          arg_120_0      = pawn.Faction;
                Faction          faction        = billDoer.Faction;
                int              goodwillChange = -15;
                string           reason         = "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort);
                GlobalTargetInfo?lookTarget     = new GlobalTargetInfo?(pawn);
                arg_120_0.TryAffectGoodwillWith(faction, goodwillChange, true, true, reason, lookTarget);
            }
        }
コード例 #6
0
        public override void ApplyOnPawn(Pawn p, BodyPartRecord part, Pawn doer, List <Thing> ingredients, Bill bill)
        {
            var har = is_harvest(p, part);

            base.ApplyOnPawn(p, part, doer, ingredients, bill);

            if (har)
            {
                if (!p.Dead)
                {
                    ThoughtUtility.GiveThoughtsForPawnOrganHarvested(p);
                }
                else
                {
                    ThoughtUtility.GiveThoughtsForPawnExecuted(p, PawnExecutionKind.OrganHarvesting);
                }
            }
        }
コード例 #7
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            CompHediffStorage comp = ingredients.Select(x => x.TryGetComp <CompHediffStorage>()).Where(x => x != null).RandomElementWithFallback();

            if (comp == null)
            {
                return;
            }
            if (billDoer == null)
            {
                return;
            }

            if (CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
            {
                return;
            }

            TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
            {
                billDoer,
                pawn
            });
            MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
            if (IsViolationOnPawn(pawn, part, Faction.OfPlayer))
            {
                ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
                ReportViolation(pawn, billDoer, pawn.FactionOrExtraMiniOrHomeFaction, -70, "GoodwillChangedReason_NeedlesslyInstalledWorseBodyPart".Translate(comp.parent.def.label));
            }

            for (int i = 0; i < comp.hediffs.Count; i++)
            {
                var            hediff        = comp.hediffs[i];
                var            installedPart = comp.parts[i];
                BodyPartRecord target        = pawn.RaceProps.body.AllParts.Where(x => x.def == installedPart && HealthHelper.IsParent(part, x)).FirstOrDefault();

                hediff.pawn = pawn;
                pawn.health.AddHediff(hediff, target, null, null);
            }
        }
コード例 #8
0
ファイル: CORE_EXPOSED.cs プロジェクト: deanec64/RJW
        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);
            }
        }
コード例 #9
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            // START VANILLA CODE (couldn't know if the surgery was successfull)

            bool partIsClean = MedicalRecipesUtility.IsClean(pawn, part);
            bool isViolation = !PawnGenerator.IsBeingGenerated(pawn) && 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.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
                if (partIsClean && isViolation && part.def.spawnThingOnRemoved != null)
                {
                    ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
                }
                if (isViolation)
                {
                    base.ReportViolation(pawn, billDoer, pawn.FactionOrExtraHomeFaction, -70, "GoodwillChangedReason_NeedlesslyInstalledWorseBodyPart".Translate(this.recipe.addsHediff.label));
                }
            }
            else if (pawn.Map != null)
            {
                MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, pawn.Position, pawn.Map);
            }
            else
            {
                pawn.health.RestorePart(part, null, true);
            }
            pawn.health.AddHediff(this.recipe.addsHediff, part, null, null);

            // END VANILLA CODE

            if (!ingredients.NullOrEmpty())
            {
                // iterate over non null CompIncludedChildParts in ingredients
                foreach (CompIncludedChildParts compChildParts in
                         from x in ingredients
                         let comp = x.TryGetComp <CompIncludedChildParts>() // take the comp
                                    where comp?.IncludedParts != null
                                    select comp)
                {
                    compChildParts.RecursiveInstallation(pawn, part);
                }
            }
            else
            {
                foreach (CompProperties_IncludedChildParts compProp in
                         (this.recipe.fixedIngredientFilter?.AllowedThingDefs ?? Enumerable.Empty <ThingDef>())
                         .Select(td => td.GetCompProperties <CompProperties_IncludedChildParts>())
                         .Where(c => c != null))
                {
                    compProp.RecursiveDefInstallation(pawn, part);
                }
            }
        }
コード例 #10
0
        // Token: 0x06001463 RID: 5219 RVA: 0x0009DD5C File Offset: 0x0009C15C
        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
                });
                if (PawnUtility.ShouldSendNotificationAbout(pawn) || PawnUtility.ShouldSendNotificationAbout(billDoer))
                {
                    string text;
                    if (!this.recipe.successfullyRemovedHediffMessage.NullOrEmpty())
                    {
                        text = string.Format(this.recipe.successfullyRemovedHediffMessage, billDoer.LabelShort, pawn.LabelShort);
                    }
                    else
                    {
                        text = "MessageSuccessfullyRemovedHediff".Translate(billDoer.LabelShort, pawn.LabelShort, this.recipe.removesHediff.label.Named("HEDIFF"), billDoer.Named("SURGEON"), pawn.Named("PATIENT"));
                    }
                    Messages.Message(text, pawn, MessageTypeDefOf.PositiveEvent, true);
                }
            }
            Hediff hediff = pawn.health.hediffSet.hediffs.Find((Hediff x) => x.def == this.recipe.removesHediff && x.Part == part);

            if (hediff != null)
            {
                pawn.health.RemoveHediff(hediff);
                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;
                    int              goodwillChange = -15;
                    string           reason         = "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort);
                    GlobalTargetInfo?lookTarget     = new GlobalTargetInfo?(pawn);
                    faction.TryAffectGoodwillWith(faction2, goodwillChange, true, true, reason, lookTarget);
                }
            }

            /*
             * 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);
             * }
             * 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;
             *  int goodwillChange = -15;
             *  string reason = "GoodwillChangedReason_RemovedBodyPart".Translate(part.LabelShort);
             *  GlobalTargetInfo? lookTarget = new GlobalTargetInfo?(pawn);
             *  faction.TryAffectGoodwillWith(faction2, goodwillChange, true, true, reason, lookTarget);
             * }
             */
        }