//public static void SetComps(this Backstory story, List<ThingComp> comps)
        //{
        //    // Hate this bit of code. thank f**k for extentions
        //    typeof(ThingWithComps).GetField("comps", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(thingWithComps, comps);
        //}


        public static void setBody(this Backstory story, BodyType b)
        {
            // useless bit... but now I have a nice looking Get and Set ...
            story.bodyTypeFemale = b;
            story.bodyTypeGlobal = b;
            story.bodyTypeMale   = b;
        }
        public void ExposeData()
        {
            string text = (this.childhood == null) ? null : this.childhood.identifier;

            Scribe_Values.Look(ref text, "childhood", null, false);
            if (Scribe.mode == LoadSaveMode.LoadingVars && !text.NullOrEmpty() && !BackstoryDatabase.TryGetWithIdentifier(text, out this.childhood))
            {
                Log.Error("Couldn't load child backstory with identifier " + text + ". Giving random.");
                this.childhood = BackstoryDatabase.RandomBackstory(BackstorySlot.Childhood);
            }
            string text2 = (this.adulthood == null) ? null : this.adulthood.identifier;

            Scribe_Values.Look(ref text2, "adulthood", null, false);
            if (Scribe.mode == LoadSaveMode.LoadingVars && !text2.NullOrEmpty() && !BackstoryDatabase.TryGetWithIdentifier(text2, out this.adulthood))
            {
                Log.Error("Couldn't load adult backstory with identifier " + text2 + ". Giving random.");
                this.adulthood = BackstoryDatabase.RandomBackstory(BackstorySlot.Adulthood);
            }
            Scribe_Values.Look <BodyType>(ref this.bodyType, "bodyType", BodyType.Undefined, false);
            Scribe_Values.Look <CrownType>(ref this.crownType, "crownType", CrownType.Undefined, false);
            Scribe_Values.Look <string>(ref this.headGraphicPath, "headGraphicPath", (string)null, false);
            Scribe_Defs.Look <HairDef>(ref this.hairDef, "hairDef");
            Scribe_Values.Look <Color>(ref this.hairColor, "hairColor", default(Color), false);
            Scribe_Values.Look <float>(ref this.melanin, "melanin", 0f, false);
            Scribe_Deep.Look <TraitSet>(ref this.traits, "traits", new object[1]
            {
                this.pawn
            });
            if (Scribe.mode == LoadSaveMode.PostLoadInit && this.hairDef == null)
            {
                this.hairDef = DefDatabase <HairDef> .AllDefs.RandomElement();
            }
        }
Пример #3
0
        private static void FillBackstorySlotShuffled(Pawn pawn, BackstorySlot slot, ref Backstory backstory, FactionDef factionType)
        {
            IEnumerable <Backstory> source = from bs in BackstoryDatabase.ShuffleableBackstoryList(slot, factionType.backstoryCategory).TakeRandom(20)
                                             where slot != BackstorySlot.Adulthood || !bs.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables)
                                             select bs;

            if (PawnBioAndNameGenerator.< > f__mg$cache0 == null)
            {
                PawnBioAndNameGenerator.< > f__mg$cache0 = new Func <Backstory, float>(PawnBioAndNameGenerator.BackstorySelectionWeight);
            }
            if (!source.TryRandomElementByWeight(PawnBioAndNameGenerator.< > f__mg$cache0, out backstory))
            {
                Log.Error(string.Concat(new object[]
                {
                    "No shuffled ",
                    slot,
                    " found for ",
                    pawn.ToStringSafe <Pawn>(),
                    " of ",
                    factionType.ToStringSafe <FactionDef>(),
                    ". Defaulting."
                }), false);
                backstory = (from kvp in BackstoryDatabase.allBackstories
                             where kvp.Value.slot == slot
                             select kvp).RandomElement <KeyValuePair <string, Backstory> >().Value;
            }
        }
        public static string GetIdentifierClosestMatch(string identifier, bool closestMatchWarning = true)
        {
            string result;

            if (BackstoryDatabase.allBackstories.ContainsKey(identifier))
            {
                result = identifier;
            }
            else
            {
                string b = BackstoryDatabase.StripNumericSuffix(identifier);
                foreach (KeyValuePair <string, Backstory> keyValuePair in BackstoryDatabase.allBackstories)
                {
                    Backstory value = keyValuePair.Value;
                    if (BackstoryDatabase.StripNumericSuffix(value.identifier) == b)
                    {
                        if (closestMatchWarning)
                        {
                            Log.Warning("Couldn't find exact match for backstory " + identifier + ", using closest match " + value.identifier, false);
                        }
                        return(value.identifier);
                    }
                }
                Log.Warning("Couldn't find exact match for backstory " + identifier + ", or any close match.", false);
                result = identifier;
            }
            return(result);
        }
Пример #5
0
 public static void AddBackstory(Backstory bs)
 {
     BackstoryHardcodedData.InjectHardcodedData(bs);
     if (BackstoryDatabase.allBackstories.ContainsKey(bs.identifier))
     {
         if (bs == BackstoryDatabase.allBackstories[bs.identifier])
         {
             Log.Error("Tried to add the same backstory twice " + bs.identifier, false);
         }
         else
         {
             Log.Error(string.Concat(new string[]
             {
                 "Backstory ",
                 bs.title,
                 " has same unique save key ",
                 bs.identifier,
                 " as old backstory ",
                 BackstoryDatabase.allBackstories[bs.identifier].title
             }), false);
         }
         return;
     }
     BackstoryDatabase.allBackstories.Add(bs.identifier, bs);
     BackstoryDatabase.shuffleableBackstoryList.Clear();
 }
Пример #6
0
        public void ExposeData()
        {
            string value = (childhood == null) ? null : childhood.identifier;

            Scribe_Values.Look(ref value, "childhood");
            if (Scribe.mode == LoadSaveMode.LoadingVars && !value.NullOrEmpty() && !BackstoryDatabase.TryGetWithIdentifier(value, out childhood))
            {
                Log.Error("Couldn't load child backstory with identifier " + value + ". Giving random.");
                childhood = BackstoryDatabase.RandomBackstory(BackstorySlot.Childhood);
            }
            string value2 = (adulthood == null) ? null : adulthood.identifier;

            Scribe_Values.Look(ref value2, "adulthood");
            if (Scribe.mode == LoadSaveMode.LoadingVars && !value2.NullOrEmpty() && !BackstoryDatabase.TryGetWithIdentifier(value2, out adulthood))
            {
                Log.Error("Couldn't load adult backstory with identifier " + value2 + ". Giving random.");
                adulthood = BackstoryDatabase.RandomBackstory(BackstorySlot.Adulthood);
            }
            Scribe_Defs.Look(ref bodyType, "bodyType");
            Scribe_Values.Look(ref crownType, "crownType", CrownType.Undefined);
            Scribe_Values.Look(ref headGraphicPath, "headGraphicPath");
            Scribe_Defs.Look(ref hairDef, "hairDef");
            Scribe_Values.Look(ref hairColor, "hairColor");
            Scribe_Values.Look(ref melanin, "melanin", 0f);
            Scribe_Deep.Look(ref traits, "traits", pawn);
            Scribe_Values.Look(ref title, "title");
            if (Scribe.mode == LoadSaveMode.PostLoadInit && hairDef == null)
            {
                hairDef = DefDatabase <HairDef> .AllDefs.RandomElement();
            }
        }
