コード例 #1
0
 public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
 {
     if (style == NameStyle.Full)
     {
         RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
         if (nameGenerator != null)
         {
             string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x, false).UsedThisGame, false, null);
             return(new NameSingle(name, false));
         }
         if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
         {
             string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
             {
                 NameTriple nameTriple4 = NameTriple.FromString(x);
                 nameTriple4.ResolveMissingPieces(forcedLastName);
                 return(!nameTriple4.UsedThisGame);
             }, false, null);
             NameTriple nameTriple = NameTriple.FromString(rawName);
             nameTriple.CapitalizeNick();
             nameTriple.ResolveMissingPieces(forcedLastName);
             return(nameTriple);
         }
         if (pawn.RaceProps.nameCategory != PawnNameCategory.NoName)
         {
             if (Rand.Value < 0.5f)
             {
                 NameTriple nameTriple2 = PawnBioAndNameGenerator.TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                 if (nameTriple2 != null)
                 {
                     return(nameTriple2);
                 }
             }
             return(PawnBioAndNameGenerator.GeneratePawnName_Shuffled(pawn, forcedLastName));
         }
         Log.Error("No name making method for " + pawn);
         NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
         nameTriple3.ResolveMissingPieces(null);
         return(nameTriple3);
     }
     else
     {
         if (style == NameStyle.Numeric)
         {
             int    num = 1;
             string text;
             while (true)
             {
                 text = pawn.KindLabel + " " + num.ToString();
                 if (!NameUseChecker.NameSingleIsUsed(text))
                 {
                     break;
                 }
                 num++;
             }
             return(new NameSingle(text, true));
         }
         throw new InvalidOperationException();
     }
 }
コード例 #2
0
        private void trainPawnDone(string def)
        {
            var request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed(def), Faction.OfPlayer,
                                                    PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true,
                                                    false);
            var item = PawnGenerator.GeneratePawn(request);
            var ps   = item.story;

            ps.childhood        = null;
            ps.adulthood        = null;
            ps.traits.allTraits = new List <Trait>();
            ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier")));
            ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath));


            var pws = item.workSettings;

            pws.DisableAll();
            var pps = item.playerSettings;

            pps.hostilityResponse = HostilityResponseMode.Attack;

            var triple = NameTriple.FromString(item.kindDef.label.Replace(" ", ""));

            item.Name = triple;
            item.inventory.DestroyAll();


            YuriSoldierMakeUp.tryMakeUp(item);


            DefDatabase <SoundDef> .GetNamed(parent.def.defName + "_UnitReady").PlayOneShotOnCamera();


            var loc = CellFinder.RandomClosewalkCellNear(parent.Position, parent.Map, 3);

            Pawn unused;

            if (trainPawns[0] != "ra2_AlliedTanya")
            {
                unused = (Pawn)GenSpawn.Spawn(item, loc, parent.Map);
            }
            else
            {
                // bool flag = true;
                if (getAllTanya().Count > 0)
                {
                    foreach (var tanya in getAllTanya())
                    {
                        tanya.Destroy();
                    }
                }

                unused = (Pawn)GenSpawn.Spawn(getTanya(), loc, parent.Map);
            }


            trainPawns.Remove(trainPawns[0]);
            ticks = 0;
        }
コード例 #3
0
        private static void CheckAllInjected()
        {
            // Thanks to all modders out there for providing help and support.
            // This is just for me.
            Backstory childMe = new Backstory
            {
                bodyTypeMale   = BodyType.Male,
                bodyTypeFemale = BodyType.Female,
                slot           = BackstorySlot.Childhood,
                baseDesc       =
                    "NAME never believed what was common sense and always doubted other people. HECAP later went on inflating toads with HIS sushi stick. It was there HE earned HIS nickname.",
                requiredWorkTags = WorkTags.Violent,
                shuffleable      = false
            };

            childMe.SetTitle("Lost child");
            childMe.SetTitleShort("Seeker");
            childMe.skillGains.Add("Shooting", 4);
            childMe.skillGains.Add("Medicine", 2);
            childMe.skillGains.Add("Social", 1);
            childMe.PostLoad();
            childMe.ResolveReferences();

            Backstory adultMale = new Backstory
            {
                bodyTypeMale   = BodyType.Male,
                bodyTypeFemale = BodyType.Female,
                slot           = BackstorySlot.Adulthood,
                baseDesc       =
                    "HECAP tells no one about his past. HECAP doesn't like doctors, thus HECAP prefers to tend his wounds himself.",
                shuffleable     = false,
                spawnCategories = new List <string>()
            };

            adultMale.spawnCategories.AddRange(new[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
            adultMale.SetTitle("Lone gunman");
            adultMale.SetTitleShort("Gunman");
            adultMale.skillGains.Add("Shooting", 4);
            adultMale.skillGains.Add("Medicine", 3);
            adultMale.skillGains.Add("Cooking", 2);
            adultMale.skillGains.Add("Social", 1);
            adultMale.PostLoad();
            adultMale.ResolveReferences();

            PawnBio me = new PawnBio
            {
                childhood = childMe,
                adulthood = adultMale,
                gender    = GenderPossibility.Male,
                name      = NameTriple.FromString("Gator 'Killface' Stinkwater")
            };

            me.PostLoad();
            SolidBioDatabase.allBios.Add(me);
            BackstoryDatabase.AddBackstory(childMe);

            BackstoryDatabase.AddBackstory(adultMale);
        }
コード例 #4
0
ファイル: CompBarracks.cs プロジェクト: AKreedz/ra2inRW
        private void trainPawnDone(String def)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed(def, true), Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null);
            Pawn item            = PawnGenerator.GeneratePawn(request);
            Pawn_StoryTracker ps = item.story;

            ps.childhood        = null;
            ps.adulthood        = null;
            ps.traits.allTraits = new List <Trait>();
            ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier", true)));
            ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath));


            Pawn_WorkSettings pws = item.workSettings;

            pws.DisableAll();
            Pawn_PlayerSettings pps = item.playerSettings;

            pps.hostilityResponse = HostilityResponseMode.Attack;

            NameTriple triple = NameTriple.FromString(item.kindDef.label.Replace(" ", ""));

            item.Name = triple;
            item.inventory.DestroyAll();


            YuriSoldierMakeUp.tryMakeUp(item);



            SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed(this.parent.def.defName + "_UnitReady", true));


            IntVec3 loc = CellFinder.RandomClosewalkCellNear(this.parent.Position, this.parent.Map, 3, null);

            Pawn pp;

            if (this.trainPawns[0] != "ra2_AlliedTanya")
            {
                pp = (Pawn)(GenSpawn.Spawn(item, loc, this.parent.Map, WipeMode.Vanish));
            }
            else
            {
                // bool flag = true;
                if (getAllTanya().Count > 0)
                {
                    foreach (Pawn tanya in getAllTanya())
                    {
                        tanya.Destroy(DestroyMode.Vanish);
                    }
                }
                pp = (Pawn)(GenSpawn.Spawn(getTanya(), loc, this.parent.Map, WipeMode.Vanish));
            }


            this.trainPawns.Remove(this.trainPawns[0]);
            this.ticks = 0;
        }
コード例 #5
0
        /// <summary>
        /// Creates a cutebold name.
        /// </summary>
        /// <param name="nameMaker">The given name rules.</param>
        /// <param name="forcedLastName">The forced last name.</param>
        /// <returns>Returns a new cutebold name.</returns>
        private static NameTriple CuteboldNameResolver(RulePackDef nameMaker, string forcedLastName)
        {
            NameTriple name = NameTriple.FromString(NameGenerator.GenerateName(nameMaker, null, false, null, null));

            name.CapitalizeNick();
            name.ResolveMissingPieces(forcedLastName);

            return(name);
        }
