public static void OpenPreacherSelectMenu(BuildingAltar altar)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
            {
                altar.preacher = null;
            }, MenuOptionPriority.Default, null, null, 0f, null));

            foreach (Pawn current in altar.Map.mapPawns.FreeColonistsSpawned)
            {
                if (!SermonUtility.IsPreacher(current))
                {
                    Need_Soul nsoul = current.needs.TryGetNeed <Need_Soul>();
                    if (nsoul == null)
                    {
                        nsoul = new Need_Soul(current);
                    }
                    SoulTrait strait = nsoul.DevotionTrait;
                    string    text1  = current.NameStringShort + " (" + strait.SoulCurrentData.label + ")";

                    Action action;
                    Pawn   localCol = current;
                    action = delegate
                    {
                        altar.preacher = localCol;
                    };
                    list.Add(new FloatMenuOption(text1, action, MenuOptionPriority.Default, null, null, 0f, null));
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Beispiel #2
0
        public override void SetInitialLevel()
        {
            InitiatePsykerComp();
            //           try
            //           {
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Berserker);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_WarpBolt);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Temptation);
            //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Purgatus);
            //           }
            //           catch
            //           { }
            ChaosFollowerPawnKindDef pdef = this.pawn.kindDef as ChaosFollowerPawnKindDef;

            if (pdef != null && pdef.AfflictionProperty != null)
            {
                PawnAfflictionProps      = new AfflictionProperty();
                this.PawnAfflictionProps = pdef.AfflictionProperty;
                int pllow = (int)this.PawnAfflictionProps.LowerPsykerPowerLimit;
                int plup  = (int)this.PawnAfflictionProps.UpperAfflictionLimit;
                this.PsykerPowerLevel = (PsykerPowerLevel)Rand.RangeInclusive(pllow, plup);

                if (PawnAfflictionProps.IsImmune)
                {
                    this.curLevelInt   = 0.99f;
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                    this.IsImmune      = true;
                }
                else if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune    = true;
                    this.curLevelInt = Rand.Range(0.86f, 0.99f);
                    this.NoPatron    = true;
                }
                else
                {
                    float afup   = pdef.AfflictionProperty.UpperAfflictionLimit;
                    float afdown = pdef.AfflictionProperty.LowerAfflictionLimit;
                    this.curLevelInt = (Rand.Range(afup, afdown));
                }
                if (PawnAfflictionProps.UseOtherFaith)
                {
                    this.patronInfo.PatronName = PawnAfflictionProps.IsofFaith.ToString();
                }
                this.CulturalTolerance = PawnAfflictionProps.PrimaryToleranceCategory;
            }
            else
            {
                PawnAfflictionProps    = new AfflictionProperty();
                this.PsykerPowerLevel  = (PsykerPowerLevel)Rand.RangeInclusive(0, Enum.GetValues(typeof(PsykerPowerLevel)).Length - 1);
                this.CulturalTolerance = (CulturalToleranceCategory)Rand.RangeInclusive(0, 2);
                if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune    = true;
                    this.curLevelInt = Rand.Range(0.86f, 0.99f);
                    this.NoPatron    = true;
                }
                else
                {
                    this.curLevelInt = Rand.Range(0.01f, 0.99f);
                }
            }

            if (this.PawnAfflictionProps.CommmonPsykerPowers != null)
            {
                for (int i = 0; i < this.PawnAfflictionProps.CommmonPsykerPowers.Count; i++)
                {
                    try
                    {
                        this.compPsyker.PowerManager.AddPsykerPower(this.PawnAfflictionProps.CommmonPsykerPowers[i]);
                    }
                    catch
                    { }
                }
            }

            if (CorruptionDefOfs.Devotion.SDegreeDatas == null)
            {
                Log.Message("No stdata");
            }

            if (this.SoulTraits.NullOrEmpty())
            {
                if ((PawnAfflictionProps != null && PawnAfflictionProps.IsImmune))
                {
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                    this.IsImmune      = true;
                }
                else
                {
                    this.DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, Rand.RangeInclusive(-2, 2));
                }
                this.SoulTraits.Insert(0, DevotionTrait);
            }
            if (PawnAfflictionProps.CommonSoulTrait != null && !this.SoulTraits.Any(x => x.SDef == PawnAfflictionProps.CommonSoulTrait))
            {
                this.SoulTraits.Add(new SoulTrait(PawnAfflictionProps.CommonSoulTrait, 0));
            }

            if (this.curLevelInt < 0.3f && NoPatron == true)
            {
                GainPatron(ChaosGods.Undivided, false);
            }
            if (NoPatron == false)
            {
                if (curLevelInt > 0.3f)
                {
                    curLevelInt = 0.3f;
                }
            }
            if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
            {
                this.IsImmune = true;
            }
        }