Пример #7
0
 public static void InjectHardcodedData(Backstory bs)
 {
     if (bs.Title == "Urbworld sex slave")
     {
         bs.AddForcedTrait(TraitDefOf.Beauty, 2);
     }
     if (bs.Title == "Pop idol")
     {
         bs.AddForcedTrait(TraitDefOf.Beauty, 2);
     }
     if (bs.Title == "Amateur botanist")
     {
         bs.AddForcedTrait(TraitDefOf.GreenThumb, 0);
     }
     if (bs.Title == "Mechanoid nerd")
     {
         bs.AddDisallowedTrait(TraitDefOf.Gay, 0);
     }
     if (bs.Title == "Mad scientist")
     {
         bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
     }
     if (bs.Title == "Urbworld politican")
     {
         bs.AddForcedTrait(TraitDefOf.Greedy, 0);
     }
     if (bs.Title == "Criminal tinker")
     {
         bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
     }
     if (bs.Title == "Urbworld enforcer")
     {
         bs.AddForcedTrait(TraitDefOf.Nerves, 1);
     }
     if (bs.Title == "Pyro assistant")
     {
         bs.AddForcedTrait(TraitDefOf.Pyromaniac, 0);
     }
     if (bs.Title == "Stiletto assassin")
     {
         bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
     }
     if (bs.Title == "Discharged soldier")
     {
         bs.AddForcedTrait(TraitDefOf.TooSmart, 0);
     }
     if (bs.Title == "Bloody wanderer")
     {
         bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
     }
     if (bs.Title == "New age duelist")
     {
         bs.AddForcedTrait(TraitDefOf.Industriousness, -1);
     }
     if (bs.Title == "Pirate doctor")
     {
         bs.AddForcedTrait(TraitDefOf.NaturalMood, 1);
     }
 }
 public bool Matches(Backstory backstory)
 {
     if (exclude != null && backstory.spawnCategories.Any((string e) => exclude.Contains(e)))
     {
         return(false);
     }
     if (categories != null)
     {
         return(backstory.spawnCategories.Any((string c) => categories.Contains(c)));
     }
     return(true);
 }
Пример #9
0
 public static void AddBackstory(Backstory bs)
 {
     BackstoryHardcodedData.InjectHardcodedData(bs);
     if (BackstoryDatabase.allBackstories.ContainsKey(bs.identifier))
     {
         Log.Error("Backstory " + bs.Title + " has same unique save key " + bs.identifier + " as old backstory " + BackstoryDatabase.allBackstories[bs.identifier].Title);
     }
     else
     {
         BackstoryDatabase.allBackstories.Add(bs.identifier, bs);
     }
 }
        private static void FillBackstorySlotShuffled(Pawn pawn, BackstorySlot slot, ref Backstory backstory, Backstory backstoryOtherSlot, List <BackstoryCategoryFilter> backstoryCategories, FactionDef factionType)
        {
            BackstoryCategoryFilter backstoryCategoryFilter = backstoryCategories.RandomElementByWeight((BackstoryCategoryFilter c) => c.commonality);

            if (backstoryCategoryFilter == null)
            {
                backstoryCategoryFilter = FallbackCategoryGroup;
            }
            if (!(from bs in BackstoryDatabase.ShuffleableBackstoryList(slot, backstoryCategoryFilter).TakeRandom(20)
                  where (slot != BackstorySlot.Adulthood || !bs.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables)) ? true : false
                  select bs).TryRandomElementByWeight(BackstorySelectionWeight, out backstory))
            {
                Log.Error(string.Concat("No shuffled ", slot, " found for ", pawn.ToStringSafe(), " of ", factionType.ToStringSafe(), ". Choosing random."));
                backstory = BackstoryDatabase.allBackstories.Where((KeyValuePair <string, Backstory> kvp) => kvp.Value.slot == slot).RandomElement().Value;
            }
        }
 public static void AddBackstory(Backstory bs)
 {
     if (allBackstories.ContainsKey(bs.identifier))
     {
         if (bs == allBackstories[bs.identifier])
         {
             Log.Error("Tried to add the same backstory twice " + bs.identifier);
             return;
         }
         Log.Error("Backstory " + bs.title + " has same unique save key " + bs.identifier + " as old backstory " + allBackstories[bs.identifier].title);
     }
     else
     {
         allBackstories.Add(bs.identifier, bs);
         shuffleableBackstoryList.Clear();
     }
 }
Пример #12
0
 public static void AddBackstory(Backstory bs)
 {
     BackstoryHardcodedData.InjectHardcodedData(bs);
     if (BackstoryDatabase.allBackstories.ContainsKey(bs.identifier))
     {
         Log.Error(string.Concat(new string[]
         {
             "Backstory ",
             bs.Title,
             " has same unique save key ",
             bs.identifier,
             " as old backstory ",
             BackstoryDatabase.allBackstories[bs.identifier].Title
         }));
         return;
     }
     BackstoryDatabase.allBackstories.Add(bs.identifier, bs);
 }
Пример #13
0
 private static void FillBackstorySlotShuffled(Pawn pawn, BackstorySlot slot, ref Backstory backstory, List <string> backstoryCategories, FactionDef factionType)
 {
     tmpBackstories.Clear();
     BackstoryDatabase.ShuffleableBackstoryList(slot, backstoryCategories, tmpBackstories);
     if (!tmpBackstories.TakeRandom(20).Where(delegate(Backstory bs)
     {
         if (slot == BackstorySlot.Adulthood && bs.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables))
         {
             return(false);
         }
         return(true);
     }).TryRandomElementByWeight(BackstorySelectionWeight, out backstory))
     {
         Log.Error("No shuffled " + slot + " found for " + pawn.ToStringSafe() + " of " + factionType.ToStringSafe() + ". Defaulting.");
         backstory = (from kvp in BackstoryDatabase.allBackstories
                      where kvp.Value.slot == slot
                      select kvp).RandomElement().Value;
     }
     tmpBackstories.Clear();
 }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    if (this.childhood != null)
                    {
                        this.$current = this.childhood;
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        return(true);
                    }
                    break;

                case 1u:
                    break;

                case 2u:
                    goto IL_90;

                default:
                    return(false);
                }
                if (this.adulthood != null)
                {
                    this.$current = this.adulthood;
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);
                }
IL_90:
                this.$PC = -1;
                return(false);
            }
 private static void FillBackstorySlotShuffled(Pawn pawn, BackstorySlot slot, ref Backstory backstory, FactionDef factionType)
 {
     if (!(from kvp in BackstoryDatabase.allBackstories
           where kvp.Value.shuffleable && kvp.Value.spawnCategories.Contains(factionType.backstoryCategory) && kvp.Value.slot == slot && (slot != BackstorySlot.Adulthood || !kvp.Value.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables))
           select kvp.Value).TryRandomElementByWeight(new Func <Backstory, float>(PawnBioAndNameGenerator.BackstorySelectionWeight), out backstory))
     {
         Log.Error(string.Concat(new object[]
         {
             "No shuffled ",
             slot,
             " found for ",
             pawn,
             " of ",
             factionType,
             ". Defaulting."
         }));
         backstory = (from kvp in BackstoryDatabase.allBackstories
                      where kvp.Value.slot == slot
                      select kvp).RandomElement <KeyValuePair <string, Backstory> >().Value;
     }
 }
