コード例 #1
0
ファイル: Utility.cs プロジェクト: ALEXALIGHT/newcode
        public static void DrawMilkBars(this Pawn pawn, Rect rect)
        {
            //List<ThingComp> milkcomp = pawn.AllComps.FindAll(x => x is CompMilkable || x.GetType().ToString().ToLower().Contains("milkable"));
            ThingComp milkcomp = null;
            float     res      = 0;

            if (VariousDefOf.Hediff_Heavy_Lactating_Permanent != null)
            {
                if (pawn.health.hediffSet.HasHediff(VariousDefOf.Hediff_Heavy_Lactating_Permanent))
                {
                    milkcomp = pawn.AllComps.FirstOrDefault(x => x.GetType().ToString().ToLower().Contains("hypermilkable"));
                }
                else
                {
                    milkcomp = pawn.AllComps.FirstOrDefault(x => x.GetType().ToString().ToLower().Contains("milkable"));
                }
            }
            else
            {
                milkcomp = pawn.GetComp <CompMilkable>();
            }

            if (milkcomp != null)
            {
                if (milkcomp is CompMilkable)
                {
                    bool active = (bool)milkcomp.GetPropertyValue("Active");
                    if (active)
                    {
                        CompMilkable m = (CompMilkable)milkcomp;
                        res = Math.Max(m.Fullness, res);
                        Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.milkTexture, Texture2D.blackTexture, true);
                        DrawMilkBottle(rect, pawn, VariousDefOf.Job_LactateSelf, m.Fullness);
                    }
                }
                else
                {
                    bool active = (bool)milkcomp.GetPropertyValue("Active");
                    if (active)
                    {
                        float fullness = (float)milkcomp.GetMemberValue("fullness");
                        res = Math.Max(fullness, res);
                        Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.milkTexture, Texture2D.blackTexture, true);
                        DrawMilkBottle(rect, pawn, VariousDefOf.Job_LactateSelf_MC, fullness);
                    }
                }
            }
        }