Beispiel #1
0
        public static string UniqueSaveKey(this BackstoryDef def)
        {
            bool   flag = def.saveKeyIdentifier.NullOrEmpty();
            string result;

            if (flag)
            {
                result = "CustomBackstory_" + def.defName;
            }
            else
            {
                result = def.saveKeyIdentifier + "_" + def.defName;
            }
            return(result);
        }
        public static void Post_GeneratePawn_Yautja(PawnGenerationRequest request, ref Pawn __result)
        {
            Comp_Yautja _Yautja = __result.TryGetComp <Comp_Yautja>();

            if (_Yautja != null)
            {
                Backstory pawnStoryC = __result.story.childhood;
                Backstory pawnStoryA = __result.story.adulthood ?? null;

                AlienRace.BackstoryDef bsDefUnblooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_YoungBlood");

                AlienRace.BackstoryDef bsDefBlooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_Blooded");

                AlienRace.BackstoryDef bsDefBadbloodA = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodA");

                AlienRace.BackstoryDef bsDefBadblooBd = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodB");

                HediffDef unbloodedDef = YautjaDefOf.RRY_Hediff_Unblooded;
                HediffDef unmarkedDef  = YautjaDefOf.RRY_Hediff_BloodedUM;
                HediffDef markedDef    = YautjaDefOf.RRY_Hediff_BloodedM;

                bool hasunblooded = __result.health.hediffSet.HasHediff(unbloodedDef);
                bool hasbloodedUM = __result.health.hediffSet.HasHediff(unmarkedDef);
                bool hasbloodedM  = __result.health.hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(markedDef.defName));

                if (!hasunblooded && !hasbloodedUM && !hasbloodedM)
                {
                    HediffDef hediffDef;
                    if (pawnStoryA != null)
                    {
                        if (pawnStoryA != bsDefUnblooded.backstory && __result.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                        {
                            hediffDef = _Yautja.Props.bloodedDefs.RandomElement();

                            if (hediffDef != null)
                            {
                                PawnKindDef pawnKindDef = YautjaBloodedUtility.RandomMarked(hediffDef);
                                if (_Yautja != null)
                                {
                                    _Yautja.MarkHedifflabel = pawnKindDef.LabelCap;
                                    _Yautja.MarkedhediffDef = hediffDef;
                                    _Yautja.predator        = pawnKindDef.RaceProps.predator;
                                    _Yautja.BodySize        = pawnKindDef.RaceProps.baseBodySize;
                                    _Yautja.combatPower     = pawnKindDef.combatPower;
                                    //    Log.Message(string.Format("{0}: {1}", hediffDef.stages[0].label, pawnKindDef.LabelCap));
                                }
                            }
                        }
                        else
                        {
                            hediffDef = unbloodedDef;
                        }
                    }
                    else
                    {
                        hediffDef = unbloodedDef;
                    }
                    foreach (var item in __result.RaceProps.body.AllParts)
                    {
                        if (item.def == BodyPartDefOf.Head)
                        {
                            __result.health.AddHediff(hediffDef, item);
                        }
                    }
                }
                else
                {
                    //    Log.Message(string.Format("new pawn has hasunblooded:{0}, hasbloodedUM:{1}, hasbloodedM:{2}", hasunblooded, hasbloodedUM, hasbloodedM));
                }
            }
            if (__result.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
            {
                if (request.Faction.leader == null && request.Faction != Faction.OfPlayerSilentFail && request.KindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                {
                    bool upgradeWeapon = Rand.Chance(0.5f);
                    if (__result.equipment.Primary != null && upgradeWeapon)
                    {
                        __result.equipment.Primary.TryGetQuality(out QualityCategory weaponQuality);
                        if (weaponQuality != QualityCategory.Legendary)
                        {
                            Thing       Weapon         = __result.equipment.Primary;
                            CompQuality Weapon_Quality = Weapon.TryGetComp <CompQuality>();
                            if (Weapon_Quality != null)
                            {
                                Weapon_Quality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Outsider);
                            }
                        }
                    }
                    else if (__result.apparel.WornApparelCount > 0 && !upgradeWeapon)
                    {
                        foreach (var item in __result.apparel.WornApparel)
                        {
                            item.TryGetQuality(out QualityCategory gearQuality);
                            float upgradeChance = 0.5f;
                            bool  upgradeGear   = Rand.Chance(0.5f);
                            if (gearQuality != QualityCategory.Legendary)
                            {
                                CompQuality Gear_Quality = item.TryGetComp <CompQuality>();
                                if (Gear_Quality != null)
                                {
                                    if (upgradeGear)
                                    {
                                        Gear_Quality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Outsider);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            /*
             * if (__result.Faction.def.defName.Contains("RRY_USCM"))
             * {
             *  __result.relations.ClearAllRelations();
             *
             *  if (__result.gender != Gender.Male)
             *  {
             *      PawnKindDef pawnKindDef = request.KindDef;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Neophyte : AstartesOGDefOf.OG_Astartes_Brother;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Sargent : AstartesOGDefOf.OG_Astartes_Brother;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Captain : AstartesOGDefOf.OG_Astartes_Brother;
             *      request = new PawnGenerationRequest(request.KindDef, request.Faction, request.Context, -1, true, false, false, false, false, true, 0f, fixedGender: Gender.Male, allowGay: false);
             *      __result = PawnGenerator.GeneratePawn(request);
             *  }
             *
             *  __result.story.bodyType = BodyTypeDefOf.Hulk;
             *  __result.gender = Gender.Male;
             *  //Log.Message(string.Format(__result.Drawer.renderer.graphics.headGraphic.data.texPath));
             *  //   __result.Drawer.renderer.graphics.headGraphic.data.texPath.ToString();
             *  HairDef hairdef = Rand.Chance(0.5f) ? AstartesOGDefOf.Shaved : AstartesOGDefOf.Topdog;
             *  __result.story.hairDef = hairdef;
             * }
             */
            if (__result.kindDef.RaceProps.FleshType == XenomorphRacesDefOf.RRY_Xenomorph)
            {
                if (request.KindDef == XenomorphDefOf.RRY_Xenomorph_Queen)
                {
                    __result.gender = Gender.Female;

                    /*
                     * bool QueenPresent = false;
                     *
                     * foreach (var p in Find.AnyPlayerHomeMap.mapPawns.AllPawns)
                     * {
                     *  if (p.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen)
                     *  {
                     *  //    Log.Message(string.Format("Queen Found"));
                     *      QueenPresent = true;
                     *      break;
                     *  }
                     * }
                     * if (QueenPresent)
                     * {
                     *  request = new PawnGenerationRequest(XenomorphDefOf.RRY_Xenomorph_Warrior, request.Faction, request.Context, -1, true, false, false, false, false, true, 0f, fixedGender: Gender.None, allowGay: false);
                     *  __result = PawnGenerator.GeneratePawn(request);
                     *  __result.gender = Gender.None;
                     *  return;
                     * }
                     * else
                     * {
                     *  __result.gender = Gender.Female;
                     * }
                     */
                }
                else
                {
                    __result.gender = Gender.None;
                }
            }
            if (__result.kindDef.race != YautjaDefOf.RRY_Alien_Yautja && __result.RaceProps.Humanlike && (__result.story.hairDef == YautjaDefOf.RRY_Yaujta_Dreds || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Ponytail || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Bald))
            {
                Log.Message(string.Format("Non Yautja with Yautja Hair"));
                __result.story.hairDef = DefDatabase <HairDef> .AllDefsListForReading.FindAll(x => !x.hairTags.Contains("Yautja")).RandomElement();
            }
            if (Rand.Chance(0.005f) && XenomorphUtil.isInfectablePawn(__result) && SettingsHelper.latest.AllowHiddenInfections)
            {
                HediffDef def = Rand.Chance(0.75f) ? XenomorphDefOf.RRY_HiddenXenomorphImpregnation : XenomorphDefOf.RRY_HiddenNeomorphImpregnation;
                __result.health.AddHediff(def, __result.RaceProps.body.corePart, null);
            }
            var hediffGiverSet = __result?.def?.race?.hediffGiverSets;

            if (hediffGiverSet == null)
            {
                return;
            }
            foreach (var item in hediffGiverSet)
            {
                var hediffGivers = item.hediffGivers;
                if (hediffGivers == null)
                {
                    return;
                }
                if (hediffGivers.Any(y => y is HediffGiver_StartWithHediff))
                {
                    foreach (var hdg in hediffGivers.Where(x => x is HediffGiver_StartWithHediff))
                    {
                        HediffGiver_StartWithHediff hediffGiver_StartWith = (HediffGiver_StartWithHediff)hdg;
                        hediffGiver_StartWith.GiveHediff(__result);
                    }
                }
            }
        }
        public static void Post_GeneratePawn_Yautja(PawnGenerationRequest request, ref Pawn __result)
        {
            if (__result.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
            {
                Comp_Yautja _Yautja = __result.TryGetComp <Comp_Yautja>();
                if (_Yautja != null)
                {
                    Backstory pawnStoryC = __result.story.childhood;
                    Backstory pawnStoryA = __result.story.adulthood != null ? __result.story.adulthood : null;

                    AlienRace.BackstoryDef bsDefUnblooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_YoungBlood");

                    AlienRace.BackstoryDef bsDefBlooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_Blooded");

                    AlienRace.BackstoryDef bsDefBadbloodA = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodA");

                    AlienRace.BackstoryDef bsDefBadblooBd = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodB");

                    HediffDef unbloodedDef = YautjaDefOf.RRY_Hediff_Unblooded;
                    HediffDef unmarkedDef  = YautjaDefOf.RRY_Hediff_BloodedUM;
                    HediffDef markedDef    = YautjaDefOf.RRY_Hediff_BloodedM;

                    bool hasunblooded = __result.health.hediffSet.HasHediff(unbloodedDef);
                    bool hasbloodedUM = __result.health.hediffSet.HasHediff(unmarkedDef);
                    bool hasbloodedM  = __result.health.hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(markedDef.defName));

                    if (!hasunblooded && !hasbloodedUM && !hasbloodedM)
                    {
                        HediffDef hediffDef;
                        if (pawnStoryA != null)
                        {
                            if (pawnStoryA != bsDefUnblooded.backstory)
                            {
                                hediffDef = _Yautja.Props.bloodedDefs.RandomElement();
                            }
                            else
                            {
                                hediffDef = unbloodedDef;
                            }
                        }
                        else
                        {
                            hediffDef = unbloodedDef;
                        }
                        __result.health.AddHediff(hediffDef);
                    }
                    else
                    {
                        Log.Message(string.Format("new pawn has hasunblooded:{0}, hasbloodedUM:{1}, hasbloodedM:{2}", hasunblooded, hasbloodedUM, hasbloodedM));
                    }
                }
            }
            else if (request.Faction == Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph))
            {
                Log.Message(string.Format("Xenomorph spawning"));
            }
            else if (__result.kindDef.race != YautjaDefOf.RRY_Alien_Yautja && __result.RaceProps.Humanlike && (__result.story.hairDef == YautjaDefOf.RRY_Yaujta_Dreds || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Ponytail || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Bald))
            {
                Log.Message(string.Format("Non Yautja with Yautja Hair"));
                __result.story.hairDef = DefDatabase <HairDef> .GetRandom();
            }
        }