Пример #16
0
        public Backstory ToBackstory()
        {
            Backstory bs = new Backstory();

            bs.identifier = $"{GetType().Name}_{this.defName}";
            bs.slot       = this.slot;
            bs.SetTitle(this.title);
            bs.SetTitleShort(this.titleShort);
            bs.baseDesc           = this.baseDesc;
            bs.skillGainsResolved = this.skillGains;
            bs.workDisables       = this.workDisables;
            bs.requiredWorkTags   = this.requiredWorkTags;
            bs.spawnCategories    = this.spawnCategories;
            bs.bodyTypeGlobal     = this.bodyTypeGlobal;
            bs.bodyTypeFemale     = this.bodyTypeFemale;
            bs.bodyTypeMale       = this.bodyTypeMale;
            bs.forcedTraits       = this.forcedTraits.ToTraitEntryList();
            bs.disallowedTraits   = this.disallowedTraits.ToTraitEntryList();
            bs.shuffleable        = this.shuffleable;
            return(bs);
        }
Пример #17
0
 private static void FillBackstorySlotShuffled(Pawn pawn, BackstorySlot slot, ref Backstory backstory, FactionDef factionType)
 {
     if (!(from kvp in BackstoryDatabase.allBackstories.Where(delegate(KeyValuePair <string, Backstory> kvp)
     {
         if (kvp.Value.shuffleable && kvp.Value.spawnCategories.Contains(factionType.backstoryCategory) && kvp.Value.slot == slot)
         {
             if (slot == BackstorySlot.Adulthood && kvp.Value.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables))
             {
                 return(false);
             }
             return(true);
         }
         return(false);
     })
           select kvp.Value).TryRandomElementByWeight <Backstory>((Func <Backstory, float>)PawnBioAndNameGenerator.BackstorySelectionWeight, out backstory))
     {
         Log.Error("No shuffled " + slot + " found for " + pawn + " of " + factionType + ". Defaulting.");
         backstory = (from kvp in BackstoryDatabase.allBackstories
                      where kvp.Value.slot == slot
                      select kvp).RandomElement().Value;
     }
 }
Пример #18
0
        public static string GetIdentifierClosestMatch(string identifier, bool closestMatchWarning = true)
        {
            if (allBackstories.ContainsKey(identifier))
            {
                return(identifier);
            }
            string b = StripNumericSuffix(identifier);

            foreach (KeyValuePair <string, Backstory> allBackstory in allBackstories)
            {
                Backstory value = allBackstory.Value;
                if (StripNumericSuffix(value.identifier) == b)
                {
                    if (closestMatchWarning)
                    {
                        Log.Warning("Couldn't find exact match for backstory " + identifier + ", using closest match " + value.identifier);
                    }
                    return(value.identifier);
                }
            }
            Log.Warning("Couldn't find exact match for backstory " + identifier + ", or any close match.");
            return(identifier);
        }
