Beispiel #1
0
        protected override void FillTab()
        {
            Rect rect = new Rect(0f, 0f, size.x, size.y).ContractedBy(17f);

            rect.yMin += 10f;

            PawnLvComp pawnLvComp = base.SelPawn.GetComp <PawnLvComp>();

            Text.Font = GameFont.Small;

            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect);

            listing_Standard.Label("PawnColumnWorker_Level_Tip_Desc".Translate() + " : " + pawnLvComp.level);
            listing_Standard.GapLine();
            listing_Standard.Label("StatsReport_STAT_STR".Translate() + " : " + pawnLvComp.STR);
            listing_Standard.Label("StatsReport_STAT_DEX".Translate() + " : " + pawnLvComp.DEX);
            listing_Standard.Label("StatsReport_STAT_AGL".Translate() + " : " + pawnLvComp.AGL);
            listing_Standard.Label("StatsReport_STAT_CON".Translate() + " : " + pawnLvComp.CON);
            listing_Standard.Label("StatsReport_STAT_INT".Translate() + " : " + pawnLvComp.INT);
            listing_Standard.Label("StatsReport_STAT_CHA".Translate() + " : " + pawnLvComp.CHA);

            listing_Standard.End();
        }
Beispiel #2
0
 public void DoStatUpButton(Rect rect, Pawn pawn)
 {
     TooltipHandler.TipRegion(rect, Translator.Translate("LvTab_Distribute"));
     if (Widgets.ButtonImage(rect, harmony_patches.DistributeIMG, Color.white, GenUI.SubtleMouseoverColor))
     {
         PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             if (Input.GetKey(KeyCode.LeftShift))
             {
                 pawnlvcomp.StatPoint += 10;
             }
             else if (Input.GetKey(KeyCode.LeftControl))
             {
                 pawnlvcomp.StatPoint += 100;
             }
             else if (Input.GetKey(KeyCode.LeftAlt))
             {
                 pawnlvcomp.StatPoint = 0;
             }
             else
             {
                 pawnlvcomp.StatPoint += 1;
             }
         }
     }
 }
Beispiel #3
0
        public static bool TakeDamagePrefix(Thing __instance, ref DamageInfo dinfo)
        {
            //Log.Message("TakeDamagePrefix");
            //if(dinfo.IntendedTarget != null)
            //    Log.Message(dinfo.IntendedTarget.def.defName);
            //if(dinfo.HitPart != null)
            //    Log.Message(dinfo.HitPart.def.defName);
            //Log.Message(dinfo.Amount.ToString());
            //if(dinfo.Height != null)
            //   Log.Message(dinfo.Height.ToString());
            //if (dinfo.Depth != null)
            //    Log.Message(dinfo.Depth.ToString());
            Pawn pawn = __instance as Pawn;

            if (pawn != null)
            {
                float oriAmount = dinfo.Amount;
                float ff        = oriAmount;
                //Log.Message(pawn.Name + " " + dinfo.Amount);
                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                if (pawnlvcomp != null)
                {
                    ff = oriAmount * ((float)Math.Max(1 - (0.003 * pawnlvcomp.CON), 0.5f));
                    dinfo.SetAmount(ff);
                    //Log.Message(pawn.Name + " " + dinfo.Amount);
                }
            }
            return(true);
        }
 public void DoStatRerollButton(Rect rect, Pawn pawn)
 {
     TooltipHandler.TipRegion(rect, Translator.Translate("LvTab_reroll"));
     if (Widgets.ButtonImage(rect, harmony_patches.LVUP_rerollIMG, Color.white, GenUI.SubtleMouseoverColor))
     {
         PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             pawnlvcomp.StatPoint = pawnlvcomp.level;
             if (FP_RSLUM_setting.FlatStartingStat)
             {
                 pawnlvcomp.STR = 0;
                 pawnlvcomp.DEX = 0;
                 pawnlvcomp.AGL = 0;
                 pawnlvcomp.CON = 0;
                 pawnlvcomp.INT = 0;
                 pawnlvcomp.CHA = 0;
             }
             else
             {
                 pawnlvcomp.STR = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                 pawnlvcomp.DEX = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                 pawnlvcomp.AGL = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                 pawnlvcomp.CON = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                 pawnlvcomp.INT = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                 pawnlvcomp.CHA = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
             }
         }
     }
 }
 public void DoStatUpButton(Rect rect, Pawn pawn)
 {
     TooltipHandler.TipRegion(rect, Translator.Translate("LvTab_Distribute"));
     if (Widgets.ButtonImage(rect, harmony_patches.DistributeIMG, Color.white, GenUI.SubtleMouseoverColor))
     {
         PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             if (Input.GetKey(KeyCode.LeftShift))
             {
                 pawnlvcomp.StatPoint += 10;
             }
             else if (Input.GetKey(KeyCode.LeftControl))
             {
                 pawnlvcomp.StatPoint += 100;
             }
             else if (Input.GetKey(KeyCode.LeftAlt))
             {
                 pawnlvcomp.StatPoint = 0;
             }
             else
             {
                 pawnlvcomp.StatPoint += 1;
             }
         }
         Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.RSLUM_LVUP, pawn, null);
         hediff.Severity = 0.1f;
         pawn.health.AddHediff(hediff, null, null, null);
     }
 }