Beispiel #3
0
        public void GainPatron(ChaosGods forcedPatron, bool UseForcedPatron)
        {
            if (PawnAfflictionProps == null)
            {
                PawnAfflictionProps        = new AfflictionProperty();
                PawnAfflictionProps.Patron = ChaosGods.Undivided;
            }

            if (UseForcedPatron)
            {
                PawnAfflictionProps.Patron = forcedPatron;
                this.Patron = PawnAfflictionProps.Patron;
            }
            else
            {
                if (pawn.Faction.def.GetType() == typeof(FactionDefUniform))
                {
                    FactionDefUniform Facdef = this.pawn.Faction.def as FactionDefUniform;

                    if (Facdef.PreferredChaosGod == ChaosGods.Undivided)
                    {
                        PawnAfflictionProps.Patron = ChaosGods.Undivided;
                    }
                    else
                    {
                        PawnAfflictionProps.Patron = Facdef.PreferredChaosGod;
                    }
                }

                if (PawnAfflictionProps == null)
                {
                    PawnAfflictionProps        = new AfflictionProperty();
                    PawnAfflictionProps.Patron = ChaosGods.Undivided;
                }

                if (PawnAfflictionProps.Patron == ChaosGods.Undivided)
                {
                    if (Rand.Range(0.1f, 1f) > 0.5f)
                    {
                        this.Patron = ChaosGods.Undivided;
                    }
                    else
                    {
                        this.Patron = (ChaosGods)Rand.RangeInclusive(1, 4);
                    }
                }
                else
                {
                    this.Patron = PawnAfflictionProps.Patron;
                }
            }

            patronInfo.PatronName = Patron.ToString();
            GeneratePatronTraits(pawn);
            this.SoulTraits.Remove(DevotionTrait);
            DevotionTrait = new SoulTrait(CorruptionDefOfs.Devotion, Rand.RangeInclusive(0, 2));
            this.SoulTraits.Add(DevotionTrait);
            if (pawn.story == null)
            {
                pawn.story = new Pawn_StoryTracker(pawn);
            }
            //         Hediff chaosmark = HediffMaker.MakeHediff(ChaosMarkDef(this.patronInfo.PatronName), this.pawn,null);
            //         this.pawn.health.hediffSet.AddHediffDirect(chaosmark);
            if (this.pawn.Drawer != null && this.pawn.story != null)
            {
                if (this.pawn.Drawer.renderer != null)
                {
                    if (this.pawn.Drawer.renderer.graphics != null && this.pawn.apparel != null)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            this.pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
                            PortraitsCache.SetDirty(this.pawn);
                        });
                    }
                }
            }
            this.NoPatron = false;
        }
Beispiel #4
0
 public void GeneratePatronTraits(Pawn tpawn)
 {
     patronInfo.GetPatronTraits(patronInfo.PatronName);
     this.PatronTrait = patronInfo.PatronTraits[0];
 }
