GetMeatInCorpses() public method

public GetMeatInCorpses ( ) : int
return int
Ejemplo n.º 1
0
        public float DrawThresholdSettings(Vector2 pos, float width)
        {
            var start = pos;

            // target count (1)
            int currentCount    = _selected.Trigger.CurrentCount;
            int corpseCount     = _selected.GetMeatInCorpses();
            int designatedCount = _selected.GetMeatInDesignations();
            int targetCount     = _selected.Trigger.TargetCount;

            _selected.Trigger.DrawTriggerConfig(ref pos, width, ListEntryHeight,
                                                "FMH.TargetCount".Translate(currentCount, corpseCount, designatedCount,
                                                                            targetCount),
                                                "FMH.TargetCountTooltip".Translate(currentCount, corpseCount,
                                                                                   designatedCount, targetCount));

            // allow human & insect meat (2)
            Utilities.DrawToggle(ref pos, width, "FM.PathBasedDistance".Translate(),
                                 "FM.PathBasedDistance.Tip".Translate(), ref _selected.PathBasedDistance, true);
            Utilities.DrawReachabilityToggle(ref pos, width, ref _selected.CheckReachable);
            Utilities.DrawToggle(ref pos, width, "FMH.AllowHumanMeat".Translate(), "FMH.AllowHumanMeat.Tip".Translate(),
                                 _selected.Trigger.ThresholdFilter.Allows(Utilities_Hunting.HumanMeat),
                                 () => _selected.AllowHumanLikeMeat = true,
                                 () => _selected.AllowHumanLikeMeat = false);
            Utilities.DrawToggle(ref pos, width, "FMH.AllowInsectMeat".Translate(), "FMH.AllowInsectMeat.Tip".Translate(),
                                 _selected.Trigger.ThresholdFilter.Allows(Utilities_Hunting.InsectMeat),
                                 () => _selected.AllowInsectMeat = true,
                                 () => _selected.AllowInsectMeat = false);

            return(pos.y - start.y);
        }
        public void DoContent(Rect rect)
        {
            // layout: settings | animals
            // draw background
            Widgets.DrawMenuSection(rect);

            // some variables
            float width         = rect.width;
            float height        = rect.height - _topAreaHeight - _button.y - _margin;
            var   cols          = 2;
            float colWidth      = width / cols - _margin;
            var   colRects      = new List <Rect>();
            var   colTitleRects = new List <Rect>();
            var   buttonRect    = new Rect(rect.width - _button.x, rect.height - _button.y, _button.x - _margin,
                                           _button.y - _margin);

            // set up rects
            for (var j = 0; j < cols; j++)
            {
                colRects.Add(new Rect(j * colWidth + j * _margin + _margin / 2, _topAreaHeight, colWidth, height));
                colTitleRects.Add(new Rect(j * colWidth + j * _margin + _margin / 2, 0f, colWidth, _topAreaHeight));
            }

            // keep track of location
            Vector2 cur = Vector2.zero;

            // begin window
            GUI.BeginGroup(rect);

            // settings.
            Utilities.Label(colTitleRects[0], "FMH.Options".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny);

            GUI.DrawTexture(colRects[0], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[0]);

            // target count (1)
            int currentCount    = _selected.Trigger.CurCount;
            int corpseCount     = _selected.GetMeatInCorpses();
            int designatedCount = _selected.GetMeatInDesignations();
            int targetCount     = _selected.Trigger.Count;

            _selected.Trigger.DrawTriggerConfig(ref cur, colWidth, _entryHeight, true,
                                                "FMH.TargetCount".Translate(currentCount, corpseCount, designatedCount,
                                                                            targetCount),
                                                "FMH.TargetCountTooltip".Translate(currentCount, corpseCount,
                                                                                   designatedCount, targetCount));

            // allow human meat (2)
            var humanMeatRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Utilities.DrawToggle(humanMeatRect, "FMH.AllowHumanMeat".Translate(),
                                 _selected.Trigger.ThresholdFilter.Allows(Utilities_Hunting.HumanMeat),
                                 delegate
                                 { _selected.AllowHumanLikeMeat(true); },
                                 delegate
                                 { _selected.AllowHumanLikeMeat(false); });
            cur.y += _entryHeight;

            // unforbid corpses (3)
            var ufCorpseRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Widgets.DrawAltRect(ufCorpseRect);
            Utilities.DrawToggle(ufCorpseRect, "FMH.UnforbidCorpses".Translate(), ref _selected.UnforbidCorpses);
            cur.y += _entryHeight;

            // hunting grounds (4)
            var huntingGroundsTitleRect = new Rect(cur.x, cur.y, colWidth - 2 * _margin, _entryHeight);

            Utilities.Label(huntingGroundsTitleRect, "FMH.HuntingGrounds".Translate(), anchor: TextAnchor.MiddleLeft,
                            lrMargin: _margin);
            cur.y += _entryHeight;

            var huntingGroundsRect = new Rect(cur.x + _margin, cur.y, colWidth - 2 * _margin, _entryHeight);

            AreaAllowedGUI.DoAllowedAreaSelectors(huntingGroundsRect, ref _selected.HuntingGrounds, manager,
                                                  AllowedAreaMode.Humanlike);
            cur.y += _entryHeight;

            GUI.EndGroup();

            // animals.
            Utilities.Label(colTitleRects[1], "FMH.Animals".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny);

            GUI.DrawTexture(colRects[1], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[1]);
            cur = Vector2.zero;

            Rect outRect  = colRects[1].AtZero().ContractedBy(1f);
            var  viewRect = new Rect(0f, 0f, outRect.width, _selected.AllowedAnimals.Count * _entryHeight);

            if (viewRect.height > outRect.height)
            {
                viewRect.width -= 16f;
            }

            // start scrolling view
            Widgets.BeginScrollView(outRect, ref _animalsScrollPosition, viewRect);

            // list of keys in allowed animals list (all animals in biome, static)
            var PawnKinds = new List <PawnKindDef>(_selected.AllowedAnimals.Keys);

            // toggle all
            var toggleAllRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Widgets.DrawAltRect(toggleAllRect);
            Dictionary <PawnKindDef, bool> .ValueCollection test = _selected.AllowedAnimals.Values;
            Utilities.DrawToggle(toggleAllRect, "<i>" + "FM.All".Translate() + "</i>",
                                 _selected.AllowedAnimals.Values.All(v => v), delegate
            {
                foreach (
                    PawnKindDef def in
                    PawnKinds)
                {
                    _selected.AllowedAnimals[
                        def
                    ] = true;
                }
            }, delegate
            {
                foreach (
                    PawnKindDef def in
                    PawnKinds)
                {
                    _selected
                    .AllowedAnimals[
                        def
                    ] = false;
                }
            });

            cur.y += _entryHeight;

            // toggle for each animal
            var i = 1;

            foreach (PawnKindDef kind in PawnKinds)
            {
                var toggleRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

                // highlight alternate rows
                if (i++ % 2 == 0)
                {
                    Widgets.DrawAltRect(toggleRect);
                }

                // draw the toggle
                Utilities.DrawToggle(toggleRect, kind.LabelCap, _selected.AllowedAnimals[kind],
                                     delegate
                                     { _selected.AllowedAnimals[kind] = !_selected.AllowedAnimals[kind]; });

                // update current position
                cur.y += _entryHeight;
            }

            // close scrolling view
            Widgets.EndScrollView();

            // close animal list
            GUI.EndGroup();

            // do the button
            if (!_selected.Managed)
            {
                if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate()))
                {
                    // activate job, add it to the stack
                    _selected.Managed = true;
                    Manager.For(manager).JobStack.Add(_selected);

                    // refresh source list
                    Refresh();
                }
            }
            else
            {
                if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate()))
                {
                    // inactivate job, remove from the stack.
                    Manager.For(manager).JobStack.Delete(_selected);

                    // remove content from UI
                    _selected = null;

                    // refresh source list
                    Refresh();
                }
            }

            // close window
            GUI.EndGroup();
        }