Beispiel #6
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     if (req.HasThing)
     {
         Pawn       pawn       = req.Thing as Pawn;
         PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             val *= (float)Math.Max((1 - (0.003 * pawnlvcomp.DEX)), 0.5f);
         }
     }
 }
Beispiel #7
0
 public static void Notify_PawnKilledPostfix(Pawn killed, Pawn killer)
 {
     if (killer != null)
     {
         PawnLvComp pawnlvcomp = killer.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             pawnlvcomp.exp += (int)killed.kindDef.combatPower * FP_RSLUM_setting.KillExpMult;
             Log.Message((killed.kindDef.combatPower * FP_RSLUM_setting.KillExpMult).ToString());
         }
     }
 }
Beispiel #8
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     if (req.HasThing)
     {
         Pawn       pawn       = req.Thing as Pawn;
         PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             val *= (1.00f + (float)(0.01 * pawnlvcomp.CON));
         }
     }
 }
Beispiel #9
0
 public static void GetDamageFactorForPostFix(Tool tool, Pawn attacker, ref float __result)
 {
     //Verse.Log.Message(attacker.Name + " " + __result.ToString());
     if (attacker != null)
     {
         PawnLvComp pawnlvcomp = attacker.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             __result *= (float)(1.0f + (0.003 * pawnlvcomp.STR));
         }
     }
     //Verse.Log.Message(attacker.Name + " " + __result.ToString());
 }