Пример #19
0
        public static void DrawCharacterCard(Rect rect, Pawn pawn, Action randomizeCallback = null, Rect creationRect = default(Rect))
        {
            bool creationMode = randomizeCallback != null;

            GUI.BeginGroup(creationMode ? creationRect : rect);
            Rect       rect2      = new Rect(0f, 0f, 300f, 30f);
            NameTriple nameTriple = pawn.Name as NameTriple;

            if (creationMode && nameTriple != null)
            {
                Rect rect3 = new Rect(rect2);
                rect3.width *= 0.333f;
                Rect rect4 = new Rect(rect2);
                rect4.width *= 0.333f;
                rect4.x     += rect4.width;
                Rect rect5 = new Rect(rect2);
                rect5.width *= 0.333f;
                rect5.x     += rect4.width * 2f;
                string name  = nameTriple.First;
                string name2 = nameTriple.Nick;
                string name3 = nameTriple.Last;
                DoNameInputRect(rect3, ref name, 12);
                if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.5f);
                }
                DoNameInputRect(rect4, ref name2, 16);
                GUI.color = Color.white;
                DoNameInputRect(rect5, ref name3, 12);
                if (nameTriple.First != name || nameTriple.Nick != name2 || nameTriple.Last != name3)
                {
                    pawn.Name = new NameTriple(name, string.IsNullOrEmpty(name2) ? name : name2, name3);
                }
                TooltipHandler.TipRegionByKey(rect3, "FirstNameDesc");
                TooltipHandler.TipRegionByKey(rect4, "ShortIdentifierDesc");
                TooltipHandler.TipRegionByKey(rect5, "LastNameDesc");
            }
            else
            {
                rect2.width = 999f;
                Text.Font   = GameFont.Medium;
                Widgets.Label(rect2, pawn.Name.ToStringFull);
                Text.Font = GameFont.Small;
            }
            if (randomizeCallback != null)
            {
                Rect rect6 = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rect2.height);
                if (Widgets.ButtonText(rect6, "Randomize".Translate()))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    randomizeCallback();
                }
                UIHighlighter.HighlightOpportunity(rect6, "RandomizePawn");
            }
            if (creationMode)
            {
                Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
            }
            else if (!pawn.health.Dead)
            {
                float num = PawnCardSize(pawn).x - 85f;
                if (pawn.IsFreeColonist && pawn.Spawned)
                {
                    Rect rect7 = new Rect(num, 0f, 30f, 30f);
                    if (Mouse.IsOver(rect7))
                    {
                        TooltipHandler.TipRegion(rect7, PawnBanishUtility.GetBanishButtonTip(pawn));
                    }
                    if (Widgets.ButtonImage(rect7, TexButton.Banish))
                    {
                        if (pawn.Downed)
                        {
                            Messages.Message("MessageCantBanishDownedPawn".Translate(pawn.LabelShort, pawn).AdjustedFor(pawn), pawn, MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                        }
                    }
                    num -= 40f;
                }
                if (pawn.IsColonist)
                {
                    Rect rect8 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegionByKey(rect8, "RenameColonist");
                    if (Widgets.ButtonImage(rect8, TexButton.Rename))
                    {
                        Find.WindowStack.Add(new Dialog_NamePawn(pawn));
                    }
                    num -= 40f;
                }
                if (pawn.IsFreeColonist && !pawn.IsQuestLodger() && pawn.royalty != null && pawn.royalty.AllTitlesForReading.Count > 0)
                {
                    Rect rect9 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegionByKey(rect9, "RenounceTitle");
                    if (Widgets.ButtonImage(rect9, TexButton.RenounceTitle))
                    {
                        FloatMenuUtility.MakeMenu(pawn.royalty.AllTitlesForReading, (RoyalTitle title) => "RenounceTitle".Translate() + ": " + "TitleOfFaction".Translate(title.def.GetLabelCapFor(pawn), title.faction.GetCallLabel()), (RoyalTitle title) => delegate
                        {
                            RoyalTitleUtility.FindLostAndGainedPermits(title.def, null, out List <RoyalTitlePermitDef> _, out List <RoyalTitlePermitDef> lostPermits);
                            StringBuilder stringBuilder = new StringBuilder();
                            if (lostPermits.Count > 0)
                            {
                                stringBuilder.AppendLine("RenounceTitleWillLoosePermits".Translate(pawn.Named("PAWN")) + ":");
                                foreach (RoyalTitlePermitDef item2 in lostPermits)
                                {
                                    stringBuilder.AppendLine("- " + item2.LabelCap + " (" + FirstTitleWithPermit(item2).GetLabelFor(pawn) + ")");
                                }
                                stringBuilder.AppendLine();
                            }
                            if (!title.faction.def.renounceTitleMessage.NullOrEmpty())
                            {
                                stringBuilder.AppendLine(title.faction.def.renounceTitleMessage);
                            }
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("RenounceTitleDescription".Translate(pawn.Named("PAWN"), "TitleOfFaction".Translate(title.def.GetLabelCapFor(pawn), title.faction.GetCallLabel()).Named("TITLE"), stringBuilder.ToString().TrimEndNewlines().Named("EFFECTS")), delegate
                            {
                                pawn.royalty.SetTitle(title.faction, null, grantRewards: false);
                            }, destructive: true));
                        });
                    }
                    num -= 40f;
                }
            }
            List <GenUI.AnonymousStackElement> stackElements = new List <GenUI.AnonymousStackElement>();

            Text.Font = GameFont.Small;
            string  text   = pawn.MainDesc(writeFaction: false);
            Vector2 vector = Text.CalcSize(text);
            Rect    rect10 = new Rect(0f, 45f, vector.x + 5f, 24f);

            Widgets.Label(rect10, text);
            float height = Text.CalcHeight(text, rect10.width);
            Rect  rect11 = new Rect(rect10.x, rect10.y, rect10.width, height);

            if (Mouse.IsOver(rect11))
            {
                TooltipHandler.TipRegion(rect11, () => pawn.ageTracker.AgeTooltipString, 6873641);
            }
            float num2 = 0f;

            if (pawn.Faction != null && !pawn.Faction.def.hidden)
            {
                float num3 = Text.CalcSize(pawn.Faction.Name).x + 22f + 15f;
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Rect rect23  = new Rect(r.x, r.y, r.width, r.height);
                        Color color7 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(rect23, BaseContent.WhiteTex);
                        GUI.color = color7;
                        Widgets.DrawHighlightIfMouseover(rect23);
                        Rect rect24    = new Rect(r.x, r.y, r.width, r.height);
                        Rect position4 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                        GUI.color      = pawn.Faction.Color;
                        GUI.DrawTexture(position4, pawn.Faction.def.FactionIcon);
                        GUI.color = color7;
                        Widgets.Label(new Rect(rect24.x + rect24.height + 5f, rect24.y, rect24.width - 10f, rect24.height), pawn.Faction.Name);
                        if (Widgets.ButtonInvisible(rect23))
                        {
                            if (creationMode)
                            {
                                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
                            }
                            else
                            {
                                Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Factions);
                            }
                        }
                        if (Mouse.IsOver(rect23))
                        {
                            TipSignal tip6 = new TipSignal(() => "Faction".Translate() + "\n\n" + "FactionDesc".Translate(pawn.Named("PAWN")) + "\n\n" + "ClickToViewFactions".Translate(), pawn.Faction.loadID * 37);
                            TooltipHandler.TipRegion(rect23, tip6);
                        }
                    },
                    width = num3
                });
                num2 += num3;
            }
            bool  flag = false;
            float num4 = rect.width - vector.x - 10f;

            tmpExtraFactions.Clear();
            QuestUtility.GetExtraFactionsFromQuestParts(pawn, tmpExtraFactions);
            foreach (ExtraFaction tmpExtraFaction in tmpExtraFactions)
            {
                ExtraFaction localExtraFaction    = tmpExtraFaction;
                string       factionName          = localExtraFaction.faction.Name;
                bool         drawExtraFactionIcon = localExtraFaction.factionType == ExtraFactionType.HomeFaction;
                float        num5 = ElementWidth();
                if (flag || num2 + num5 >= num4)
                {
                    factionName = "...";
                    num5        = ElementWidth();
                    flag        = true;
                }
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Rect rect20  = new Rect(r.x, r.y, r.width, r.height);
                        Rect rect21  = drawExtraFactionIcon ? rect20 : r;
                        Color color6 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(rect21, BaseContent.WhiteTex);
                        GUI.color = color6;
                        Widgets.DrawHighlightIfMouseover(rect21);
                        if (drawExtraFactionIcon)
                        {
                            Rect rect22    = new Rect(r.x, r.y, r.width, r.height);
                            Rect position3 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                            GUI.color      = localExtraFaction.faction.Color;
                            GUI.DrawTexture(position3, localExtraFaction.faction.def.FactionIcon);
                            GUI.color = color6;
                            Widgets.Label(new Rect(rect22.x + rect22.height + 5f, rect22.y, rect22.width - 10f, rect22.height), factionName);
                        }
                        else
                        {
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), factionName);
                        }
                        if (Widgets.ButtonInvisible(rect20))
                        {
                            Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Factions);
                        }
                        if (Mouse.IsOver(rect21))
                        {
                            TipSignal tip5 = new TipSignal(() => localExtraFaction.factionType.GetLabel().CapitalizeFirst() + "\n\n" + "ExtraFactionDesc".Translate(pawn.Named("PAWN")) + "\n\n" + "ClickToViewFactions".Translate(), localExtraFaction.faction.loadID ^ 0x738AC053);
                            TooltipHandler.TipRegion(rect21, tip5);
                        }
                    },
                    width = num5
                });
                num2 += num5;
                float ElementWidth()
                {
                    return(Text.CalcSize(factionName).x + (float)(drawExtraFactionIcon ? 22 : 0) + 15f);
                }
            }
            GenUI.DrawElementStack(new Rect(vector.x + 10f, 45f, 999f, 24f), 22f, stackElements, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => obj.width, 4f, 5f, allowOrderOptimization: false);
            stackElements.Clear();
            float curY = 72f;

            if (pawn.royalty != null && pawn.royalty.AllTitlesForReading.Count > 0)
            {
                foreach (RoyalTitle title2 in pawn.royalty.AllTitlesForReading)
                {
                    RoyalTitle localTitle = title2;
                    string     titleLabel = localTitle.def.GetLabelCapFor(pawn) + " (" + pawn.royalty.GetFavor(localTitle.faction) + ")";
                    stackElements.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            Color color5 = GUI.color;
                            Rect rect18  = new Rect(r.x, r.y, r.width + 22f, r.height);
                            GUI.color    = StackElementBackground;
                            GUI.DrawTexture(rect18, BaseContent.WhiteTex);
                            GUI.color = color5;
                            int favor = pawn.royalty.GetFavor(localTitle.faction);
                            if (Mouse.IsOver(rect18))
                            {
                                Widgets.DrawHighlight(rect18);
                            }
                            Rect rect19    = new Rect(r.x, r.y, r.width + 22f, r.height);
                            Rect position2 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                            GUI.color      = title2.faction.Color;
                            GUI.DrawTexture(position2, localTitle.faction.def.FactionIcon);
                            GUI.color = color5;
                            Widgets.Label(new Rect(rect19.x + rect19.height + 5f, rect19.y, rect19.width - 10f, rect19.height), titleLabel);
                            if (Widgets.ButtonInvisible(rect18))
                            {
                                Find.WindowStack.Add(new Dialog_InfoCard(localTitle.def, localTitle.faction));
                            }
                            if (Mouse.IsOver(rect18))
                            {
                                TipSignal tip4 = new TipSignal(() => GetTitleTipString(pawn, localTitle.faction, localTitle, favor), (int)curY * 37);
                                TooltipHandler.TipRegion(rect18, tip4);
                            }
                        },
                        width = Text.CalcSize(titleLabel).x + 15f
                    });
                }
            }
            QuestUtility.AppendInspectStringsFromQuestParts(delegate(string str, Quest quest)
            {
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Color color4 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(r, BaseContent.WhiteTex);
                        GUI.color = color4;
                        DoQuestLine(r, str, quest);
                    },
                    width = GetQuestLineSize(str, quest).x
                });
            }, pawn, out int _);
            curY += GenUI.DrawElementStack(new Rect(0f, curY, rect.width - 5f, 50f), 22f, stackElements, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => obj.width).height;
            if (stackElements.Any())
            {
                curY += 10f;
            }
            Rect leftRect = new Rect(0f, curY, 250f, 355f);
            Rect position = new Rect(leftRect.xMax, curY, 258f, 355f);

            GUI.BeginGroup(leftRect);
            curY = 0f;
            Pawn           pawnLocal = pawn;
            List <Ability> abilities = (from a in pawn.abilities.abilities
                                        orderby a.def.level, a.def.EntropyGain
                                        select a).ToList();
            int   numSections = abilities.Any() ? 5 : 4;
            float num6        = (float)Enum.GetValues(typeof(BackstorySlot)).Length * 22f;

            if (pawn.story != null && pawn.story.title != null)
            {
                num6 += 22f;
            }
            List <LeftRectSection> list = new List <LeftRectSection>();
            LeftRectSection        item = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    float num12 = sectionRect.y;
                    Text.Font = GameFont.Small;
                    foreach (BackstorySlot value6 in Enum.GetValues(typeof(BackstorySlot)))
                    {
                        Backstory backstory = pawn.story.GetBackstory(value6);
                        if (backstory != null)
                        {
                            Rect rect14 = new Rect(sectionRect.x, num12, leftRect.width, 22f);
                            if (Mouse.IsOver(rect14))
                            {
                                Widgets.DrawHighlight(rect14);
                            }
                            if (Mouse.IsOver(rect14))
                            {
                                TooltipHandler.TipRegion(rect14, backstory.FullDescriptionFor(pawn).Resolve());
                            }
                            Text.Anchor = TextAnchor.MiddleLeft;
                            string str2 = (value6 == BackstorySlot.Adulthood) ? "Adulthood".Translate() : "Childhood".Translate();
                            Widgets.Label(rect14, str2 + ":");
                            Text.Anchor = TextAnchor.UpperLeft;
                            Rect rect15 = new Rect(rect14);
                            rect15.x     += 90f;
                            rect15.width -= 90f;
                            string str3 = backstory.TitleCapFor(pawn.gender);
                            Widgets.Label(rect15, str3.Truncate(rect15.width));
                            num12 += rect14.height;
                        }
                    }
                    if (pawn.story != null && pawn.story.title != null)
                    {
                        Rect rect16 = new Rect(sectionRect.x, num12, leftRect.width, 22f);
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Widgets.Label(rect16, "Current".Translate() + ":");
                        Text.Anchor = TextAnchor.UpperLeft;
                        Rect rect17 = new Rect(rect16);
                        rect17.x     += 90f;
                        rect17.width -= 90f;
                        Widgets.Label(rect17, pawn.story.title);
                        num12 += rect16.height;
                    }
                }
            };

            list.Add(item);
            num6 = 30f;
            WorkTags        disabledTags               = pawn.CombinedDisabledWorkTags;
            List <WorkTags> disabledTagsList           = WorkTagsFrom(disabledTags).ToList();
            bool            allowWorkTagVerticalLayout = false;

            GenUI.StackElementWidthGetter <WorkTags> workTagWidthGetter = (WorkTags tag) => Text.CalcSize(tag.LabelTranslated().CapitalizeFirst()).x + 10f;
            if (disabledTags == WorkTags.None)
            {
                num6 += 22f;
            }
            else
            {
                disabledTagsList.Sort(delegate(WorkTags a, WorkTags b)
                {
                    int num11  = GetWorkTypeDisableCauses(pawn, a).Any((object c) => c is RoyalTitleDef) ? 1 : (-1);
                    int value5 = GetWorkTypeDisableCauses(pawn, b).Any((object c) => c is RoyalTitleDef) ? 1 : (-1);
                    return(num11.CompareTo(value5));
                });
                num6 += GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 22f, disabledTagsList, delegate
                {
                }, workTagWidthGetter, 4f, 5f, allowOrderOptimization: false).height;
                num6 += 12f;
                allowWorkTagVerticalLayout = (GenUI.DrawElementStackVertical(new Rect(0f, 0f, rect.width, leftRect.height / (float)numSections), 22f, disabledTagsList, delegate
                {
                }, workTagWidthGetter).width <= leftRect.width);
            }
            item = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    Text.Font = GameFont.Medium;
                    float currentY3 = sectionRect.y;
                    Widgets.Label(new Rect(sectionRect.x, currentY3, 200f, 30f), "IncapableOf".Translate(pawn));
                    currentY3 += 30f;
                    Text.Font  = GameFont.Small;
                    if (disabledTags == WorkTags.None)
                    {
                        GUI.color = Color.gray;
                        Rect rect13 = new Rect(sectionRect.x, currentY3, leftRect.width, 24f);
                        if (Mouse.IsOver(rect13))
                        {
                            Widgets.DrawHighlight(rect13);
                        }
                        Widgets.Label(rect13, "None".Translate());
                        TooltipHandler.TipRegionByKey(rect13, "None");
                    }
                    else
                    {
                        GenUI.StackElementDrawer <WorkTags> drawer = delegate(Rect r, WorkTags tag)
                        {
                            Color color3 = GUI.color;
                            GUI.color = StackElementBackground;
                            GUI.DrawTexture(r, BaseContent.WhiteTex);
                            GUI.color = color3;
                            GUI.color = GetDisabledWorkTagLabelColor(pawn, tag);
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), tag.LabelTranslated().CapitalizeFirst());
                            if (Mouse.IsOver(r))
                            {
                                TooltipHandler.TipRegion(tip: new TipSignal(() => GetWorkTypeDisabledCausedBy(pawnLocal, tag) + "\n" + GetWorkTypesDisabledByWorkTag(tag), (int)currentY3 * 32), rect: r);
                            }
                        };
                        if (allowWorkTagVerticalLayout)
                        {
                            GenUI.DrawElementStackVertical(new Rect(sectionRect.x, currentY3, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, disabledTagsList, drawer, workTagWidthGetter);
                        }
                        else
                        {
                            GenUI.DrawElementStack(new Rect(sectionRect.x, currentY3, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, disabledTagsList, drawer, workTagWidthGetter, 5f);
                        }
                    }
                    GUI.color = Color.white;
                }
            };
            list.Add(item);
            num6 = 30f;
            List <Trait> traits = pawn.story.traits.allTraits;

            num6 = ((traits != null && traits.Count != 0) ? (num6 + GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 22f, pawn.story.traits.allTraits, delegate
            {
            }, (Trait trait) => Text.CalcSize(trait.LabelCap).x + 10f).height) : (num6 + 22f));
            num6 += 12f;
            item  = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    Text.Font = GameFont.Medium;
                    float currentY2 = sectionRect.y;
                    Widgets.Label(new Rect(sectionRect.x, currentY2, 200f, 30f), "Traits".Translate());
                    currentY2 += 30f;
                    Text.Font  = GameFont.Small;
                    if (traits == null || traits.Count == 0)
                    {
                        Color color = GUI.color;
                        GUI.color = Color.gray;
                        Rect rect12 = new Rect(sectionRect.x, currentY2, leftRect.width, 24f);
                        if (Mouse.IsOver(rect12))
                        {
                            Widgets.DrawHighlight(rect12);
                        }
                        Widgets.Label(rect12, "None".Translate());
                        currentY2 += rect12.height + 2f;
                        TooltipHandler.TipRegionByKey(rect12, "None");
                        GUI.color = color;
                    }
                    else
                    {
                        GenUI.DrawElementStack(new Rect(sectionRect.x, currentY2, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, pawn.story.traits.allTraits, delegate(Rect r, Trait trait)
                        {
                            Color color2 = GUI.color;
                            GUI.color    = StackElementBackground;
                            GUI.DrawTexture(r, BaseContent.WhiteTex);
                            GUI.color = color2;
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), trait.LabelCap);
                            if (Mouse.IsOver(r))
                            {
                                TooltipHandler.TipRegion(tip: new TipSignal(() => trait.TipString(pawn), (int)currentY2 * 37), rect: r);
                            }
                        }, (Trait trait) => Text.CalcSize(trait.LabelCap).x + 10f);
                    }
                }
            };
            list.Add(item);
            if (abilities.Any())
            {
                num6  = 30f;
                num6 += GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 32f, abilities, delegate
                {
                }, (Ability abil) => 32f).height;
                item = new LeftRectSection
                {
                    rect   = new Rect(0f, 0f, leftRect.width, num6),
                    drawer = delegate(Rect sectionRect)
                    {
                        Text.Font = GameFont.Medium;
                        float currentY = sectionRect.y;
                        Widgets.Label(new Rect(sectionRect.x, currentY, 200f, 30f), "Abilities".Translate(pawn));
                        currentY += 30f;
                        Text.Font = GameFont.Small;
                        GenUI.DrawElementStack(new Rect(sectionRect.x, currentY, leftRect.width - 5f, leftRect.height), 32f, abilities, delegate(Rect r, Ability abil)
                        {
                            GUI.DrawTexture(r, BaseContent.ClearTex);
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            if (Widgets.ButtonImage(r, abil.def.uiIcon, doMouseoverSound: false))
                            {
                                Find.WindowStack.Add(new Dialog_InfoCard(abil.def));
                            }
                            if (Mouse.IsOver(r))
                            {
                                TipSignal tip = new TipSignal(() => abil.def.GetTooltip() + "\n\n" + "ClickToLearnMore".Translate(), (int)currentY * 37);
                                TooltipHandler.TipRegion(r, tip);
                            }
                        }, (Ability abil) => 32f);
                        GUI.color = Color.white;
                    }
                };
                list.Add(item);
            }
            float num7 = leftRect.height / (float)list.Count;
            float num8 = 0f;

            for (int i = 0; i < list.Count; i++)
            {
                LeftRectSection value = list[i];
                if (value.rect.height > num7)
                {
                    num8 += value.rect.height - num7;
                    value.calculatedSize = value.rect.height;
                }
                else
                {
                    value.calculatedSize = num7;
                }
                list[i] = value;
            }
            bool  flag2 = false;
            float num9  = 0f;

            if (num8 > 0f)
            {
                LeftRectSection value2 = list[0];
                float           num10  = value2.rect.height + 12f;
                num8 -= value2.calculatedSize - num10;
                value2.calculatedSize = num10;
                list[0] = value2;
            }
            while (num8 > 0f)
            {
                bool flag3 = true;
                for (int j = 0; j < list.Count; j++)
                {
                    LeftRectSection value3 = list[j];
                    if (value3.calculatedSize - value3.rect.height > 0f)
                    {
                        value3.calculatedSize -= 1f;
                        num8 -= 1f;
                        flag3 = false;
                    }
                    list[j] = value3;
                }
                if (!flag3)
                {
                    continue;
                }
                for (int k = 0; k < list.Count; k++)
                {
                    LeftRectSection value4 = list[k];
                    if (k > 0)
                    {
                        value4.calculatedSize = Mathf.Max(value4.rect.height, num7);
                    }
                    else
                    {
                        value4.calculatedSize = value4.rect.height + 22f;
                    }
                    num9   += value4.calculatedSize;
                    list[k] = value4;
                }
                flag2 = true;
                break;
            }
            if (flag2)
            {
                Widgets.BeginScrollView(new Rect(0f, 0f, leftRect.width, leftRect.height), ref leftRectScrollPos, new Rect(0f, 0f, leftRect.width - 16f, num9));
            }
            curY = 0f;
            for (int l = 0; l < list.Count; l++)
            {
                LeftRectSection leftRectSection = list[l];
                leftRectSection.drawer(new Rect(0f, curY, leftRect.width, leftRectSection.rect.height));
                curY += leftRectSection.calculatedSize;
            }
            if (flag2)
            {
                Widgets.EndScrollView();
            }
            GUI.EndGroup();
            GUI.BeginGroup(position);
            SkillUI.DrawSkillsOf(mode: (Current.ProgramState != ProgramState.Playing) ? SkillUI.SkillDrawMode.Menu : SkillUI.SkillDrawMode.Gameplay, p: pawn, offset: new Vector2(0f, 0f));
            GUI.EndGroup();
            GUI.EndGroup();
            RoyalTitleDef FirstTitleWithPermit(RoyalTitlePermitDef permitDef)
            {
                //return title.faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.First((RoyalTitleDef t) => t.permits != null && t.permits.Contains(permitDef));
                Log.Message("Todo:>>>>");
                return(default);
Пример #20
0
 public static bool TryGetWithIdentifier(string identifier, out Backstory bs, bool closestMatchWarning = true)
 {
     identifier = GetIdentifierClosestMatch(identifier, closestMatchWarning);
     return(allBackstories.TryGetValue(identifier, out bs));
 }
Пример #21
0
 public static bool TryGetWithIdentifier(string identifier, out Backstory bs)
 {
     return(BackstoryDatabase.allBackstories.TryGetValue(identifier, out bs));
 }
        public static void DrawCharacterCard(Rect rect, Pawn pawn, Action randomizeCallback = null, Rect creationRect = default(Rect))
        {
            bool flag = randomizeCallback != null;

            GUI.BeginGroup((!flag) ? rect : creationRect);
            Rect       rect2      = new Rect(0f, 0f, 300f, 30f);
            NameTriple nameTriple = pawn.Name as NameTriple;

            if (flag && nameTriple != null)
            {
                Rect rect3 = new Rect(rect2);
                rect3.width *= 0.333f;
                Rect rect4 = new Rect(rect2);
                rect4.width *= 0.333f;
                rect4.x     += rect4.width;
                Rect rect5 = new Rect(rect2);
                rect5.width *= 0.333f;
                rect5.x     += rect4.width * 2f;
                string first = nameTriple.First;
                string nick  = nameTriple.Nick;
                string last  = nameTriple.Last;
                CharacterCardUtility.DoNameInputRect(rect3, ref first, 12);
                if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.5f);
                }
                CharacterCardUtility.DoNameInputRect(rect4, ref nick, 16);
                GUI.color = Color.white;
                CharacterCardUtility.DoNameInputRect(rect5, ref last, 12);
                if (nameTriple.First != first || nameTriple.Nick != nick || nameTriple.Last != last)
                {
                    pawn.Name = new NameTriple(first, nick, last);
                }
                TooltipHandler.TipRegion(rect3, "FirstNameDesc".Translate());
                TooltipHandler.TipRegion(rect4, "ShortIdentifierDesc".Translate());
                TooltipHandler.TipRegion(rect5, "LastNameDesc".Translate());
            }
            else
            {
                rect2.width = 999f;
                Text.Font   = GameFont.Medium;
                Widgets.Label(rect2, pawn.Name.ToStringFull);
                Text.Font = GameFont.Small;
            }
            if (randomizeCallback != null)
            {
                Rect rect6 = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rect2.height);
                if (Widgets.ButtonText(rect6, "Randomize".Translate(), true, false, true))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                    randomizeCallback();
                }
                UIHighlighter.HighlightOpportunity(rect6, "RandomizePawn");
            }
            if (flag)
            {
                Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
            }
            else if (!pawn.health.Dead)
            {
                float num = CharacterCardUtility.PawnCardSize.x - 85f;
                if ((pawn.Faction == Faction.OfPlayer || pawn.IsPrisonerOfColony) && pawn.Spawned)
                {
                    Rect rect7 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegion(rect7, PawnBanishUtility.GetBanishButtonTip(pawn));
                    if (Widgets.ButtonImage(rect7, TexButton.Banish))
                    {
                        if (pawn.Downed)
                        {
                            Messages.Message("MessageCantBanishDownedPawn".Translate(pawn.LabelShort, pawn).AdjustedFor(pawn, "PAWN"), pawn, MessageTypeDefOf.RejectInput, false);
                        }
                        else
                        {
                            PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                        }
                    }
                    num -= 40f;
                }
                if (pawn.IsColonist)
                {
                    Rect rect8 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegion(rect8, "RenameColonist".Translate());
                    if (Widgets.ButtonImage(rect8, TexButton.Rename))
                    {
                        Find.WindowStack.Add(new Dialog_NamePawn(pawn));
                    }
                    num -= 40f;
                }
            }
            string label = pawn.MainDesc(true);
            Rect   rect9 = new Rect(0f, 45f, rect.width, 60f);

            Widgets.Label(rect9, label);
            TooltipHandler.TipRegion(rect9, () => pawn.ageTracker.AgeTooltipString, 6873641);
            Rect position  = new Rect(0f, 100f, 250f, 450f);
            Rect position2 = new Rect(position.xMax, 100f, 258f, 450f);

            GUI.BeginGroup(position);
            float num2 = 0f;

            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Backstory".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            foreach (BackstorySlot backstorySlot in Enum.GetValues(typeof(BackstorySlot)))
            {
                Backstory backstory = pawn.story.GetBackstory(backstorySlot);
                if (backstory != null)
                {
                    Rect rect10 = new Rect(0f, num2, position.width, 24f);
                    if (Mouse.IsOver(rect10))
                    {
                        Widgets.DrawHighlight(rect10);
                    }
                    TooltipHandler.TipRegion(rect10, backstory.FullDescriptionFor(pawn));
                    Text.Anchor = TextAnchor.MiddleLeft;
                    string str = (backstorySlot != BackstorySlot.Adulthood) ? "Childhood".Translate() : "Adulthood".Translate();
                    Widgets.Label(rect10, str + ":");
                    Text.Anchor = TextAnchor.UpperLeft;
                    Rect rect11 = new Rect(rect10);
                    rect11.x     += 90f;
                    rect11.width -= 90f;
                    string label2 = backstory.TitleCapFor(pawn.gender);
                    Widgets.Label(rect11, label2);
                    num2 += rect10.height + 2f;
                }
            }
            if (pawn.story != null && pawn.story.title != null)
            {
                Rect rect12 = new Rect(0f, num2, position.width, 24f);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(rect12, "Current".Translate() + ":");
                Text.Anchor = TextAnchor.UpperLeft;
                Rect rect13 = new Rect(rect12);
                rect13.x     += 90f;
                rect13.width -= 90f;
                Widgets.Label(rect13, pawn.story.title);
                num2 += rect12.height + 2f;
            }
            num2     += 25f;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, num2, 200f, 30f), "IncapableOf".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            StringBuilder stringBuilder            = new StringBuilder();
            WorkTags      combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;

            if (combinedDisabledWorkTags == WorkTags.None)
            {
                stringBuilder.Append("(" + "NoneLower".Translate() + "), ");
            }
            else
            {
                List <WorkTags> list  = CharacterCardUtility.WorkTagsFrom(combinedDisabledWorkTags).ToList <WorkTags>();
                bool            flag2 = true;
                foreach (WorkTags current in list)
                {
                    if (flag2)
                    {
                        stringBuilder.Append(current.LabelTranslated().CapitalizeFirst());
                    }
                    else
                    {
                        stringBuilder.Append(current.LabelTranslated());
                    }
                    stringBuilder.Append(", ");
                    flag2 = false;
                }
            }
            string text = stringBuilder.ToString();

            text = text.Substring(0, text.Length - 2);
            Rect rect14 = new Rect(0f, num2, position.width, 999f);

            Widgets.Label(rect14, text);
            num2     += 100f;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, num2, 200f, 30f), "Traits".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
            {
                Trait trait  = pawn.story.traits.allTraits[i];
                Rect  rect15 = new Rect(0f, num2, position.width, 24f);
                if (Mouse.IsOver(rect15))
                {
                    Widgets.DrawHighlight(rect15);
                }
                Widgets.Label(rect15, trait.LabelCap);
                num2 += rect15.height + 2f;
                Trait     trLocal = trait;
                TipSignal tip     = new TipSignal(() => trLocal.TipString(pawn), (int)num2 * 37);
                TooltipHandler.TipRegion(rect15, tip);
            }
            GUI.EndGroup();
            GUI.BeginGroup(position2);
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Skills".Translate());
            SkillUI.SkillDrawMode mode;
            if (Current.ProgramState == ProgramState.Playing)
            {
                mode = SkillUI.SkillDrawMode.Gameplay;
            }
            else
            {
                mode = SkillUI.SkillDrawMode.Menu;
            }
            SkillUI.DrawSkillsOf(pawn, new Vector2(0f, 35f), mode);
            GUI.EndGroup();
            GUI.EndGroup();
        }
