예제 #1
0
        public static void ChangePsylinkLevel(this Pawn pawn, int levelOffset)
        {
            Hediff_Psylink mainPsylinkSource = pawn.GetMainPsylinkSource();

            if (mainPsylinkSource == null)
            {
                mainPsylinkSource = (Hediff_Psylink)pawn.health.AddHediff(HediffDefOf.PsychicAmplifier, pawn.health.hediffSet.GetBrain());
            }
            else
            {
                mainPsylinkSource.ChangeLevel(levelOffset);
            }
        }
예제 #2
0
        private bool Operable(Hediff target, RecipeDef recipe)
        {
            Hediff_Psylink hediff_ImplantWithLevel = target as Hediff_Psylink;

            if (hediff_ImplantWithLevel == null)
            {
                return(false);
            }
            int level = hediff_ImplantWithLevel.level;

            if (hediff_ImplantWithLevel.def != recipe.changesHediffLevel)
            {
                return(false);
            }
            else
            {
                return(level > 0);
            }
            //return (float)level < hediff_ImplantWithLevel.def.maxSeverity;
        }
        public void FinishCeremony(Pawn pawn)
        {
            lord.ReceiveMemo("CeremonyFinished");
            RoyalTitleDef currentTitle             = target.royalty.GetCurrentTitle(bestower.Faction);
            RoyalTitleDef titleAwardedWhenUpdating = target.royalty.GetTitleAwardedWhenUpdating(bestower.Faction, target.royalty.GetFavor(bestower.Faction));

            Pawn_RoyaltyTracker.MakeLetterTextForTitleChange(target, bestower.Faction, currentTitle, titleAwardedWhenUpdating, out var headline, out var body);
            if (pawn.royalty != null)
            {
                pawn.royalty.TryUpdateTitle_NewTemp(bestower.Faction, sendLetter: false, titleAwardedWhenUpdating);
            }
            Hediff_Psylink     mainPsylinkSource  = target.GetMainPsylinkSource();
            List <AbilityDef>  abilitiesPreUpdate = ((mainPsylinkSource == null) ? new List <AbilityDef>() : pawn.abilities.abilities.Select((Ability a) => a.def).ToList());
            ThingOwner <Thing> innerContainer     = bestower.inventory.innerContainer;

            for (int i = pawn.GetPsylinkLevel(); i < pawn.GetMaxPsylinkLevelByTitle(); i++)
            {
                for (int num = innerContainer.Count - 1; num >= 0; num--)
                {
                    if (innerContainer[num].def == ThingDefOf.PsychicAmplifier)
                    {
                        Thing thing = innerContainer[num];
                        innerContainer.RemoveAt(num);
                        thing.Destroy();
                        break;
                    }
                }
                pawn.ChangePsylinkLevel(1, sendLetter: false);
            }
            mainPsylinkSource = target.GetMainPsylinkSource();
            List <AbilityDef> newAbilities = ((mainPsylinkSource == null) ? new List <AbilityDef>() : (from a in pawn.abilities.abilities
                                                                                                       select a.def into def
                                                                                                       where !abilitiesPreUpdate.Contains(def)
                                                                                                       select def).ToList());
            string str = headline;

            str = str + "\n\n" + Hediff_Psylink.MakeLetterTextNewPsylinkLevel(target, pawn.GetPsylinkLevel(), newAbilities);
            str = str + "\n\n" + body;
            Find.LetterStack.ReceiveLetter("LetterLabelGainedRoyalTitle".Translate(titleAwardedWhenUpdating.GetLabelCapFor(pawn).Named("TITLE"), pawn.Named("PAWN")), str, LetterDefOf.PositiveEvent, pawn, bestower.Faction);
        }