コード例 #6
0
        private static Name NameResolvedFrom(RulePackDef nameMaker, string forcedLastName)
        {
            NameTriple nameTriple = NameTriple.FromString(NameGenerator.GenerateName(nameMaker, delegate(string x)
            {
                NameTriple nameTriple2 = NameTriple.FromString(x);
                nameTriple2.ResolveMissingPieces(forcedLastName);
                return(!nameTriple2.UsedThisGame);
            }));

            nameTriple.CapitalizeNick();
            nameTriple.ResolveMissingPieces(forcedLastName);
            return(nameTriple);
        }
コード例 #7
0
        private Pawn getTanya()
        {
            var request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed("ra2_AlliedTanya"),
                                                    Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f,
                                                    false, true, true, false, false, false, false, false, 0, 0, null, 1, null, null, null, null, null, null,
                                                    null, Gender.Female);
            var item = PawnGenerator.GeneratePawn(request);

            var ps   = item.story;
            var hair = DefDatabase <HairDef> .GetNamed("Curly");

            ps.childhood        = null;
            ps.adulthood        = null;
            ps.traits.allTraits = new List <Trait>();
            ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier")));
            ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath));
            var pws = item.workSettings;

            pws.DisableAll();

            var triple = NameTriple.FromString(item.kindDef.label);

            triple.ResolveMissingPieces("Adams".Translate());
            item.Name = triple;

            var skt = item.skills;

            foreach (var sr in skt.skills)
            {
                sr.Level = 20;
            }

            item.inventory.DestroyAll();
            ps.bodyType  = BodyTypeDefOf.Female;
            ps.hairDef   = hair;
            ps.hairColor = new Color(1, 0.8f, 0);

            //st.SkinColor = new UnityEngine.Color(0.98f,0.76f,0.71f);
            ps.melanin = 0f;


            var pe = item.equipment;

            pe.Remove(pe.Primary);
            pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya")));


            //item.story = st;
            return(item);
        }
コード例 #8
0
        public static void InitOnNewGame()
        {
            ListAllyAvailable.Clear();
            ListAllySpawned.Clear();
#if TESTING
            /* */
            const int TOTAL = 5;
            for (int i = 0; i < TOTAL; ++i)
            {
                var pgr = new PawnGenerationRequest(PawnKindDef.Named("SpaceRefugee"), null,
                                                    PawnGenerationContext.NonPlayer, -1, true);
                var newPawn = PawnGenerator.GeneratePawn(pgr);
                newPawn.Name = NameTriple.FromString("ReunionPawn" + i);
                ListAllyAvailable.Add(newPawn);
            }
            /* */
#endif
        }
コード例 #9
0
        private static Pawn getTanya(IncidentParms parms)
        {
            var request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed("ra2_AlliedTanya"), parms.faction,
                                                    PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true,
                                                    false, false, false, false, false, 0, 0, null, 1, null, null, null, null, null, null, null,
                                                    Gender.Female);
            var item = PawnGenerator.GeneratePawn(request);

            var st   = item.story;
            var hair = DefDatabase <HairDef> .GetNamed("Curly");

            var bsdb  = BackstoryDatabase.allBackstories;
            var child = bsdb.TryGetValue("YouthSoldier99");
            var old   = bsdb.TryGetValue("VeteranSoldier2");

            st.adulthood = old;
            st.childhood = child;

            var triple = NameTriple.FromString(item.kindDef.label);

            triple.ResolveMissingPieces("Adams".Translate());
            item.Name = triple;

            var skt = item.skills;

            foreach (var sr in skt.skills)
            {
                sr.Level = 20;
            }


            st.bodyType  = BodyTypeDefOf.Female;
            st.hairDef   = hair;
            st.hairColor = new Color(1, 0.8f, 0);

            //st.SkinColor = new UnityEngine.Color(0.98f,0.76f,0.71f);
            st.melanin = 0f;


            //item.story = st;
            return(item);
        }
コード例 #10
0
        public override void PostSpawnSetup()
        {
            base.PostSpawnSetup();
            this.psykerPowerManager = new PsykerPowerManager(this);
            ChaosFollowerPawnKindDef pdef = this.psyker.kindDef as ChaosFollowerPawnKindDef;

            if (pdef != null && pdef.RenamePawns)
            {
                string rawName = NameGenerator.GenerateName(pdef.OverridingNameRulePack, delegate(string x)
                {
                    NameTriple nameTriple4 = NameTriple.FromString(x);
                    nameTriple4.ResolveMissingPieces(null);
                    return(!nameTriple4.UsedThisGame);
                }, false);
                NameTriple nameTriple = NameTriple.FromString(rawName);
                nameTriple.CapitalizeNick();
                nameTriple.ResolveMissingPieces(null);
                psyker.Name = nameTriple;
            }
        }
コード例 #11
0
        // RimWorld.PawnBioAndNameGenerator
        public static void GeneratePawnName(Pawn pawn, NameStyle style, string forcedLastName, ref Name __result)
        {
            if (pawn != null && pawn.Faction != null && pawn.Faction.def.defName == "RE_Player")
            {
                var ruleMaker = pawn.gender ==
                                Gender.Female ?
                                DefDatabase <RulePackDef> .GetNamed("RE_STARSNamerFemale")
                    :
                                DefDatabase <RulePackDef> .GetNamed("RE_STARSNamerMale");

                string rawName = NameGenerator.GenerateName(ruleMaker, delegate(string x)
                {
                    NameTriple nameTriple4 = NameTriple.FromString(x);
                    nameTriple4.ResolveMissingPieces(forcedLastName);
                    return(!nameTriple4.UsedThisGame);
                });
                NameTriple nameTriple = NameTriple.FromString(rawName);
                nameTriple.CapitalizeNick();
                nameTriple.ResolveMissingPieces(forcedLastName);
                __result = nameTriple;
            }
        }
コード例 #12
0
        public static NameTriple TryGetRandomUnusedSolidName(Gender gender, string requiredLastName = null)
        {
            List <NameTriple> listForGender = PawnNameDatabaseSolid.GetListForGender(GenderPossibility.Either);
            List <NameTriple> list          = ((gender == Gender.Male) ? PawnNameDatabaseSolid.GetListForGender(GenderPossibility.Male) : PawnNameDatabaseSolid.GetListForGender(GenderPossibility.Female));
            float             num           = ((float)listForGender.Count + 0.1f) / ((float)(listForGender.Count + list.Count) + 0.1f);
            List <NameTriple> list2         = ((!(Rand.Value < num)) ? list : listForGender);

            if (list2.Count == 0)
            {
                Log.Error(string.Concat("Empty solid pawn name list for gender: ", gender, "."));
                return(null);
            }
            if (Rand.Value < 0.5f)
            {
                tmpNames.Clear();
                tmpNames.AddRange(Prefs.PreferredNames);
                tmpNames.Shuffle();
                foreach (string tmpName in tmpNames)
                {
                    NameTriple nameTriple = NameTriple.FromString(tmpName);
                    if (list2.Contains(nameTriple) && !nameTriple.UsedThisGame && (requiredLastName == null || !(nameTriple.Last != requiredLastName)))
                    {
                        return(nameTriple);
                    }
                }
            }
            list2.Shuffle();
            return(list2.Where(delegate(NameTriple name)
            {
                if (requiredLastName != null && name.Last != requiredLastName)
                {
                    return false;
                }
                return (!name.UsedThisGame) ? true : false;
            }).FirstOrDefault());
        }