Пример #23
0
 internal bool <> m__0(Backstory bs)
 {
     return(this.slot != BackstorySlot.Adulthood || !bs.requiredWorkTags.OverlapsWithOnAnyWorkType(this.pawn.story.childhood.workDisables));
 }
Пример #24
0
 private static float BackstorySelectionWeight(Backstory bs)
 {
     return(PawnBioAndNameGenerator.SelectionWeightFactorFromWorkTagsDisabled(bs.workDisables));
 }
Пример #25
0
 private static float BackstorySelectionWeight(Backstory bs)
 {
     return(SelectionWeightFactorFromWorkTagsDisabled(bs.workDisables));
 }
        public static void InjectHardcodedData(Backstory bs)
        {
            string a = bs.title.CapitalizeFirst();

            if (a == "Urbworld sex slave")
            {
                bs.AddForcedTrait(TraitDefOf.Beauty, 2);
            }
            if (a == "Pop idol")
            {
                bs.AddForcedTrait(TraitDefOf.Beauty, 2);
            }
            if (a == "Mechanoid nerd")
            {
                bs.AddDisallowedTrait(TraitDefOf.Gay, 0);
            }
            if (a == "Mad scientist")
            {
                bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
            }
            if (a == "Urbworld politican")
            {
                bs.AddForcedTrait(TraitDefOf.Greedy, 0);
            }
            if (a == "Criminal tinker")
            {
                bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
            }
            if (a == "Urbworld enforcer")
            {
                bs.AddForcedTrait(TraitDefOf.Nerves, 1);
            }
            if (a == "Pyro assistant")
            {
                bs.AddForcedTrait(TraitDefOf.Pyromaniac, 0);
            }
            if (a == "Stiletto assassin")
            {
                bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
            }
            if (a == "Discharged soldier")
            {
                bs.AddForcedTrait(TraitDefOf.TooSmart, 0);
            }
            if (a == "Bloody wanderer")
            {
                bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
            }
            if (a == "New age duelist")
            {
                bs.AddForcedTrait(TraitDefOf.Industriousness, -1);
            }
            if (a == "Pirate doctor")
            {
                bs.AddForcedTrait(TraitDefOf.NaturalMood, 1);
            }
            if (a == "Cave child")
            {
                bs.AddForcedTrait(TraitDefOf.Tunneler, 0);
            }
            if (a == "Space marine medic")
            {
                bs.AddForcedTrait(TraitDefOf.SpeedOffset, 2);
                bs.AddForcedTrait(TraitDefOf.ShootingAccuracy, -1);
            }
        }
 private static float BackstorySelectionWeight(Backstory bs)
 {
     return(PawnBioAndNameGenerator.WorkDisablesSelectionWeight(bs.workDisables));
 }