예제 #4
0
        public static void ChangePsylinkLevel(this Pawn pawn, int levelOffset, bool sendLetter = true)
        {
            Hediff_Psylink mainPsylinkSource = pawn.GetMainPsylinkSource();

            if (mainPsylinkSource == null)
            {
                mainPsylinkSource = (Hediff_Psylink)HediffMaker.MakeHediff(HediffDefOf.PsychicAmplifier, pawn);
                try
                {
                    mainPsylinkSource.suppressPostAddLetter = !sendLetter;
                    pawn.health.AddHediff(mainPsylinkSource, pawn.health.hediffSet.GetBrain());
                }
                finally
                {
                    mainPsylinkSource.suppressPostAddLetter = false;
                }
            }
            else
            {
                mainPsylinkSource.ChangeLevel(levelOffset, sendLetter);
            }
        }
예제 #5
0
        public static void Post_GeneratePawn(PawnGenerationRequest request, ref Pawn __result)
        {
            if (__result != null && __result.isOrkoid())
            {
                if (__result.story == null)
                {
                    if (__result.isSquig() && request.Context == PawnGenerationContext.PlayerStarter)
                    {
                        if (__result.ageTracker.AgeBiologicalYearsFloat > 5f)
                        {
                            Rand.PushState();
                            __result.ageTracker.AgeBiologicalTicks = ((float)Rand.RangeInclusive(1, 5) * 3600000).SecondsToTicks();
                            Rand.PopState();
                        }
                    }
                    return;
                }
                Pawn_StoryTracker storyTracker = __result.story;
                Backstory         adulthood    = storyTracker.adulthood;
                bool adult = adulthood != null;
                if (__result.isOrk())
                {
                    if (storyTracker.childhood.identifier.Contains("Ork_Base_Child"))
                    {
                        //    Log.Message(__result.Name + ": Ork_Base_Child");
                    }
                    else
                    if (storyTracker.childhood.identifier.Contains("Ork_Odd_Child"))
                    {
                        //    Log.Message(__result.Name + ": Ork_Odd_Child");
                    }
                    else
                    if (storyTracker.childhood.identifier.Contains("Ork_Weird_Child"))
                    {
                        //    Log.Message(__result.Name + ": Ork_Weird_Child");
                        if (!storyTracker.traits.HasTrait(TraitDefOf.PsychicSensitivity))
                        {
                            Trait trait = new Trait(TraitDefOf.PsychicSensitivity, 1);
                            if (storyTracker.adulthood != null)
                            {
                                if (storyTracker.adulthood.identifier.Contains("_Boss"))
                                {
                                    trait = new Trait(TraitDefOf.PsychicSensitivity, 2);
                                }
                                else if (storyTracker.adulthood.identifier.Contains("_Nob"))
                                {
                                    Rand.PushState();
                                    trait = new Trait(TraitDefOf.PsychicSensitivity, Rand.RangeInclusive(1, 2));
                                    Rand.PopState();
                                }
                            }
                            __result.story.traits.GainTrait(trait);
                        }
                        if (AdeptusIntergrationUtility.enabled_Royalty)
                        {
                            if (!__result.health.hediffSet.HasHediff(HediffDefOf.PsychicAmplifier))
                            {
                                Hediff_Psylink _Psylink = HediffMaker.MakeHediff(HediffDefOf.PsychicAmplifier, __result, __result.RaceProps.body.AllParts.FirstOrDefault(x => x.def == BodyPartDefOf.Brain)) as Hediff_Psylink;
                                _Psylink.suppressPostAddLetter = true;
                                __result.health.AddHediff(_Psylink);
                            }
                            if (adult)
                            {
                                if (storyTracker.adulthood.identifier.Contains("_Boss"))
                                {
                                    Rand.PushState();
                                    __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(3, 5), __result.GetMaxPsylinkLevel()), false);
                                    Rand.PopState();
                                }
                                else if (storyTracker.adulthood.identifier.Contains("_Nob"))
                                {
                                    Rand.PushState();
                                    __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(1, 3), __result.GetMaxPsylinkLevel()), false);
                                    Rand.PopState();
                                }
                                else if (adult)
                                {
                                    Rand.PushState();
                                    __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(0, 2), __result.GetMaxPsylinkLevel()), false);
                                    Rand.PopState();
                                }
                            }
                        }
                    }
                }
                if (__result.isGrot())
                {
                }

                /*
                 * if (adult)
                 * {
                 *  if (__result.isOrk())
                 *  {
                 *      if (storyTracker.adulthood.identifier.Contains("_Boss") || storyTracker.adulthood.identifier.Contains("_Nob"))
                 *      {
                 *          HarmonyPatches.ChangeBodyType(__result, BodyTypeDefOf.Hulk);
                 *      }
                 *      else
                 *      {
                 *          HarmonyPatches.ChangeBodyType(__result, BodyTypeDefOf.Male);
                 *      }
                 *  }
                 * }
                 */
            }
        }