コード例 #13
0
        public static bool Prefix(Pawn pawn, ref Name __result, NameStyle style = 0, string forcedLastName = null)
        {
            if (style != NameStyle.Full)
            {
                return(true);
            }
            RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);

            if (nameGenerator != null)
            {
                if (nameGenerator.defName.Contains("NamerAnimalGeneric"))
                {
                    if (pawn.Faction != null && (pawn.Faction.def.defName.Contains("Tribe") || pawn.Faction.def.defName == "TribalRaiders"))
                    {
                        string        name;
                        RTPN_NameBank nameBank = RTPN_Initializer.BankOf(PawnNameCategory.HumanStandard);
                        name = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                        if (Rand.Value < 0.33f)
                        {
                            string subname1;
                            string subname2;
                            float  nickDesc = Rand.Value;
                            if (nickDesc < 0.25)
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Female);
                            }
                            else
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Male);
                            }
                            float nickObject = Rand.Value;
                            if (nickObject < 0.33)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Male);
                            }
                            else if (nickObject < 0.67)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Female);
                            }
                            else
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.None);
                            }
                            if (Rand.Value < 0.1)
                            {
                                name = subname2;
                            }
                            else
                            {
                                name = string.Concat(subname1, " ", subname2);
                            }
                        }
                        __result = new NameSingle(name, false);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                return(true);
            }
            if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
            {
                if (pawn.Faction.def.pawnNameMaker.defName.Contains("NamerPersonTribal"))
                {
                    string        name1;
                    string        name2;
                    string        name3;
                    RTPN_NameBank nameBank = RTPN_Initializer.BankOf(PawnNameCategory.HumanStandard);
                    name3 = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                    name1 = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                    int num = 0;
                    do
                    {
                        num++;
                        if (Rand.Value >= 0.33f)
                        {
                            name2 = (Rand.Value >= 0.67f ? name3 : name1);
                        }
                        else
                        {
                            string subname1;
                            string subname2;
                            float  nickDesc = Rand.Value;
                            if (nickDesc < 0.25)
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Female);
                            }
                            else
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Male);
                            }
                            float nickObject = Rand.Value;
                            if (nickObject < 0.33)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Male);
                            }
                            else if (nickObject < 0.67)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Female);
                            }
                            else
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.None);
                            }
                            if (Rand.Value < 0.1)
                            {
                                name2 = subname2;
                            }
                            else
                            {
                                name2 = string.Concat(subname1, " ", subname2);
                            }
                        }
                    }while (num < 50 && NameUseChecker.AllPawnsNamesEverUsed.Any <Name>((Name x) => {
                        NameTriple nameTriple = x as NameTriple;
                        return(nameTriple == null ? false : nameTriple.Nick == name2);
                    }));
                    name1 = name1 + " '" + name2 + "'";
                    NameTriple fullName = NameTriple.FromString(name1 + " " + name3);
                    fullName.CapitalizeNick();
                    fullName.ResolveMissingPieces(null);
                    __result = fullName;
                    return(false);
                }
            }
            return(true);
        }