Пример #28
0
 public static void InjectHardcodedData(Backstory bs)
 {
     if (bs.title == "urbworld sex slave")
     {
         bs.AddForcedTrait(TraitDefOf.Beauty, 2);
     }
     if (bs.title == "pop idol")
     {
         bs.AddForcedTrait(TraitDefOf.Beauty, 2);
     }
     if (bs.title == "mechanoid nerd")
     {
         bs.AddDisallowedTrait(TraitDefOf.Gay, 0);
     }
     if (bs.title == "mad scientist")
     {
         bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
     }
     if (bs.title == "urbworld politican")
     {
         bs.AddForcedTrait(TraitDefOf.Greedy, 0);
     }
     if (bs.title == "criminal tinker")
     {
         bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
     }
     if (bs.title == "urbworld enforcer")
     {
         bs.AddForcedTrait(TraitDefOf.Nerves, 1);
     }
     if (bs.title == "pyro assistant")
     {
         bs.AddForcedTrait(TraitDefOf.Pyromaniac, 0);
     }
     if (bs.title == "stiletto assassin")
     {
         bs.AddForcedTrait(TraitDefOf.Psychopath, 0);
     }
     if (bs.title == "discharged soldier")
     {
         bs.AddForcedTrait(TraitDefOf.TooSmart, 0);
     }
     if (bs.title == "bloody wanderer")
     {
         bs.AddForcedTrait(TraitDefOf.Bloodlust, 0);
     }
     if (bs.title == "new age duelist")
     {
         bs.AddForcedTrait(TraitDefOf.Industriousness, -1);
     }
     if (bs.title == "pirate doctor")
     {
         bs.AddForcedTrait(TraitDefOf.NaturalMood, 1);
     }
     if (bs.title == "cave child")
     {
         bs.AddForcedTrait(TraitDefOf.Undergrounder, 0);
     }
     if (bs.title == "space marine medic")
     {
         bs.AddForcedTrait(TraitDefOf.SpeedOffset, 2);
         bs.AddForcedTrait(TraitDefOf.ShootingAccuracy, -1);
     }
     if (bs.title == "bush sniper")
     {
         bs.AddForcedTrait(TraitDefOf.ShootingAccuracy, 1);
     }
 }