Beispiel #5
0
        public override void DoWindowContents(Rect inRect)
        {
            if (this.SelThing == null)
            {
                this.Close();
            }
            if (Find.Selector.SingleSelectedThing as Pawn != this.SelPawn)
            {
                this.PreOpen();
            }
            this.SetInitialSizeAndPosition();
            Rect rect2 = inRect.ContractedBy(10f);

            rect2.height = 30f;
            rect2.width  = 300;
            rect2.x      = inRect.x + (inRect.width / 2) - 150;
            rect2.y     += 10f;
            //      GUI.BeginGroup(rect2);
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Medium;
            var tmp1 = rect2.y;

            Widgets.Label(rect2, "Patron :");
            //          GUI.EndGroup();
            Rect rect3 = rect2;

            rect3.y += 30f;
            //         GUI.BeginGroup(rect3);
            Rect rect4 = rect3;

            rect4.height = 300f;
            String    texpath = "UI/" + SelPawnPatron + "_bg";
            Texture2D tex     = ContentFinder <Texture2D> .Get(texpath, true);

            GUI.DrawTexture(rect4, tex as Texture);
//            GUI.EndGroup();
            Rect rect5 = rect3;

            rect5.y     += 320f;
            rect5.height = 30f;
            //        GUI.BeginGroup(rect5);
            GUI.color = PatronColor;
            var tmp2 = rect5.y + 5;

            Widgets.Label(rect5, SelPawnPatron.Translate());
            Widgets.ListSeparator(ref tmp2, inRect.width, "");
            GUI.color = Color.white;

            Rect rect7 = rect5;

            rect7.x     = 0f;
            rect7.width = inRect.width / 3;
            rect7.y    += 30;
            Text.Font   = GameFont.Medium;
            Widgets.Label(new Rect(rect7), "ReligiousTraits".Translate());
            Text.Font = GameFont.Small;
            float num    = rect7.y + 30f;
            Rect  rect13 = new Rect(rect7.x, num, rect7.width, 23f);;

            for (int i = 0; i < STraits.Count(); i++)
            {
                SoulTrait trait  = STraits[i];
                Rect      rect12 = new Rect(rect7.x, num, rect7.width, 23f);
                if (Mouse.IsOver(rect12))
                {
                    Widgets.DrawHighlight(rect12);
                }
                Widgets.Label(rect12, trait.SoulCurrentData.label);
                num += rect12.height + 15f;
                SoulTrait trLocal = trait;
                TipSignal tip2    = new TipSignal(() => trLocal.TipString(SelPawn), (int)num * 37);

                TooltipHandler.TipRegion(rect12, tip2);
                rect13 = rect12;
            }

            rect13.y += 53;
            if (Mouse.IsOver(rect13))
            {
                Widgets.DrawHighlight(rect13);
            }
            Widgets.Label(rect13, this.culturalTolerance.ToString());
            num += rect13.height + 15;
            TipSignal tip = new TipSignal(() => culturalToleranceToolTip(this.culturalTolerance), (int)num * 37);

            TooltipHandler.TipRegion(rect13, tip);


            Rect rect8 = rect7;

            rect8.x      = inRect.x + (inRect.width / 2) - 150;
            rect8.width -= 20;
            String desc = SelPawnPatron + "_Description";

            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(rect8), "Description".Translate());
            Rect rect8a = rect8;

            rect8a.y     += 30f;
            rect8a.height = 200f;
            Text.Font     = GameFont.Small;
            Widgets.Label(new Rect(rect8a), desc.Translate());

            Rect rect9 = rect7;

            rect9.x   = rect8.xMax + 20;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(rect9), "SoulStatus".Translate());
            Rect rect9a = rect9;

            rect9a.y += 30f;
            Text.Font = GameFont.Small;
            Widgets.Label(new Rect(rect9a), SelPawnSoulState.Translate());
            TipSignal tip3 = new TipSignal(() => this.AfflictionCategoryToolTip(soul.CurCategory), (int)num * 37);

            TooltipHandler.TipRegion(rect9a, tip3);
            Rect rect9b = rect9a;

            rect9b.y += rect9a.height + 15f;
            Widgets.Label(new Rect(rect9b), this.psykerPowerLevel);
            TipSignal tip4 = new TipSignal(() => this.PsykerPowerLevelToolTip(soul.PsykerPowerLevel), (int)num * 37);

            TooltipHandler.TipRegion(rect9b, tip4);
            Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.CloseButtonFor(inRect.AtZero()))
            {
                this.Close();
            }
            if (this.SelPawn == null)
            {
                this.Close();
            }
        }