コード例 #14
0
        public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            switch (style)
            {
            case NameStyle.Full:
            {
                if (pawn.story != null)
                {
                    if (pawn.story.childhood != null && pawn.story.childhood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.childhood.NameMaker, forcedLastName));
                    }
                    if (pawn.story.adulthood != null && pawn.story.adulthood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.adulthood.NameMaker, forcedLastName));
                    }
                }
                RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
                if (nameGenerator != null)
                {
                    return(new NameSingle(NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x).UsedThisGame)));
                }
                if (pawn.Faction != null)
                {
                    RulePackDef nameMaker = pawn.Faction.def.GetNameMaker(pawn.gender);
                    if (nameMaker != null)
                    {
                        return(NameResolvedFrom(nameMaker, forcedLastName));
                    }
                }
                if (pawn.RaceProps.nameCategory != 0)
                {
                    if (Rand.Value < 0.5f)
                    {
                        NameTriple nameTriple = TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                        if (nameTriple != null)
                        {
                            return(nameTriple);
                        }
                    }
                    return(GeneratePawnName_Shuffled(pawn, forcedLastName));
                }
                Log.Error("No name making method for " + pawn);
                NameTriple nameTriple2 = NameTriple.FromString(pawn.def.label);
                nameTriple2.ResolveMissingPieces();
                return(nameTriple2);
            }

            case NameStyle.Numeric:
                try
                {
                    foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_AliveOrDead)
                    {
                        NameSingle nameSingle = item.Name as NameSingle;
                        if (nameSingle != null)
                        {
                            usedNamesTmp.Add(nameSingle.Name);
                        }
                    }
                    int    num = 1;
                    string text;
                    while (true)
                    {
                        text = $"{pawn.KindLabel} {num.ToString()}";
                        if (!usedNamesTmp.Contains(text))
                        {
                            break;
                        }
                        num++;
                    }
                    return(new NameSingle(text, numerical: true));
                }
                finally
                {
                    usedNamesTmp.Clear();
                }

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #15
0
        //
        // Methods
        //
        public void DoBirthSpawn(Pawn mother, Pawn father, float chance_successful = 1.0f)
        {
            if (mother == null)
            {
                Log.Error("No mother defined");
                return;
            }
            if (father == null)
            {
                Log.Warning("No father defined");
            }

            float birthing_quality = mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")).TryGetComp <HediffComp_TendDuration> ().tendQuality;

            mother.health.AddHediff(HediffDef.Named("PostPregnancy"), null, null);
            mother.health.AddHediff(HediffDef.Named("Lactating"), ChildrenUtility.GetPawnBodyPart(pawn, "Torso"), null);

            int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve, 300));

            if (num < 1)
            {
                num = 1;
            }

            // Make sure the pawn looks like mommy and daddy
            float skin_whiteness = Rand.Range(0, 1);
            // Pool of "genetic traits" the baby can inherit
            List <Trait> traitpool = new List <Trait>();

            if (mother.RaceProps.Humanlike)
            {
                // Add mom's traits to the pool
                foreach (Trait momtrait in mother.story.traits.allTraits)
                {
                    traitpool.Add(momtrait);
                }
                if (father != null)
                {
                    // Add dad's traits to the pool
                    foreach (Trait dadtrait in father.story.traits.allTraits)
                    {
                        traitpool.Add(dadtrait);
                    }
                    // Blend skin colour between mom and dad
                    skin_whiteness = Rand.Range(mother.story.melanin, father.story.melanin);
                }
                else
                {
                    // If dad doesn't exist, just use mom's skin colour
                    skin_whiteness = mother.story.melanin;
                }

                // Clear out any traits that aren't genetic from the list
                if (traitpool.Count > 0)
                {
                    foreach (Trait trait in traitpool.ToArray())
                    {
                        bool is_genetic = false;
                        foreach (TraitDef gentrait in genetic_traits)
                        {
                            if (gentrait.defName == trait.def.defName)
                            {
                                is_genetic = true;
                            }
                        }
                        if (!is_genetic)
                        {
                            traitpool.Remove(trait);
                        }
                    }
                }
            }

            // Todo: Perhaps add a way to pass on the parent's body build
            // Best way to do it might be to represent thin/fat/normal/hulk
            // as a pair of two values, strength and weight
            // For example, if the mother has an average body type, she would
            // have a strength of .5f and a weight of .5f. A fat pawn would have
            // a strength of .5f and a weight of .75f. A thin pawn would have a
            // strength of .25f and a weight of .25f. A hulk pawn would have
            // strength of .75f and weight of .75f
            //List<float> strength_pool = new List<float>();
            //List<float> weight_pool = new List<float>();

            //// Get mother and fathers info here if possible

            //float avg_strength = strength_pool.Average();
            //float avg_weight = weight_pool.Average();

            // Surname passing
            string last_name = null;

            if (mother.RaceProps.Humanlike)
            {
                if (father == null)
                {
                    last_name = NameTriple.FromString(mother.Name.ToStringFull).Last;
                }
                else
                {
                    last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
                }
                //Log.Message ("Debug: Newborn is born to the " + last_name + " family.");
            }

            //PawnGenerationRequest request = new PawnGenerationRequest (mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map, false, true, false, false, true, false, 1, false, true, true, null, 0, 0, null, skin_whiteness, last_name);
            PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map.Tile, false, true, false, false, false, false, 1, false, true, true, false, false, null, 0, 0, null, skin_whiteness, last_name);

            Pawn baby = null;

            for (int i = 0; i < num; i++)
            {
                baby = PawnGenerator.GeneratePawn(request);
                if (PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother))
                {
                    if (baby.playerSettings != null && mother.playerSettings != null)
                    {
                        baby.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
                    }
                    if (baby.RaceProps.IsFlesh)
                    {
                        baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
                        if (father != null)
                        {
                            baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
                        }
                    }

                    // Good until otherwise proven bad
                    bool successful_birth = true;
                    var  disabledBaby     = BackstoryDatabase.allBackstories ["CustomBackstory_NA_Childhood_Disabled"];
                    if (disabledBaby != null)
                    {
                        baby.story.childhood = disabledBaby;
                    }
                    else
                    {
                        Log.Error("Couldn't find the required Backstory: CustomBackstory_NA_Childhood_Disabled!");
                        baby.story.childhood = null;
                    }
                    baby.story.adulthood = null;
                    baby.workSettings.Disable(WorkTypeDefOf.Hunting);                      //hushes up the "has no ranged weapon" alert
                    // remove all traits
                    baby.story.traits.allTraits.Clear();

                    // Add some genetic traits
                    if (traitpool.Count > 0)
                    {
                        for (int j = 0; j != 2; j++)
                        {
                            Trait gentrait = traitpool.RandomElement();
                            if (!baby.story.traits.HasTrait(gentrait.def))
                            {
                                baby.story.traits.GainTrait(gentrait);
                            }
                        }
                    }
                    // Move the baby in front of the mother, rather than on top
                    if (mother.CurrentBed() != null)
                    {
                        baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
                    }
                    // else {
                    //	 baby.Position = baby.Position + new IntVec3 (0, 0, 1).RotatedBy (mother.Rotation);
                    // }

                    // The baby died from bad chance of success
                    if (Rand.Value > chance_successful || chance_successful == 0)
                    {
                        successful_birth = false;
                    }

                    // Birth defects via drugs or alcohol
                    if (mother.health.hediffSet.HasHediff(HediffDef.Named("BirthDefectTracker")))
                    {
                        Hediff_BirthDefectTracker tracker = (Hediff_BirthDefectTracker)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("BirthDefectTracker"));
                        // The baby died in utero from chemical affect
                        if (tracker.stillbirth)
                        {
                            successful_birth = false;
                        }
                        // The baby lived! So far, anyways
                        else
                        {
                            // Should the baby get fetal alcohol syndrome?
                            if (tracker.fetal_alcohol)
                            {
                                baby.health.AddHediff(HediffDef.Named("FetalAlcoholSyndrome"));
                            }
                            // If the mother got high while pregnant, crongrats retard
                            // now your baby is addicted to crack
                            if (tracker.drug_addictions.Count > 0)
                            {
                                foreach (HediffDef addiction in tracker.drug_addictions)
                                {
                                    baby.health.AddHediff(addiction, null, null);
                                }
                            }
                        }
                    }

                    // Inbred?
                    if (father != null && mother.relations.FamilyByBlood.Contains <Pawn> (father))
                    {
                        // 50% chance to get a birth defect from inbreeding
                        if (Rand.Range(0, 1) == 1)
                        {
                            GiveRandomBirthDefect(baby);
                            if (baby.health.hediffSet.HasHediff(HediffDef.Named("DefectStillborn")))
                            {
                                successful_birth = false;
                            }
                        }
                    }



                    // The baby was born! Yay!
                    if (successful_birth == true)
                    {
                        // Give father a happy memory if the birth was successful and he's not dead
                        if (father != null && !father.health.Dead)
                        {
                            // The father is happy the baby was born
                            father.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PartnerGaveBirth"));
                        }

                        // Send a message that the baby was born
                        if (mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy")).Visible&& PawnUtility.ShouldSendNotificationAbout(mother))
                        {
                            //Messages.Message ("MessageGaveBirth".Translate (new object[] {mother.LabelIndefinite ()}).CapitalizeFirst (), mother, MessageSound.Benefit);
                            Find.LetterStack.ReceiveLetter("LabelGaveBirth".Translate(new object[] { baby.LabelIndefinite() }), "MessageHumanBirth".Translate(new object[] {
                                mother.LabelIndefinite(),
                                baby.Name.ToStringShort
                            }), LetterDefOf.Good, baby, null);
                        }

                        // Try to give PPD. If not, give "New baby" thought
                        float chance = 0.2f;
                        if (mother.story.traits.HasTrait(TraitDefOf.Psychopath))
                        {
                            chance -= 1;
                        }
                        if (mother.story.traits.HasTrait(TraitDef.Named("Nerves")))
                        {
                            chance -= 0.2f * mother.story.traits.GetTrait(TraitDef.Named("Nerves")).Degree;
                        }
                        else if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                        {
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == 2)
                            {
                                chance -= 1;
                            }
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                            {
                                chance += 0.6f;
                            }
                            // For some reason this is broken

                            /*} else if (mother.story.traits.HasTrait (TraitDef.Named ("Neurotic"))) {
                             * if (mother.story.traits.GetTrait (TraitDef.Named ("Neurotic")).Degree == 1) {
                             *      chance += 0.2f;
                             * } else
                             *      chance += 0.4f;*/
                        }

                        // Because for whatever dumb reason the Math class doesn't have a Clamp method
                        if (chance < 0)
                        {
                            chance = 0;
                        }

                        if (chance > 1)
                        {
                            chance = 1;
                        }
                        Log.Message("Debugging: Chance of PPD is " + chance * 100 + "%");


                        // Try to give PPD
                        if (Rand.Value < chance)
                        {
                            mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PostPartumDepression"), null);
                            bool verybad = false;
                            if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                                {
                                    verybad = true;
                                }
                            }
                            else if (mother.story.traits.HasTrait(TraitDef.Named("Neurotic")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("Neurotic")).Degree == 2)
                                {
                                    verybad = true;
                                }
                            }
                            // This pawn gets an exceptionally bad case of PPD
                            if (verybad)
                            {
                                foreach (Thought_Memory thought in mother.needs.mood.thoughts.memories.Memories)
                                {
                                    if (thought.def.defName == "PostPartumDepression")
                                    {
                                        thought.SetForcedStage(thought.CurStageIndex + 1);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // If we didn't get PPD, then the pawn gets a mood buff
                            if (mother.health.hediffSet.HasHediff(HediffDef.Named("GaveBirthFlag")) == false)
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirthFirstTime"));
                            }
                            else
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirth"));
                            }
                        }
                    }
                    else
                    {
                        bool aborted = false;
                        if (chance_successful < 0f)
                        {
                            aborted = true;
                        }
                        if (baby != null)
                        {
                            Miscarry(baby, aborted);
                        }
                    }
                }
                else
                {
                    Find.WorldPawns.PassToWorld(baby, PawnDiscardDecideMode.Discard);
                }
            }
            // Post birth
            if (mother.Spawned)
            {
                // Spawn guck
                FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.FilthAmnioticFluid, mother.LabelIndefinite(), 5);
                if (mother.caller != null)
                {
                    mother.caller.DoCall();
                }
                if (baby != null)
                {
                    if (baby.caller != null)
                    {
                        baby.caller.DoCall();
                    }
                }

                Log.Message("Birth quality = " + birthing_quality);
                // Possible tearing from pregnancy
                if (birthing_quality < 0.75f)
                {
                    if (birthing_quality < Rand.Value)
                    {
                        // Add a tear from giving birth
                        if (birthing_quality < Rand.Value)
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTearMajor"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                        else
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTear"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                    }
                }
            }
            pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")));
            pawn.health.RemoveHediff(this);
        }