예제 #6
0
        public static void Post_GeneratePawn(PawnGenerationRequest request, ref Pawn __result)
        {
            if (__result != null && __result.def == AdeptusThingDefOf.OG_Alien_Eldar)
            {
                if (__result.story == null)
                {
                    return;
                }
                Pawn_StoryTracker storyTracker = __result.story;
                Backstory         adulthood    = storyTracker.adulthood;
                bool adult = adulthood != null;
                if (storyTracker.childhood.spawnCategories.Contains("Ork_Base_Child"))
                {
                }
                else
                if (storyTracker.childhood.spawnCategories.Contains("Ork_Odd_Child"))
                {
                }
                else
                if (storyTracker.childhood.spawnCategories.Contains("Eldar_Craftworld_Psyker"))
                {
                    if (!storyTracker.traits.HasTrait(TraitDefOf.PsychicSensitivity))
                    {
                        Trait trait = new Trait(TraitDefOf.PsychicSensitivity, 1);
                        if (storyTracker.adulthood != null)
                        {
                            if (storyTracker.adulthood.identifier.Contains("_Farseer"))
                            {
                                trait = new Trait(TraitDefOf.PsychicSensitivity, 2);
                            }
                            else if (storyTracker.adulthood.identifier.Contains("_Warlock"))
                            {
                                Rand.PushState();
                                trait = new Trait(TraitDefOf.PsychicSensitivity, Rand.RangeInclusive(1, 2));
                                Rand.PopState();
                            }
                        }
                        __result.story.traits.GainTrait(trait);
                    }
                    if (AdeptusIntergrationUtility.enabled_Royalty)
                    {
                        if (!__result.health.hediffSet.HasHediff(HediffDefOf.PsychicAmplifier))
                        {
                            Hediff_Psylink _Psylink = HediffMaker.MakeHediff(HediffDefOf.PsychicAmplifier, __result, __result.RaceProps.body.AllParts.FirstOrDefault(x => x.def == BodyPartDefOf.Brain)) as Hediff_Psylink;
                            _Psylink.suppressPostAddLetter = true;
                            __result.health.AddHediff(_Psylink);
                        }
                        if (storyTracker.adulthood.identifier.Contains("_Farseer"))
                        {
                            Rand.PushState();
                            __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(3, 5), __result.GetMaxPsylinkLevel()), false);
                            Rand.PopState();
                        }
                        else if (storyTracker.adulthood.identifier.Contains("_Warlock"))
                        {
                            Rand.PushState();
                            __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(1, 3), __result.GetMaxPsylinkLevel()), false);
                            Rand.PopState();
                        }
                        else if (adult)
                        {
                            Rand.PushState();
                            __result.ChangePsylinkLevel(Math.Min(Rand.RangeInclusive(0, 2), __result.GetMaxPsylinkLevel()), false);
                            Rand.PopState();
                        }
                    }
                }

                /*
                 * if (adult)
                 * {
                 *  if (__result.isOrk())
                 *  {
                 *      if (storyTracker.adulthood.identifier.Contains("_Boss") || storyTracker.adulthood.identifier.Contains("_Nob"))
                 *      {
                 *          HarmonyPatches.ChangeBodyType(__result, BodyTypeDefOf.Hulk);
                 *      }
                 *      else
                 *      {
                 *          HarmonyPatches.ChangeBodyType(__result, BodyTypeDefOf.Male);
                 *      }
                 *  }
                 * }
                 */
            }
        }