Beispiel #6
0
        public override void SetInitialLevel()
        {
            if (!SoulInitialized)
            {
                FieldInfo info = typeof(StatsReportUtility).GetField("cachedDrawEntries", BindingFlags.NonPublic | BindingFlags.Static);
                if (info != null)
                {
                    List <StatDrawEntry> entries = info.GetValue(this.pawn) as List <StatDrawEntry>;
                    if (!entries.NullOrEmpty())
                    {
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Patron", this.Patron.ToString(), 3));
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "CulturalToleranceStat".Translate(), this.Patron.ToString(), 2));
                        entries.Add(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "PurityOfSoulStat".Translate(), this.CurLevel.ToString(), 1));
                    }
                }

                //           try
                //           {
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Berserker);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_WarpBolt);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Temptation);
                //               AddPsykerPower(PsykerPowerDefOf.PsykerPower_Purgatus);
                //           }
                //           catch
                //           { }

                InitiatePsykerComp();

                ChaosFollowerPawnKindDef pdef = this.pawn.kindDef as ChaosFollowerPawnKindDef;
                //       Log.Message("Name is: " + this.pawn.Name.ToStringFull);
                if (pdef != null)
                {
                    if (pdef.UseFixedGender)
                    {
                        this.pawn.gender = pdef.FixedGender;
                    }
                    if (pdef.AfflictionProperty != null)
                    {
                        PawnAfflictionProps      = new AfflictionProperty();
                        this.PawnAfflictionProps = pdef.AfflictionProperty;
                        int pllow = (int)this.PawnAfflictionProps.LowerPsykerPowerLimit;
                        int plup  = (int)this.PawnAfflictionProps.UpperAfflictionLimit;
                        this.PsykerPowerLevel = (PsykerPowerLevel)Rand.RangeInclusive(pllow, plup);

                        if (PawnAfflictionProps.IsImmune)
                        {
                            this.curLevelInt   = 0.99f;
                            this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                            this.IsImmune      = true;
                        }
                        else if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                        {
                            this.IsImmune    = true;
                            this.curLevelInt = Rand.Range(0.86f, 0.99f);
                            this.NoPatron    = true;
                        }
                        else
                        {
                            float afup   = pdef.AfflictionProperty.UpperAfflictionLimit;
                            float afdown = pdef.AfflictionProperty.LowerAfflictionLimit;
                            this.curLevelInt = (Rand.Range(afup, afdown));
                        }
                        if (PawnAfflictionProps.UseOtherFaith)
                        {
                            this.patronInfo.PatronName = PawnAfflictionProps.IsofFaith.ToString();
                        }
                        this.CulturalTolerance = PawnAfflictionProps.PrimaryToleranceCategory;
                    }
                }
                else
                {
                    PawnAfflictionProps = new AfflictionProperty();
                    float pNum = Rand.GaussianAsymmetric(2.5f, 0.45f, 2);
                    if (pNum < 0)
                    {
                        pNum = 0;
                    }
                    else if (pNum > 7)
                    {
                        pNum = 7;
                    }
                    this.PsykerPowerLevel = (PsykerPowerLevel)pNum;

                    this.CulturalTolerance = (CulturalToleranceCategory)Rand.RangeInclusive(0, 2);
                    if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                    {
                        this.IsImmune    = true;
                        this.curLevelInt = Rand.Range(0.86f, 0.99f);
                        this.NoPatron    = true;
                    }
                    else
                    {
                        this.curLevelInt = Rand.Range(0.4f, 0.99f);
                    }
                }

                if (this.PawnAfflictionProps.CommmonPsykerPowers != null)
                {
                    for (int i = 0; i < this.PawnAfflictionProps.CommmonPsykerPowers.Count; i++)
                    {
                        try
                        {
                            this.compPsyker.psykerPowerManager.AddPsykerPower(this.PawnAfflictionProps.CommmonPsykerPowers[i]);
                        }
                        catch
                        { }
                    }
                }

                if (this.DevotionTrait == null)
                {
                    if ((PawnAfflictionProps != null && PawnAfflictionProps.IsImmune))
                    {
                        this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, PawnAfflictionProps.ImmuneDevotionDegree);
                        this.IsImmune      = true;
                    }
                    else
                    {
                        this.DevotionTrait = new SoulTrait(C_SoulTraitDefOf.Devotion, Rand.RangeInclusive(-2, 2));
                    }
                }
                if (PawnAfflictionProps.CommonSoulTrait != null)
                {
                    this.CommonSoulTrait = new SoulTrait(PawnAfflictionProps.CommonSoulTrait, 0);
                }

                if (this.curLevelInt < 0.3f && NoPatron == true)
                {
                    GainPatron(ChaosGods.Undivided, false);
                }
                if (NoPatron == false)
                {
                    if (curLevelInt > 0.3f)
                    {
                        curLevelInt = 0.3f;
                    }
                }
                if (this.PsykerPowerLevel == PsykerPowerLevel.Omega)
                {
                    this.IsImmune = true;
                }

                this.SoulInitialized = true;

                if (this.compPsyker.patronName != patronInfo.PatronName)
                {
                    this.compPsyker.patronName = patronInfo.PatronName;
                    PortraitsCache.SetDirty(this.pawn);
                }
            }
        }