Beispiel #10
0
        public static void AdjustedMeleeDamageAmountPostfix(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource, ref float __result)
        {
            PawnLvComp pawnlvcomp = attacker.TryGetComp <PawnLvComp>();

            Log.Message(__result.ToString());
            if (pawnlvcomp != null)
            {
                //Log.Message(__result.ToString() + "i");

                __result *= (float)(1.0f + (0.01 * pawnlvcomp.STR));
                //Log.Message(__result.ToString() + "in postfix");
            }
        }
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            Pawn       pawn       = diffSet.pawn;
            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();

            if (pawnlvcomp != null)
            {
                return((float)(1.00f + (0.01 * pawnlvcomp.DEX)));
            }
            else
            {
                return(1);
            }
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();

            if (pawnlvcomp != null)
            {
                if (pawnlvcomp.StatPoint > 0)
                {
                    this.DoStatUpButton(new Rect(rect.x, rect.yMin, 30f, 30f), pawn);
                    Rect   rect2   = new Rect(rect.x + 35, rect.y, rect.width - 35, Mathf.Min(rect.height, 30f));
                    String textFor = this.GetTextFor(pawn);
                    if (textFor != null)
                    {
                        Text.Font     = GameFont.Small;
                        Text.Anchor   = TextAnchor.MiddleLeft;
                        Text.WordWrap = false;
                        Widgets.Label(rect2, textFor);
                        Text.WordWrap = true;
                        Text.Anchor   = TextAnchor.UpperLeft;
                        String tip = this.GetTip(pawn);
                        if (!tip.NullOrEmpty())
                        {
                            TooltipHandler.TipRegion(rect2, tip);
                        }
                    }
                }
                else
                {
                    Vector2 topLeft = new Vector2(rect.x, rect.yMin);
                    statCheckbox(topLeft, ref pawnlvcomp.AGLauto, 30f, def.paintable, pawnlvcomp);
                    Rect   rect2   = new Rect(rect.x + 35, rect.y, rect.width - 35, Mathf.Min(rect.height, 30f));
                    String textFor = this.GetTextFor(pawn);
                    if (textFor != null)
                    {
                        Text.Font     = GameFont.Small;
                        Text.Anchor   = TextAnchor.MiddleLeft;
                        Text.WordWrap = false;
                        Widgets.Label(rect2, textFor);
                        Text.WordWrap = true;
                        Text.Anchor   = TextAnchor.UpperLeft;
                        String tip = this.GetTip(pawn);
                        if (!tip.NullOrEmpty())
                        {
                            TooltipHandler.TipRegion(rect2, tip);
                        }
                    }
                }
            }
        }
        //protected override AGLing GetTextFor(Pawn pawn)
        //    => Math.Round(pawn.ageTracker.AgeBiologicalYearsFloat, 2).ToAGLing("0.00");

        protected String GetTextFor(Pawn pawn)
        {
            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();

            if (pawnlvcomp != null)
            {
                return(pawnlvcomp.AGL.ToString());
            }
            else
            {
                // WHAT?
                Log.Message("error in PawnColumnWorker_Level GetTextFor. no pawnlvcomp.");
                return("err");
            }
        }
        protected string GetTextFor(Pawn pawn)
        {
            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();

            if (pawnlvcomp != null)
            {
                return(((int)(pawnlvcomp.exp / 100)).ToString());
            }
            else
            {
                // WHAT?
                Log.Message("error in PawnColumnWorker_EXP GetTextFor.");
                return("err");
            }
        }
Beispiel #15
0
        public static void GetMeleeDamagePostfix(StatRequest req, ref float __result)
        {
            Pawn pawn = req.Thing as Pawn;

            //Log.Message(__result.ToString());
            if (pawn != null)
            {
                //Log.Message(__result.ToString() + "i");
                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                if (pawnlvcomp != null)
                {
                    __result *= (float)(1.0f + (0.01 * pawnlvcomp.STR));
                }
                //Log.Message(__result.ToString() + "in postfix");
            }
        }
Beispiel #16
0
 public override string ExplanationPart(StatRequest req)
 {
     if (req.HasThing)
     {
         Pawn pawn = req.Thing as Pawn;
         if (pawn != null)
         {
             PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
             if (pawnlvcomp != null)
             {
                 return("StatsReport_STAT_CON".Translate() + ": x" + (1.00f + (float)(0.01 * pawnlvcomp.CON)).ToStringPercent());
             }
         }
     }
     return(null);
 }
Beispiel #17
0
 public static void Notify_PawnKilledPostfix(Pawn killed, Pawn killer)
 {
     if (killer != null)
     {
         PawnLvComp pawnlvcomp = killer.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             pawnlvcomp.exp += (int)killed.kindDef.combatPower * FP_RSLUM_setting.KillExpMult;
             //Log.Message((killed.kindDef.combatPower * FP_RSLUM_setting.KillExpMult).ToString());
             if ((pawnlvcomp.exp > pawnlvcomp.need_exp) && (pawnlvcomp.level < FP_RSLUM_setting.MaxLevel || FP_RSLUM_setting.MaxLevel == 0))
             {
                 pawnlvcomp.levelup();
             }
         }
     }
 }