コード例 #16
0
ファイル: PsychologyBase.cs プロジェクト: XNoNameX/Psychology
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                /* Mod settings */

                toggleEmpathy       = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey        = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode          = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleIndividuality = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);
                toggleElections     = Settings.GetHandle <bool>("EnableElections", "ElectionsTitle".Translate(), "ElectionsTooltip".Translate(), true);

                notBabyMode = toggleIndividuality.Value;
                elections   = toggleElections.Value;

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                }

                /* Mod conflict detection */

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                    }
                    kinsey = false;
                }

                /* Conditional vanilla Def edits */

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    knowGuestExecuted = ModifyThoughtStages(knowGuestExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    knowColonistExecuted = ModifyThoughtStages(knowColonistExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    knowPrisonerDiedInnocent = ModifyThoughtStages(knowPrisonerDiedInnocent, new int[] { -4 });
                }
                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    knowColonistDied = ModifyThoughtStages(knowColonistDied, new int[] { -2 });
                }
                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistAbandoned", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    colonistAbandoned = ModifyThoughtStages(colonistAbandoned, new int[] { -2 });
                }
                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    colonistAbandonedToDie = ModifyThoughtStages(colonistAbandonedToDie, new int[] { -4 });
                }
                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    prisonerAbandonedToDie = ModifyThoughtStages(prisonerAbandonedToDie, new int[] { -3 });
                }
                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    knowPrisonerSold = ModifyThoughtStages(knowPrisonerSold, new int[] { -4 });
                }
                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    knowGuestOrganHarvested = ModifyThoughtStages(knowGuestOrganHarvested, new int[] { -4 });
                }
                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }
                ThoughtDef beauty = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }


                IEnumerable <ThingDef> things = (from m in LoadedModManager.RunningMods
                                                 from def in m.AllDefs.OfType <ThingDef>()
                                                 where typeof(Pawn).IsAssignableFrom(def.thingClass)
                                                 select def);
                foreach (ThingDef t in things)
                {
                    if (t.race.intelligence == Intelligence.Humanlike && (DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie") == null || t.race.thinkTreeMain != DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie")))
                    {
                        t.thingClass = typeof(PsychologyPawn);
                        t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Psyche)));
                        t.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                        t.recipes.Add(RecipeDefOfPsychology.TreatChemicalInterest);
                        t.recipes.Add(RecipeDefOfPsychology.TreatChemicalFascination);
                        t.recipes.Add(RecipeDefOfPsychology.TreatDepression);
                        if (!t.race?.hediffGiverSets?.NullOrEmpty() ?? false)
                        {
                            if (t.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                            {
                                t.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                            }
                        }
                    }
                }

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Backstory childMe = new Backstory();
                childMe.bodyTypeMale   = BodyType.Male;
                childMe.bodyTypeFemale = BodyType.Female;
                childMe.slot           = BackstorySlot.Childhood;
                childMe.SetTitle("Child soldier");
                childMe.SetTitleShort("Scout");
                childMe.baseDesc = "NAME was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and HE was conscripted at a young age into the military to serve as a scout due to HIS runner's build. HECAP learned how to use a gun, patch wounds on the battlefield, and communicate with HIS squad. It was there HE earned HIS nickname.";
                childMe.skillGains.Add("Shooting", 4);
                childMe.skillGains.Add("Medicine", 2);
                childMe.skillGains.Add("Social", 1);
                childMe.requiredWorkTags = WorkTags.Violent;
                childMe.shuffleable      = false;
                childMe.PostLoad();
                childMe.ResolveReferences();
                //Disabled until I can be bothered to code it so they're actually siblings.

                /*Backstory adultMale = new Backstory();
                 * adultMale.bodyTypeMale = BodyType.Male;
                 * adultMale.bodyTypeFemale = BodyType.Female;
                 * adultMale.slot = BackstorySlot.Adulthood;
                 * adultMale.SetTitle("Missing in action");
                 * adultMale.SetTitleShort("P.O.W.");
                 * adultMale.baseDesc = "Eventually, HE was captured on a mission by one of his faction's many enemies. HECAP was tortured for information, the techniques of which HE never forgot. When they could get no more out of HIM, HE was sent to a prison camp, where HE worked for years before staging an escape and fleeing into civilization.";
                 * adultMale.skillGains.Add("Crafting", 4);
                 * adultMale.skillGains.Add("Construction", 3);
                 * adultMale.skillGains.Add("Mining", 2);
                 * adultMale.skillGains.Add("Social", 1);
                 * adultMale.spawnCategories = new List<string>();
                 * adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                 * adultMale.shuffleable = false;
                 * adultMale.PostLoad();
                 * adultMale.ResolveReferences();*/
                Backstory adultFemale = new Backstory();
                adultFemale.bodyTypeMale   = BodyType.Male;
                adultFemale.bodyTypeFemale = BodyType.Female;
                adultFemale.slot           = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic");
                adultFemale.SetTitleShort("Medic");
                adultFemale.baseDesc = "HECAP continued to serve in the military, being promoted through the ranks as HIS skill increased. HECAP learned how to treat more serious wounds as HIS role slowly transitioned from scout to medic, as well as how to make good use of army rations. HECAP built good rapport with HIS squad as a result.";
                adultFemale.skillGains.Add("Shooting", 4);
                adultFemale.skillGains.Add("Medicine", 3);
                adultFemale.skillGains.Add("Cooking", 2);
                adultFemale.skillGains.Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();

                /*PawnBio maleMe = new PawnBio();
                 * maleMe.childhood = childMe;
                 * maleMe.adulthood = adultMale;
                 * maleMe.gender = GenderPossibility.Male;
                 * maleMe.name = NameTriple.FromString("Nathan 'Jackal' Tarai");
                 * maleMe.PostLoad();
                 * SolidBioDatabase.allBios.Add(maleMe);*/
                PawnBio femaleMe = new PawnBio();
                femaleMe.childhood = childMe;
                femaleMe.adulthood = adultFemale;
                femaleMe.gender    = GenderPossibility.Female;
                femaleMe.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                femaleMe.PostLoad();
                SolidBioDatabase.allBios.Add(femaleMe);
                BackstoryDatabase.AddBackstory(childMe);
                //BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