Пример #29
0
        public string EnablingThingsExplanation(Pawn pawn)
        {
            List <string> reasons = new List <string>();

            if (requiresRoyalTitle && pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0)
            {
                RoyalTitle royalTitle = pawn.royalty.AllTitlesInEffectForReading.MaxBy((RoyalTitle t) => t.def.seniority);
                reasons.Add("MeditationFocusEnabledByTitle".Translate(royalTitle.def.GetLabelCapFor(pawn).Named("TITLE"), royalTitle.faction.Named("FACTION")).Resolve());
            }
            if (pawn.story != null)
            {
                Backstory adulthood = pawn.story.adulthood;
                Backstory childhood = pawn.story.childhood;
                if (!requiresRoyalTitle && requiredBackstoriesAny.Count == 0)
                {
                    for (int i = 0; i < incompatibleBackstoriesAny.Count; i++)
                    {
                        BackstoryCategoryAndSlot backstoryCategoryAndSlot = incompatibleBackstoriesAny[i];
                        Backstory backstory2 = (backstoryCategoryAndSlot.slot == BackstorySlot.Adulthood) ? adulthood : childhood;
                        if (!backstory2.spawnCategories.Contains(backstoryCategoryAndSlot.categoryName))
                        {
                            AddBackstoryReason(backstoryCategoryAndSlot.slot, backstory2);
                        }
                    }
                    for (int j = 0; j < DefDatabase <TraitDef> .AllDefsListForReading.Count; j++)
                    {
                        TraitDef traitDef = DefDatabase <TraitDef> .AllDefsListForReading[j];
                        List <MeditationFocusDef> disallowedMeditationFocusTypes = traitDef.degreeDatas[0].disallowedMeditationFocusTypes;
                        if (disallowedMeditationFocusTypes != null && disallowedMeditationFocusTypes.Contains(this))
                        {
                            reasons.Add("MeditationFocusDisabledByTrait".Translate() + ": " + traitDef.degreeDatas[0].LabelCap + ".");
                        }
                    }
                }
                for (int k = 0; k < requiredBackstoriesAny.Count; k++)
                {
                    BackstoryCategoryAndSlot backstoryCategoryAndSlot2 = requiredBackstoriesAny[k];
                    Backstory backstory3 = (backstoryCategoryAndSlot2.slot == BackstorySlot.Adulthood) ? adulthood : childhood;
                    if (backstory3.spawnCategories.Contains(backstoryCategoryAndSlot2.categoryName))
                    {
                        AddBackstoryReason(backstoryCategoryAndSlot2.slot, backstory3);
                    }
                }
                for (int l = 0; l < pawn.story.traits.allTraits.Count; l++)
                {
                    Trait trait = pawn.story.traits.allTraits[l];
                    List <MeditationFocusDef> allowedMeditationFocusTypes = trait.CurrentData.allowedMeditationFocusTypes;
                    if (allowedMeditationFocusTypes != null && allowedMeditationFocusTypes.Contains(this))
                    {
                        reasons.Add("MeditationFocusEnabledByTrait".Translate() + ": " + trait.LabelCap + ".");
                    }
                }
            }
            return(reasons.ToLineList("  - ", capitalizeItems: true));

            void AddBackstoryReason(BackstorySlot slot, Backstory backstory)
            {
                if (slot == BackstorySlot.Adulthood)
                {
                    reasons.Add("MeditationFocusEnabledByAdulthood".Translate() + ": " + backstory.title.CapitalizeFirst() + ".");
                }
                else
                {
                    reasons.Add("MeditationFocusEnabledByChildhood".Translate() + ": " + backstory.title.CapitalizeFirst() + ".");
                }
            }
        }