Beispiel #18
0
 public override string ExplanationPart(StatRequest req)
 {
     if (req.HasThing)
     {
         Pawn pawn = req.Thing as Pawn;
         if (pawn != null)
         {
             PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
             if (pawnlvcomp != null)
             {
                 return("StatsReport_STAT_DEX".Translate() + ": x" + ((float)Math.Max((1 - (0.003 * pawnlvcomp.DEX)), 0.5f)).ToStringPercent());
             }
         }
     }
     return("");
 }
 public override string ExplanationPart(StatRequest req)
 {
     if (req.HasThing)
     {
         Pawn pawn = req.Thing as Pawn;
         if (pawn != null)
         {
             PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
             if (pawnlvcomp != null)
             {
                 return("StatsReport_STAT_CON".Translate() + ": -" + (0.3f * pawnlvcomp.CON).ToStringTemperature());
             }
         }
     }
     return("");
 }
Beispiel #20
0
        static bool LearnPrefix(SkillRecord __instance, float xp, bool direct)
        {
            if (xp > 0)
            {
                Pawn pawn = pawninfo.GetValue(__instance) as Pawn;

                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                if (pawnlvcomp != null)
                {
                    pawnlvcomp.exp += (int)(xp * FP_RSLUM_setting.ColonistPercent * (1f + (0.01 * pawnlvcomp.INT)));
                }

                //Log.Message(pawn.Name + xp.ToString() + " " + ((int)(xp * 100)).ToString());
            }

            return(true);
        }
        public override int Compare(Pawn a, Pawn b)
        //    => a.ageTracker.AgeBiologicalYearsFloat.CompareTo(b.ageTracker.AgeBiologicalYearsFloat);
        {
            PawnLvComp pawnlvcompa = a.TryGetComp <PawnLvComp>();
            PawnLvComp pawnlvcompb = b.TryGetComp <PawnLvComp>();

            if (pawnlvcompa != null && pawnlvcompb != null)
            {
                return(pawnlvcompa.AGL.CompareTo(pawnlvcompb.AGL));
            }
            else
            {
                // WHAT?
                Log.Message("error in PawnColumnWorker_Level Compare. no pawnlvcomp.");
                return(0);
            }
        }
Beispiel #22
0
 public static void Notify_PawnKilledPostfix(Pawn killed, Pawn killer)
 {
     if (killer != null)
     {
         PawnLvComp pawnlvcomp = killer.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             // hard-cap exp gain from monster...
             int temp = (int)Math.Min(killed.kindDef.combatPower, 1000) * FP_RSLUM_setting.KillExpMult;
             pawnlvcomp.exp += temp;
             //Log.Message((killed.kindDef.combatPower * FP_RSLUM_setting.KillExpMult).ToString());
             if (pawnlvcomp.need_exp < pawnlvcomp.exp)
             {
                 pawnlvcomp.levelup();
             }
         }
     }
 }
Beispiel #23
0
 public static void CapacityPostfix(Pawn p, ref float __result)
 {
     if (ModCompatibilityCheck.CombatExtendedIsActive || ModCompatibilityCheck.CarryCapacityFixIsActive)
     {
         return;
     }
     if (__result > 0)
     {
         //Pawn p = pawninfo2.GetValue(__instance) as Pawn;
         //Log.Message(p.Name + __result.ToString());
         PawnLvComp pawnlvcomp = p.TryGetComp <PawnLvComp>();
         if (pawnlvcomp != null)
         {
             __result *= (float)(1f + (0.01 * pawnlvcomp.STR));
         }
         //Log.Message(p.Name + __result.ToString());
     }
 }
Beispiel #24
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();

            if (DebugSettings.godMode && pawnlvcomp != null)
            {
                this.DoStatUpButton(new Rect(rect.x, rect.yMin, 30f, 30f), pawn);
                Rect   rect2   = new Rect(rect.x + 50, rect.y, rect.width - 50, Mathf.Min(rect.height, 30f));
                String textFor = this.GetTextFor(pawn);
                if (textFor != null)
                {
                    Text.Font     = GameFont.Small;
                    Text.Anchor   = TextAnchor.MiddleCenter;
                    Text.WordWrap = false;
                    Widgets.Label(rect2, textFor);
                    Text.WordWrap = true;
                    Text.Anchor   = TextAnchor.UpperLeft;
                    String tip = this.GetTip(pawn);
                    if (!tip.NullOrEmpty())
                    {
                        TooltipHandler.TipRegion(rect2, tip);
                    }
                }
            }
            else if (pawnlvcomp != null)
            {
                Rect   rect2   = new Rect(rect.x + 35, rect.y, rect.width - 50, Mathf.Min(rect.height, 30f));
                String textFor = this.GetTextFor(pawn);
                if (textFor != null)
                {
                    Text.Font     = GameFont.Small;
                    Text.Anchor   = TextAnchor.MiddleCenter;
                    Text.WordWrap = false;
                    Widgets.Label(rect2, textFor);
                    Text.WordWrap = true;
                    Text.Anchor   = TextAnchor.UpperLeft;
                    String tip = this.GetTip(pawn);
                    if (!tip.NullOrEmpty())
                    {
                        TooltipHandler.TipRegion(rect2, tip);
                    }
                }
            }
        }
        public void DoLVUPButton(Rect rect)
        {
            TooltipHandler.TipRegion(rect, Translator.Translate("LvTab_LVUPButtonDesc"));
            if (Widgets.ButtonText(rect, Translator.Translate("LvTab_LVUPButton")))
            {
                IEnumerable <Pawn> Pawns = from p in Find.CurrentMap.mapPawns.AllPawnsSpawned
                                           select p;
                foreach (Pawn pawn in Pawns)
                {
                    PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                    if (pawnlvcomp != null)
                    {
                        pawnlvcomp.levelup();
                    }
                }

                Notify_ResolutionChanged();
            }
        }
Beispiel #26
0
        public static bool PreApplyDamagePrefix(ref DamageInfo dinfo, out bool absorbed)
        {
            absorbed = false;
            Pawn pawn = dinfo.IntendedTarget as Pawn;

            if (pawn != null)
            {
                float oriAmount = dinfo.Amount;
                float ff        = oriAmount;
                //Log.Message(pawn.Name + " " + dinfo.Amount);
                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                if (pawnlvcomp != null)
                {
                    ff = oriAmount * ((float)Math.Max(1 - (0.003 * pawnlvcomp.CON), 0.5f));
                }
                dinfo.SetAmount(ff);
                //Log.Message(pawn.Name + " " + dinfo.Amount);
            }
            return(true);
        }
Beispiel #27
0
        public void DoStatUpButton(Rect rect, Pawn pawn)
        {
            TooltipHandler.TipRegion(rect, Translator.Translate("LvTab_Distribute"));
            if (Widgets.ButtonImage(rect, harmony_patches.DistributeIMG, Color.white, GenUI.SubtleMouseoverColor))
            {
                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                if (pawnlvcomp != null)
                {
                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            if (pawnlvcomp.StatPoint > 0)
                            {
                                pawnlvcomp.StatPoint -= 1;
                                pawnlvcomp.CHA       += 1;
                            }
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftControl))
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            if (pawnlvcomp.StatPoint > 0)
                            {
                                pawnlvcomp.StatPoint -= 1;
                                pawnlvcomp.CHA       += 1;
                            }
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftAlt))
                    {
                        if (Input.GetKey(KeyCode.LeftShift))
                        {
                            int tempv = Math.Min(pawnlvcomp.CHA - FP_RSLUM_setting.Startingstat_min, 10);

                            if (pawnlvcomp.CHA > FP_RSLUM_setting.Startingstat_min)
                            {
                                pawnlvcomp.StatPoint += tempv;
                                pawnlvcomp.CHA       -= tempv;
                            }
                        }
                        else if (Input.GetKey(KeyCode.LeftControl))
                        {
                            int tempv = Math.Min(pawnlvcomp.CHA - FP_RSLUM_setting.Startingstat_min, 100);

                            if (pawnlvcomp.CHA > FP_RSLUM_setting.Startingstat_min)
                            {
                                pawnlvcomp.StatPoint += tempv;
                                pawnlvcomp.CHA       -= tempv;
                            }
                        }
                        else
                        {
                            if (pawnlvcomp.CHA > FP_RSLUM_setting.Startingstat_min)
                            {
                                pawnlvcomp.StatPoint += 1;
                                pawnlvcomp.CHA       -= 1;
                            }
                        }
                    }
                    else
                    {
                        if (pawnlvcomp.StatPoint > 0)
                        {
                            pawnlvcomp.StatPoint -= 1;
                            pawnlvcomp.CHA       += 1;
                        }
                    }
                }
            }
        }
Beispiel #28
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);
            if (this.level == -1)
            {
                if (FP_RSLUM_setting.FlatStartingStat)
                {
                    this.level = 0;
                    STR        = 0;
                    DEX        = 0;
                    AGL        = 0;
                    CON        = 0;
                    INT        = 0;
                    CHA        = 0;
                }
                else
                {
                    this.level += 1;
                    STR         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    DEX         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    AGL         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    CON         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    INT         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    CHA         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                }

                if (FP_RSLUM_setting.FP_RSLUM_LvAv == -1 && FP_RSLUM_setting.LevelScaling != 0 && Find.World != null)
                {
                    int templv               = 0;
                    int tempcount            = 0;
                    IEnumerable <Pawn> Pawns = from p in Find.World.worldPawns.AllPawnsAlive
                                               where p.IsColonist && (p.Faction == Faction.OfPlayer)
                                               select p;

                    if (Pawns.Count() != 0)
                    {
                        foreach (Pawn pawn in Pawns)
                        {
                            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                            if (pawnlvcomp != null)
                            {
                                templv += pawnlvcomp.level;
                                tempcount++;
                            }
                        }
                        FP_RSLUM_setting.FP_RSLUM_LvAv = (templv / tempcount) * FP_RSLUM_setting.LevelScaling / 100;
                    }
                    else
                    {
                        FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                    }
                }
                else
                {
                    FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                }


                if (FP_RSLUM_setting.FP_RSLUM_LvAv > 0)
                {
                    this.level = FP_RSLUM_setting.FP_RSLUM_LvAv;

                    int tempstat = FP_RSLUM_setting.FP_RSLUM_LvAv;

                    while (true)
                    {
                        this.STR += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.DEX += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.AGL += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.CON += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.INT += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.CHA += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                    }
                }
            }
        }
        public void statCheckbox(Vector2 topLeft, ref bool checkOn, float size, bool paintable, PawnLvComp pawnlvcomp)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, size, size);

            GUI.DrawTexture(image: (!checkOn) ? (CheckboxOffTex) : (CheckboxOnTex), position: new Rect(topLeft.x, topLeft.y, size, size));
            DraggableResult draggableResult = ButtonInvisibleDraggable(rect);

            MouseoverSounds.DoRegion(rect);
            bool flag = false;

            if (draggableResult == DraggableResult.Pressed)
            {
                checkOn = !checkOn;
                flag    = true;
                //pawnlvcomp.AGLauto = false;
                pawnlvcomp.CHAauto = false;
                pawnlvcomp.CONauto = false;
                pawnlvcomp.DEXauto = false;
                pawnlvcomp.INTauto = false;
                pawnlvcomp.STRauto = false;
            }
            if (flag)
            {
                if (checkOn)
                {
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera();
                }
                else
                {
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera();
                }
            }
        }
Beispiel #30
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            int tempcount = 0;

            base.PostSpawnSetup(respawningAfterLoad);
            if (this.level == -1)
            {
                if (FP_RSLUM_setting.FlatStartingStat)
                {
                    this.level = 0;
                    STR        = 0;
                    DEX        = 0;
                    AGL        = 0;
                    CON        = 0;
                    INT        = 0;
                    CHA        = 0;
                }
                else
                {
                    this.level += 1;
                    STR         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    DEX         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    AGL         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    CON         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    INT         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                    CHA         = Rand.Range(FP_RSLUM_setting.Startingstat_min, FP_RSLUM_setting.Startingstat_max);
                }

                //if (FP_RSLUM_setting.FP_RSLUM_LvAv == -1 && FP_RSLUM_setting.LevelScaling != 0 && Find.World != null)

                if (FP_RSLUM_setting.LevelScaling == 0)
                {
                    FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                }
                if (FP_RSLUM_setting.FP_RSLUM_LvAv == -1)
                {
                    // old style. Some mod touch Find.World and Crashes occur...
                    if (Find.World != null)
                    {
                        //Verse.Log.Message("old style - g", false);
                        int templv = 0;
                        IEnumerable <Pawn> Pawns = from p in Find.World.worldPawns.AllPawnsAlive
                                                   where p.IsColonist && (p.Faction == Faction.OfPlayer)
                                                   select p;

                        if (Pawns.Count() != 0)
                        {
                            foreach (Pawn pawn in Pawns)
                            {
                                PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                                if (pawnlvcomp != null)
                                {
                                    templv += pawnlvcomp.level;
                                    tempcount++;
                                }
                            }
                            if (tempcount == 0)
                            {
                                FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                            }
                            else
                            {
                                FP_RSLUM_setting.FP_RSLUM_LvAv = (templv / tempcount) * FP_RSLUM_setting.LevelScaling / 100;
                            }
                        }
                        else
                        {
                            FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                        }
                    }
                    // new style.
                    else if (PawnsFinder.AllMaps_FreeColonistsSpawned != null)
                    {
                        //Verse.Log.Message("new style - g", false);
                        int templv = 0;

                        List <Pawn> pawns = new List <Pawn>();

                        foreach (Pawn pawn in PawnsFinder.AllMaps_FreeColonistsSpawned)
                        {
                            PawnLvComp pawnlvcomp = pawn.TryGetComp <PawnLvComp>();
                            if (pawnlvcomp != null)
                            {
                                templv += pawnlvcomp.level;
                                tempcount++;
                            }
                        }

                        if (tempcount == 0)
                        {
                            FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                        }
                        else
                        {
                            FP_RSLUM_setting.FP_RSLUM_LvAv = (templv / tempcount) * FP_RSLUM_setting.LevelScaling / 100;
                        }


                        //Verse.Log.Message(String.Format("LvAv {} , count {}", FP_RSLUM_setting.FP_RSLUM_LvAv, tempcount), false);
                    }
                    else
                    {
                        // Verse.Log.Message("new, old both failed", false);
                        FP_RSLUM_setting.FP_RSLUM_LvAv = 0;
                    }
                }

                if (this.level > 0)
                {
                    //Verse.Log.Message("level up!!" + FP_RSLUM_setting.FP_RSLUM_LvAv, false);
                    this.level = FP_RSLUM_setting.FP_RSLUM_LvAv;

                    int tempstat = FP_RSLUM_setting.FP_RSLUM_LvAv;

                    while (true)
                    {
                        this.STR += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.DEX += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.AGL += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.CON += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.INT += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                        this.CHA += FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex];
                        tempstat -= FP_RSLUM_setting.thisispi[FP_RSLUM_setting.piindex++];
                        if (FP_RSLUM_setting.piindex == 1000)
                        {
                            FP_RSLUM_setting.piindex = 0;
                        }
                        if (tempstat <= 0)
                        {
                            break;
                        }
                    }
                }
            }
        }