コード例 #17
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                toggleEmpathy       = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey        = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode          = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleSabotage      = Settings.GetHandle <bool>("EnableSabotage", "SabotageIncidentTitle".Translate(), "SabotageIncidentTooltip".Translate(), false);
                toggleIndividuality = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);

                sabotabby   = toggleSabotage.Value;
                notBabyMode = toggleIndividuality.Value;

                if (!detoursMedical)
                {
                    Logger.Warning("MedicalDetourDisable".Translate());
                }

                //Vanilla Defs will be edited at load to improve compatibility with other mods.
                AddConflictingTraits("Nudist", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddConflictingTraits("Bloodlust", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddConflictingTraits("Psychopath", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized, TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("Cannibal", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Gourmet });
                AddConflictingTraits("Ascetic", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddConflictingTraits("Neurotic", new TraitDef[] { TraitDefOfPsychology.HeavySleeper });
                AddConflictingTraits("DislikesMen", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("DislikesWomen", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("Prosthophobe", new TraitDef[] { TraitDefOfPsychology.OpenMinded });

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey || !detoursSexual)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                        if (!detoursSexual)
                        {
                            Logger.Warning("KinseyDetourDisable".Translate());
                            TraitDefOfPsychology.Codependent.SetCommonality(0f);
                            TraitDefOfPsychology.Lecher.SetCommonality(0f);
                            TraitDefOfPsychology.OpenMinded.SetCommonality(0f);
                            TraitDefOfPsychology.Polygamous.SetCommonality(0f);
                        }
                    }
                    kinsey = false;
                }

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                    TraitDef gay = TraitDef.Named("Gay");
                    if (gay != null)
                    {
                        gay.SetCommonality(0f);
                    }
                    foreach (ThingDef t in DefDatabase <ThingDef> .AllDefsListForReading)
                    {
                        if (t.thingClass == typeof(Pawn))
                        {
                            t.thingClass = typeof(PsychologyPawn);
                        }
                    }
                }

                AddNullifyingTraits("AteLavishMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteFineMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteAwfulMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteRawFood", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteInsectMeatAsIngredient", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteInsectMeatDirect", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteRottenFood", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("SleepDisturbed", new TraitDef[] { TraitDefOfPsychology.HeavySleeper });
                AddNullifyingTraits("ObservedLayingCorpse", new TraitDef[] { TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("WitnessedDeathAlly", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("WitnessedDeathNonAlly", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("FeelingRandom", new TraitDef[] { TraitDefOfPsychology.Unstable });
                AddNullifyingTraits("ApparelDamaged", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddNullifyingTraits("EnvironmentDark", new TraitDef[] { TraitDefOfPsychology.Photosensitive });
                AddNullifyingTraits("DeadMansApparel", new TraitDef[] { TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("Naked", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddNullifyingTraits("ColonistLeftUnburied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                AddNullifyingTraits("CheatedOnMe", new TraitDef[] { TraitDefOfPsychology.Polygamous });
                AddNullifyingTraits("Affair", new TraitDef[] { TraitDefOfPsychology.Polygamous });
                AddNullifyingTraits("Disfigured", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("Pretty", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("Ugly", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("SleptOutside", new TraitDef[] { TraitDefOfPsychology.Outdoorsy });

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    if (knowGuestExecuted.stages.Count >= 1) //We can't assume that other mods won't remove stages from this thought, so we'll try to avoid OutOfBounds exceptions.
                    {
                        knowGuestExecuted.stages[0].baseMoodEffect = -1;
                    }
                    if (knowGuestExecuted.stages.Count >= 2)
                    {
                        knowGuestExecuted.stages[1].baseMoodEffect = -2;
                    }
                    if (knowGuestExecuted.stages.Count >= 3)
                    {
                        knowGuestExecuted.stages[2].baseMoodEffect = -4;
                    }
                    if (knowGuestExecuted.stages.Count >= 4)
                    {
                        knowGuestExecuted.stages[3].baseMoodEffect = -5;
                    }
                }

                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    if (knowColonistExecuted.stages.Count >= 1)
                    {
                        knowColonistExecuted.stages[0].baseMoodEffect = -1;
                    }
                    if (knowColonistExecuted.stages.Count >= 2)
                    {
                        knowColonistExecuted.stages[1].baseMoodEffect = -2;
                    }
                    if (knowColonistExecuted.stages.Count >= 3)
                    {
                        knowColonistExecuted.stages[2].baseMoodEffect = -4;
                    }
                    if (knowColonistExecuted.stages.Count >= 4)
                    {
                        knowColonistExecuted.stages[3].baseMoodEffect = -5;
                    }
                }

                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    if (knowPrisonerDiedInnocent.stages.Count >= 1)
                    {
                        knowPrisonerDiedInnocent.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    if (knowColonistDied.stages.Count >= 1)
                    {
                        knowColonistDied.stages[0].baseMoodEffect = -2;
                    }
                }

                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistAbandoned", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    if (colonistAbandoned.stages.Count >= 1)
                    {
                        colonistAbandoned.stages[0].baseMoodEffect = -2;
                    }
                }

                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    if (colonistAbandonedToDie.stages.Count >= 1)
                    {
                        colonistAbandonedToDie.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    if (prisonerAbandonedToDie.stages.Count >= 1)
                    {
                        prisonerAbandonedToDie.stages[0].baseMoodEffect = -3;
                    }
                }

                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    if (knowPrisonerSold.stages.Count >= 1)
                    {
                        knowPrisonerSold.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    if (knowGuestOrganHarvested.stages.Count >= 1)
                    {
                        knowGuestOrganHarvested.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    if (knowColonistOrganHarvested.stages.Count >= 1)
                    {
                        knowColonistOrganHarvested.stages[0].baseMoodEffect = -4;
                    }
                }

                ReplaceThoughtWorker("CabinFever", typeof(ThoughtWorker_CabinFever));
                ReplaceThoughtWorker("Disfigured", typeof(ThoughtWorker_Disfigured));
                ReplaceThoughtWorker("Ugly", typeof(ThoughtWorker_Ugly));
                ReplaceThoughtWorker("AnnoyingVoice", typeof(ThoughtWorker_AnnoyingVoice));
                ReplaceThoughtWorker("CreepyBreathing", typeof(ThoughtWorker_CreepyBreathing));
                ReplaceThoughtWorker("Pretty", typeof(ThoughtWorker_Pretty));
                ReplaceIncidentWorker("RaidEnemy", typeof(IncidentWorker_RaidEnemy));

                // Credit to FluffierThanThou for the code.
                var livingRaces = DefDatabase <ThingDef>
                                  .AllDefsListForReading
                                  .Where(t => !t.race?.hediffGiverSets?.NullOrEmpty() ?? false);

                foreach (ThingDef alive in livingRaces)
                {
                    if (alive.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                    {
                        alive.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                        alive.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                    }
                }

                MentalBreakDef berserk = DefDatabase <MentalBreakDef> .GetNamed("Berserk");

                berserk.baseCommonality = 0f;
                MentalStateDef fireStartingSpree = DefDatabase <MentalStateDef> .GetNamed("FireStartingSpree");

                fireStartingSpree.workerClass = typeof(MentalStateWorker_FireStartingSpree);

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Backstory childMe = new Backstory();
                childMe.bodyTypeMale   = BodyType.Male;
                childMe.bodyTypeFemale = BodyType.Female;
                childMe.slot           = BackstorySlot.Childhood;
                childMe.SetTitle("Child soldier");
                childMe.SetTitleShort("Scout");
                childMe.baseDesc = "NAME was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and HE was conscripted at a young age into the military to serve as a scout due to HIS runner's build. HECAP learned how to use a gun, patch wounds on the battlefield, and communicate with HIS squad. It was there HE earned HIS nickname.";
                childMe.skillGains.Add("Shooting", 4);
                childMe.skillGains.Add("Medicine", 2);
                childMe.skillGains.Add("Social", 1);
                childMe.requiredWorkTags = WorkTags.Violent;
                childMe.shuffleable      = false;
                childMe.PostLoad();
                childMe.ResolveReferences();
                //Disabled until I can be bothered to code it so they're actually siblings.

                /*Backstory adultMale = new Backstory();
                 * adultMale.bodyTypeMale = BodyType.Male;
                 * adultMale.bodyTypeFemale = BodyType.Female;
                 * adultMale.slot = BackstorySlot.Adulthood;
                 * adultMale.SetTitle("Missing in action");
                 * adultMale.SetTitleShort("P.O.W.");
                 * adultMale.baseDesc = "Eventually, HE was captured on a mission by one of his faction's many enemies. HECAP was tortured for information, the techniques of which HE never forgot. When they could get no more out of HIM, HE was sent to a prison camp, where HE worked for years before staging an escape and fleeing into civilization.";
                 * adultMale.skillGains.Add("Crafting", 4);
                 * adultMale.skillGains.Add("Construction", 3);
                 * adultMale.skillGains.Add("Mining", 2);
                 * adultMale.skillGains.Add("Social", 1);
                 * adultMale.spawnCategories = new List<string>();
                 * adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                 * adultMale.shuffleable = false;
                 * adultMale.PostLoad();
                 * adultMale.ResolveReferences();*/
                Backstory adultFemale = new Backstory();
                adultFemale.bodyTypeMale   = BodyType.Male;
                adultFemale.bodyTypeFemale = BodyType.Female;
                adultFemale.slot           = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic");
                adultFemale.SetTitleShort("Medic");
                adultFemale.baseDesc = "HECAP continued to serve in the military, being promoted through the ranks as HIS skill increased. HECAP learned how to treat more serious wounds as HIS role slowly transitioned from scout to medic, as well as how to make good use of army rations. HECAP built good rapport with HIS squad as a result.";
                adultFemale.skillGains.Add("Shooting", 4);
                adultFemale.skillGains.Add("Medicine", 3);
                adultFemale.skillGains.Add("Cooking", 2);
                adultFemale.skillGains.Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();

                /*PawnBio maleMe = new PawnBio();
                 * maleMe.childhood = childMe;
                 * maleMe.adulthood = adultMale;
                 * maleMe.gender = GenderPossibility.Male;
                 * maleMe.name = NameTriple.FromString("Nathan 'Jackal' Tarai");
                 * maleMe.PostLoad();
                 * SolidBioDatabase.allBios.Add(maleMe);*/
                PawnBio femaleMe = new PawnBio();
                femaleMe.childhood = childMe;
                femaleMe.adulthood = adultFemale;
                femaleMe.gender    = GenderPossibility.Female;
                femaleMe.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                femaleMe.PostLoad();
                SolidBioDatabase.allBios.Add(femaleMe);
                BackstoryDatabase.AddBackstory(childMe);
                //BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
コード例 #18
0
        public bool AddNewBaby(Pawn mother, Pawn father)
        {
            float  melanin;
            string lastname;

            if (xxx.is_human(mother))
            {
                if (xxx.is_human(father))
                {
                    melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f);
                    //melanin = (mother.story?.melanin ?? 0f + father.story?.melanin ?? 0f) / 2;
                    lastname = NameTriple.FromString(father.Name.ToStringFull).Last;
                }
                else
                {
                    melanin  = mother.story?.melanin ?? 0f;
                    lastname = NameTriple.FromString(mother.Name.ToStringFull).Last;
                }
            }
            else if (xxx.is_human(father))
            {
                melanin  = father.story?.melanin ?? 0f;
                lastname = NameTriple.FromString(father.Name.ToStringFull).Last;
            }
            else
            {
                melanin  = Rand.Range(0, 1.0f);
                lastname = "";
            }

            PawnGenerationRequest request = new PawnGenerationRequest(
                newborn: true,
                allowDowned: true,
                faction: mother.IsPrisoner ? null : mother.Faction,
                canGeneratePawnRelations: false,
                forceGenerateNewPawn: true,
                colonistRelationChanceFactor: 0,
                allowFood: false,
                allowAddictions: false,
                relationWithExtraPawnChanceFactor: 0,
                fixedMelanin: melanin,
                fixedLastName: lastname,
                kind: BabyPawnKindDecider(mother, father)
                //fixedIdeo: mother.Ideo,
                //forbidAnyTitle: true,
                //forceNoBackstory:true
                );

            int         division       = 1;
            HairDef     firsthair      = null;
            Color       firsthaircolor = Color.white;
            BodyTypeDef firstbody      = null;
            CrownType   firstcrown     = CrownType.Undefined;
            string      firstheadpath  = null;
            string      firstHARcrown  = null;

            while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins)
            {
                division++;
            }
            for (int i = 0; i < division; i++)
            {
                Pawn baby = GenerateBaby(request, mother, father);
                if (division > 1)
                {
                    if (i == 0 && baby.story != null)
                    {
                        firsthair           = baby.story.hairDef;
                        firsthaircolor      = baby.story.hairColor;
                        request.FixedGender = baby.gender;
                        firstbody           = baby.story.bodyType;
                        firstcrown          = baby.story.crownType;
                        firstheadpath       = (string)baby.story.GetMemberValue("headGraphicPath");
                        if (firstheadpath == null)
                        {
                            Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true);
                            if (head != null)
                            {
                                baby.story.SetMemberValue("headGraphicPath", head.GraphicPath);
                            }
                            firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
                        }
                        if (Configurations.HARActivated && baby.IsHAR())
                        {
                            firstHARcrown = baby.GetHARCrown();
                        }
                    }
                    else
                    {
                        if (baby.story != null)
                        {
                            baby.story.hairDef   = firsthair;
                            baby.story.hairColor = firsthaircolor;
                            baby.story.bodyType  = firstbody;
                            baby.story.crownType = firstcrown;
                            baby.story.SetMemberValue("headGraphicPath", firstheadpath);

                            if (Configurations.HARActivated && baby.IsHAR())
                            {
                                baby.SetHARCrown(firstHARcrown);
                            }
                        }
                    }
                }

                if (baby != null)
                {
                    babies.Add(baby);
                }
            }



            return(true);
        }
コード例 #19
0
        //获取战甲
        public static Pawn GetWarframePawn(PawnKindDef pk)
        {
            var request = new PawnGenerationRequest(pk, Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false,
                                                    false, false, false, true, true, 0, false, true, true, false, false, false, false, false, 0, 0, null, 1,
                                                    null, null, null, null, 12, null, null, SetGender(pk.defName));
            var item = PawnGenerator.GeneratePawn(request);

            item.story.adulthood = null;
            item.story.bodyType  = SetGender(pk.defName) == Gender.Male ? BodyTypeDefOf.Male : BodyTypeDefOf.Female;


            item.inventory.DestroyAll();
            item.apparel.WornApparel.Clear();

            item.workSettings.DisableAll();
            var pname   = pk.defName.Replace("Warframe_", "");
            var nowgear = "Head";

            try
            {
                for (var i = 0; i < 3; i++)
                {
                    if (i == 1)
                    {
                        nowgear = "Armor";
                    }
                    else if (i == 2)
                    {
                        nowgear = "Belt";
                    }


                    var ap = (Apparel)ThingMaker.MakeThing(ThingDef.Named("WF_" + pname + "_" + nowgear));
                    item.apparel.Wear(ap);
                }
            }
            catch (Exception e)
            {
                Log.Error(pk.defName + "'s apparel is not exist!");
                Log.Error("Details:" + e);
            }

            item.story.traits.allTraits.Clear();

            var triple = NameTriple.FromString(pk.label.Replace(" ", ""));

            triple.ResolveMissingPieces(pk.label[0] + (Find.TickManager.TicksGame % 100).ToString());
            item.Name = triple;

            foreach (var sr in item.skills.skills)
            {
                if (sr.def == SkillDefOf.Shooting || sr.def == SkillDefOf.Melee)
                {
                    sr.Level = 20;
                }
            }

            item.playerSettings.hostilityResponse = HostilityResponseMode.Attack;
            item.story.traits.GainTrait(new Trait(TraitDefOf.NaturalMood, 1));

            return(item);
        }
コード例 #20
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                /* Mod settings */

                toggleEmpathy        = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey         = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode           = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleIndividuality  = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);
                toggleElections      = Settings.GetHandle <bool>("EnableElections", "ElectionsTitle".Translate(), "ElectionsTooltip".Translate(), true);
                conversationDuration = Settings.GetHandle <float>("ConversationDuration", "DurationTitle".Translate(), "DurationTooltip".Translate(), 60f, (String s) => float.Parse(s) >= 15f && float.Parse(s) <= 180f);
                toggleDateLetters    = Settings.GetHandle <bool>("SendDateLetters", "SendDateLettersTitle".Translate(), "SendDateLettersTooltip".Translate(), true);
                toggleBenchmarking   = Settings.GetHandle <bool>("Benchmarking", "BenchmarkingTitle".Translate(), "BenchmarkingTooltip".Translate(), false);

                kinsey        = toggleKinsey.Value;
                notBabyMode   = toggleIndividuality.Value;
                elections     = toggleElections.Value;
                dateLetters   = toggleDateLetters.Value;
                benchmark     = toggleBenchmarking.Value;
                convoDuration = conversationDuration.Value;

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                }

                /* Mod conflict detection */

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                    }
                    kinsey = false;
                }

                /* Conditional vanilla Def edits */

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    knowGuestExecuted = ModifyThoughtStages(knowGuestExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    knowColonistExecuted = ModifyThoughtStages(knowColonistExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    knowPrisonerDiedInnocent = ModifyThoughtStages(knowPrisonerDiedInnocent, new int[] { -4 });
                }
                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    knowColonistDied = ModifyThoughtStages(knowColonistDied, new int[] { -2 });
                }
                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistBanished", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    colonistAbandoned = ModifyThoughtStages(colonistAbandoned, new int[] { -2 });
                }
                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    colonistAbandonedToDie = ModifyThoughtStages(colonistAbandonedToDie, new int[] { -4 });
                }
                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    prisonerAbandonedToDie = ModifyThoughtStages(prisonerAbandonedToDie, new int[] { -3 });
                }
                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    knowPrisonerSold = ModifyThoughtStages(knowPrisonerSold, new int[] { -4 });
                }
                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    knowGuestOrganHarvested = ModifyThoughtStages(knowGuestOrganHarvested, new int[] { -4 });
                }
                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }
                ThoughtDef beauty = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }

                /* ThingDef injection reworked by notfood */
                var zombieThinkTree = DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie");

                IEnumerable <ThingDef> things = (
                    from def in DefDatabase <ThingDef> .AllDefs
                    where typeof(Pawn).IsAssignableFrom(def.thingClass) &&
                    def.race?.intelligence == Intelligence.Humanlike &&
                    !def.defName.Contains("AIPawn") &&
                    (zombieThinkTree == null || def.race.thinkTreeMain != zombieThinkTree)
                    select def
                    );

                List <string> registered = new List <string>();
                foreach (ThingDef t in things)
                {
                    if (t.inspectorTabsResolved == null)
                    {
                        t.inspectorTabsResolved = new List <InspectTabBase>(1);
                    }
                    t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Psyche)));

                    if (t.recipes == null)
                    {
                        t.recipes = new List <RecipeDef>(6);
                    }
                    t.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalInterest);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalFascination);
                    t.recipes.Add(RecipeDefOfPsychology.TreatDepression);
                    t.recipes.Add(RecipeDefOfPsychology.TreatInsomnia);
                    t.recipes.Add(RecipeDefOfPsychology.CureAnxiety);

                    if (t.comps == null)
                    {
                        t.comps = new List <CompProperties>(1);
                    }
                    t.comps.Add(new CompProperties_Psychology());

                    if (!t.race.hediffGiverSets.NullOrEmpty())
                    {
                        if (t.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                        {
                            t.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                        }
                    }
                    registered.Add(t.defName);
                }
                if (Prefs.DevMode && Prefs.LogVerbose)
                {
                    Log.Message("Psychology :: Registered " + string.Join(", ", registered.ToArray()));
                }

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Traverse.Create(child).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(child).Field("bodyTypeFemale").SetValue("Female");
                child.slot = BackstorySlot.Childhood;
                child.SetTitle("Child soldier", "Child soldier");
                child.SetTitleShort("Scout", "Scout");
                child.baseDesc = "[PAWN_nameDef] was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and [PAWN_pronoun] was conscripted at a young age into the military to serve as a scout due to [PAWN_possessive] runner's build. [PAWN_pronoun] learned how to use a gun, patch wounds on the battlefield, and communicate with [PAWN_possessive] squad. It was there [PAWN_pronoun] earned [PAWN_possessive] nickname.";
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 2);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                child.requiredWorkTags = WorkTags.Violent;
                child.shuffleable      = false;
                child.PostLoad();
                child.ResolveReferences();
                Backstory adultMale = new Backstory();
                Traverse.Create(adultMale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultMale).Field("bodyTypeFemale").SetValue("Female");
                adultMale.slot = BackstorySlot.Adulthood;
                adultMale.SetTitle("Missing in action", "Missing in action");
                adultMale.SetTitleShort("Ex-P.O.W.", "Ex-P.O.W.");
                adultMale.baseDesc = "Eventually, [PAWN_pronoun] was captured on a mission by one of [PAWN_possessive] faction's many enemies. [PAWN_pronoun] was tortured for information, the techniques of which [PAWN_pronoun] never forgot. When they could get no more out of [PAWN_objective], [PAWN_pronoun] was sent to a prison camp, where [PAWN_pronoun] worked for years before staging an escape and fleeing into civilization.";
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Crafting", 4);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Construction", 3);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Mining", 2);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultMale.spawnCategories = new List <string>();
                adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultMale.shuffleable = false;
                adultMale.PostLoad();
                adultMale.ResolveReferences();
                Backstory adultFemale = new Backstory();
                Traverse.Create(adultFemale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultFemale).Field("bodyTypeFemale").SetValue("Female");
                adultFemale.slot = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic", "Battlefield medic");
                adultFemale.SetTitleShort("Medic", "Medic");
                adultFemale.baseDesc = "[PAWN_pronoun] continued to serve in the military, being promoted through the ranks as [PAWN_possessive] skill increased. [PAWN_pronoun] learned how to treat more serious wounds as [PAWN_possessive] role slowly transitioned from scout to medic, as well as how to make good use of army rations. [PAWN_pronoun] built good rapport with [PAWN_possessive] squad as a result.";
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 3);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Cooking", 2);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();
                PawnBio male = new PawnBio();
                male.childhood = child;
                male.adulthood = adultMale;
                male.gender    = GenderPossibility.Male;
                male.name      = NameTriple.FromString("Jason 'Jackal' Tarai");
                male.PostLoad();
                SolidBioDatabase.allBios.Add(male);
                PawnBio female = new PawnBio();
                female.childhood = child;
                female.adulthood = adultFemale;
                female.gender    = GenderPossibility.Female;
                female.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                female.PostLoad();
                SolidBioDatabase.allBios.Add(female);
                BackstoryDatabase.AddBackstory(child);
                BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }