Exemple #1
0
        public float GetStatValue(Apparel apparel, Saveable_StatDef stat)
        {
            float baseStat    = apparel.GetStatValue(stat.statDef, true);
            float currentStat = baseStat;

            currentStat += apparel.def.equippedStatOffsets.GetStatOffsetFromList(stat.statDef);

            PawnCalcForApparel.DoApparelScoreRawStatsHandlers(pawn, apparel, stat.statDef, ref currentStat);

            if (baseStat == 0)
            {
                return(currentStat);
            }
            else
            {
                return(currentStat / baseStat);
            }
        }
        public static void DoStatsInput(Rect rect, ref Vector2 scrollPosition, List<Saveable_StatDef> stats)
        {
            Widgets.DrawMenuSection(rect, true);
            Text.Font = GameFont.Tiny;
            float num = rect.width - 2f;
            Rect rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);
            if (Widgets.TextButton(rect2, "ClearAll".Translate(), true, false))
            {
                MapComponent_AutoEquip.Get.nextOptimization = 0;
                stats.Clear();
            }

            rect.yMin = rect2.yMax;
            rect2 = new Rect(rect.x + 5f, rect.y + 1f, rect.width - 2f - 16f - 8f, 20f);

            Text.Font = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect2, "-100%");

            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(rect2, "0%");

            Text.Anchor = TextAnchor.UpperRight;
            Widgets.Label(rect2, "100%");

            rect.yMin = rect2.yMax;
            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            Rect position = new Rect(rect2.xMin + rect2.width / 2, rect.yMin + 5f, 1f, rect.height - 10f);
            GUI.DrawTexture(position, BaseContent.GreyTex);

            StatDef[] allStatDefs = DefDatabase<StatDef>.AllDefs
                .Where(i =>
                    (i.category.defName == "Apparel") ||
                    (i.category.defName == "PawnCombat") ||
                    (i.category.defName == "BasicsPawn") ||
                    (i.category.defName == "PawnSocial") ||
                    (i.category.defName == "PawnWork") ||
                    (i.category.defName == "Weapon") ||
                    (i.category.defName == "StuffStatFactors"))
                .ToArray();

            rect = rect.ContractedBy(2);
            Rect viewRect = new Rect(rect.xMin, rect.yMin, rect.width - 16f, allStatDefs.Length * Text.LineHeight * 1.2f + stats.Count * 40);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);

            foreach (StatDef stat in allStatDefs)
            {
                Rect itemRect = new Rect(viewRect.xMin, viewRect.yMin, viewRect.width, Text.LineHeight * 1.2f);
                if (Mouse.IsOver(itemRect))
                {
                    GUI.color = ITab_Pawn_AutoEquip.HighlightColor;
                    GUI.DrawTexture(itemRect, TexUI.HighlightTex);
                    GUI.color = Color.white;
                }

                TooltipHandler.TipRegion(itemRect, stat.description);

                Saveable_StatDef outfitStat = stats.FirstOrDefault(i => i.statDef == stat);
                bool active = outfitStat != null;
                Widgets.LabelCheckbox(itemRect, stat.LabelCap, ref active);

                viewRect.yMin += itemRect.height;

                if (active)
                {
                    if (outfitStat == null)
                    {
                        outfitStat = new Saveable_StatDef();
                        outfitStat.statDef = stat;
                        outfitStat.strength = 0;
                    }
                    if (!stats.Contains(outfitStat))
                    {
                        stats.Add(outfitStat);
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                    }

                    itemRect = new Rect(viewRect.xMin, viewRect.yMin, viewRect.width, 30f);
                    GUI.skin.horizontalSlider.alignment = TextAnchor.MiddleCenter;
                    float n = GUI.HorizontalSlider(itemRect, outfitStat.strength, -1f, 1f);
                    viewRect.yMin += 40f;

                    if (n != outfitStat.strength)
                    {
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                        outfitStat.strength = n;
                    }
                }
                else
                {
                    if (stats.Contains(outfitStat))
                    {
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                        stats.Remove(outfitStat);
                    }
                    outfitStat = null;
                }
            }

            Widgets.EndScrollView();
        }
        public static void DoStatsInput(Rect rect, ref Vector2 scrollPosition, List <Saveable_StatDef> stats)
        {
            Widgets.DrawMenuSection(rect, true);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);

            if (Widgets.TextButton(rect2, "ClearAll".Translate(), true, false))
            {
                MapComponent_AutoEquip.Get.nextOptimization = 0;
                stats.Clear();
            }

            rect.yMin = rect2.yMax;
            rect2     = new Rect(rect.x + 5f, rect.y + 1f, rect.width - 2f - 16f - 8f, 20f);

            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect2, "-100%");

            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(rect2, "0%");

            Text.Anchor = TextAnchor.UpperRight;
            Widgets.Label(rect2, "100%");

            rect.yMin   = rect2.yMax;
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            Rect position = new Rect(rect2.xMin + rect2.width / 2, rect.yMin + 5f, 1f, rect.height - 10f);

            GUI.DrawTexture(position, BaseContent.GreyTex);

            StatDef[] allStatDefs = DefDatabase <StatDef> .AllDefs
                                    .Where(i =>
                                           (i.category.defName == "Apparel") ||
                                           (i.category.defName == "PawnCombat") ||
                                           (i.category.defName == "BasicsPawn") ||
                                           (i.category.defName == "PawnSocial") ||
                                           (i.category.defName == "PawnWork") ||
                                           (i.category.defName == "Weapon") ||
                                           (i.category.defName == "StuffStatFactors"))
                                    .ToArray();

            rect = rect.ContractedBy(2);
            Rect viewRect = new Rect(rect.xMin, rect.yMin, rect.width - 16f, allStatDefs.Length * Text.LineHeight * 1.2f + stats.Count * 40);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);

            foreach (StatDef stat in allStatDefs)
            {
                Rect itemRect = new Rect(viewRect.xMin, viewRect.yMin, viewRect.width, Text.LineHeight * 1.2f);
                if (Mouse.IsOver(itemRect))
                {
                    GUI.color = ITab_Pawn_AutoEquip.HighlightColor;
                    GUI.DrawTexture(itemRect, TexUI.HighlightTex);
                    GUI.color = Color.white;
                }

                TooltipHandler.TipRegion(itemRect, stat.description);

                Saveable_StatDef outfitStat = stats.FirstOrDefault(i => i.statDef == stat);
                bool             active     = outfitStat != null;
                Widgets.LabelCheckbox(itemRect, stat.LabelCap, ref active);

                viewRect.yMin += itemRect.height;

                if (active)
                {
                    if (outfitStat == null)
                    {
                        outfitStat          = new Saveable_StatDef();
                        outfitStat.statDef  = stat;
                        outfitStat.strength = 0;
                    }
                    if (!stats.Contains(outfitStat))
                    {
                        stats.Add(outfitStat);
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                    }

                    itemRect = new Rect(viewRect.xMin, viewRect.yMin, viewRect.width, 30f);
                    GUI.skin.horizontalSlider.alignment = TextAnchor.MiddleCenter;
                    float n = GUI.HorizontalSlider(itemRect, outfitStat.strength, -1f, 1f);
                    viewRect.yMin += 40f;

                    if (n != outfitStat.strength)
                    {
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                        outfitStat.strength = n;
                    }
                }
                else
                {
                    if (stats.Contains(outfitStat))
                    {
                        MapComponent_AutoEquip.Get.nextOptimization = 0;
                        stats.Remove(outfitStat);
                    }
                    outfitStat = null;
                }
            }

            Widgets.EndScrollView();
        }
        public float GetStatValue(Apparel apparel, Saveable_StatDef stat)
        {
            float baseStat = apparel.GetStatValue(stat.statDef, true);
            float currentStat = baseStat;
            currentStat += apparel.def.equippedStatOffsets.GetStatOffsetFromList(stat.statDef);

            PawnCalcForApparel.DoApparelScoreRawStatsHandlers(pawn, apparel, stat.statDef, ref currentStat);

            if (baseStat == 0)
                return currentStat;
            else
                return currentStat / baseStat;
        }