Exemplo n.º 1
0
 public void ClearFilter()
 {
     thingFilter = new ThingFilter();
     thingFilter.AllowedQualityLevels     = new QualityRange(QualityCategory.Normal, QualityCategory.Legendary);
     thingFilter.AllowedHitPointsPercents = new FloatRange(0.8f, 1);
     thingFilter.SetDisallowAll(null, null);
 }
        public void SetDefaultFilter(Bill_Production bill)
        {
            var thingDef = bill.recipe.products.First().thingDef;

            OutputFilter.SetDisallowAll();
            OutputFilter.SetAllow(thingDef, true);
        }
 public Trigger_Threshold(ManagerJob_Foraging job) : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     TargetCount       = DefaultCount;
     ThresholdFilter   = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
 }
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, string filterText = null)
        {
            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))
            {
                filter.SetDisallowAll();
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f);
            if (Widgets.TextButton(rect3, "AllowAll".Translate(), true, false))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, HelperThingFilterUI.viewHeight);
            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 0f;
            num2 += 2f;
            HelperThingFilterUI.DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            HelperThingFilterUI.DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            float num3 = num2;
            Rect rect4 = new Rect(0f, num2, 9999f, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter, 210f, true);
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;
            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            if (filterText != null && filterText.Length > 2)
            {
                var rootNode = new TreeNode_ThingCategory(new ThingCategoryDef());

                node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower()));

                foreach (ThingDef currentThing in node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower())))
                {
                    rootNode.catDef.childThingDefs.Add(currentThing);
                }

                node = rootNode;
            }

            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                HelperThingFilterUI.viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
 public Trigger_Threshold(ManagerJob_Forestry job) : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     TargetCount       = DefaultCount;
     ThresholdFilter   = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow(ThingDefOf.WoodLog, true);
 }
        public static ThingFilter DefaultFilter_MedZone()
        {
            ThingFilter filter = new ThingFilter();

            filter.SetDisallowAll();

            filter.SetAllow(ThingCategoryDefOf.Medicine, true);
            return(filter);
        }
 public Trigger_Threshold( ManagerJob_Hunting job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true );
 }
 public Trigger_Threshold( ManagerJob_Forestry job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Forestry.Wood, true );
 }
Exemplo n.º 9
0
        public static ThingFilter DefaultFilter_MedZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            filter.SetAllow(ThingCategoryDefOf.Medicine, true);
            return(filter);
        }
Exemplo n.º 10
0
 public TriggerThreshold(ManagerJobProduction job)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = job.MainProduct.MaxUpperThreshold;
     Count = MaxUpperThreshold / 5;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     if (job.MainProduct.ThingDef != null) ThresholdFilter.SetAllow(job.MainProduct.ThingDef, true);
     if (job.MainProduct.CategoryDef != null) ThresholdFilter.SetAllow(job.MainProduct.CategoryDef, true);
 }
Exemplo n.º 11
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ref ThingFilter filter, ThingFilter parentFilter = null, ThingFilter defaultFilter = null, int openMask = 1)
        {
            Widgets.DrawMenuSection(rect);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, buttonHeight);

            if (Widgets.ButtonText(rect2, "ClearAll".Translate(), true, false, true))
            {
                filter.SetDisallowAll(null, null);
                SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), buttonHeight);

            if (Widgets.ButtonText(rect3, "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(parentFilter);
                SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                node = parentFilter.DisplayRootCategory;
            }
            Rect viewRect   = new Rect(0f, 0f, rect.width - 17f, viewHeight);
            Rect scrollrect = new Rect(rect.x, rect.y, rect.width - 1f, rect.height - buttonHeight - 1f);

            Widgets.BeginScrollView(scrollrect, ref scrollPosition, viewRect, true);
            float num2  = 2f;
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, viewRect.width, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, null, null, null);

            listing_TreeThingFilter.Begin(rect4);
            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, null, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
            Rect buttonRect = new Rect(rect.x + 1f, rect.y + 1f, num, buttonHeight);

            buttonRect.height   = 24f;
            buttonRect.position = new Vector2(buttonRect.position.x, rect.yMax - buttonHeight - 1f);
            bool clicked = Widgets.ButtonText(buttonRect, "Reset");

            if (clicked && defaultFilter != null)
            {
                filter = defaultFilter;
            }
        }
        public static ThingFilter DefaultFilter_AnimalZone()
        {
            ThingFilter filter = new ThingFilter();

            filter.SetDisallowAll();

            filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, true);
            filter.SetAllow(ThingCategoryDefOf.CorpsesInsect, false);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowRotten"), false);
            return(filter);
        }
        public Trigger_Threshold(ManagerJob_Hunting job) : base(job.manager)
        {
            Op = Ops.LowerThan;
            MaxUpperThreshold = DefaultMaxUpperThreshold;
            TargetCount       = DefaultCount;
            ThresholdFilter   = new ThingFilter();
            ThresholdFilter.SetDisallowAll();

            // limit selection to food only.
            ParentFilter = new ThingFilter();
            ParentFilter.SetDisallowAll();
            ParentFilter.SetAllow(Utilities_Hunting.FoodRaw, true);
        }
Exemplo n.º 14
0
        public static ThingFilter DefaultFilter_OutdoorZone()
        {
            var filter = new ThingFilter();

            filter.SetDisallowAll(null, DefDatabase <SpecialThingFilterDef> .AllDefs);

            DefDatabase <ThingDef> .AllDefs
            .Where(d => !d.HasComp(typeof(CompRottable)))
            .Where(d => d.GetStatValueAbstract(StatDefOf.DeteriorationRate) == 0f)
            .ToList()
            .ForEach(d => filter.SetAllow(d, true));

            return(filter);
        }
Exemplo n.º 15
0
        public static ThingFilter ClearFilter(RecipeDef recipe, int count)
        {
            IngredientCount ic = new IngredientCount();

            ic.SetBaseCount(count);
            recipe.ingredients.Clear();
            recipe.ingredients.Add(ic);
            ThingFilter filter = ic.filter;

            recipe.defaultIngredientFilter = filter;
            filter.SetDisallowAll(null, null);
            recipe.fixedIngredientFilter = filter;
            return(filter);
        }
        public static ThingFilter DefaultFilter_JoyZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            for (int t = 0; t < database.Count; t++)
            {
                if (database[t].IsIngestible && database[t].ingestible.joyKind != null && database[t].ingestible.joy > 0)
                {
                    filter.SetAllow(database[t], true);
                }
            }
            return(filter);
        }
Exemplo n.º 17
0
        public static ThingFilter DefaultFilter_RottableZone()
        {
            var filter = new ThingFilter();

            filter.SetDisallowAll(null, DefDatabase <SpecialThingFilterDef> .AllDefs);

            DefDatabase <ThingDef> .AllDefs
            .Where(d => d.HasComp(typeof(CompRottable)))
            .ToList()
            .ForEach(d => filter.SetAllow(d, true));

            filter.SetAllow(SpecialThingFilterDef.Named("AllowRotten"), false);
            filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, false);

            return(filter);
        }
        public static ThingFilter DefaultFilter_MealZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            for (int t = 0; t < database.Count; t++)
            {
                if (database[t].comps.Any(c => c is CompProperties_Rottable) && database[t].IsIngestible && ((database[t].ingestible.foodType & FoodTypeFlags.Meal) != 0))
                {
                    filter.SetAllow(database[t], true);
                }
            }
            return(filter);
        }
        public Trigger_Threshold(ManagerJob_Mining job) : base(job.manager)
        {
            Op = Ops.LowerThan;
            MaxUpperThreshold = DefaultMaxUpperThreshold;
            TargetCount       = DefaultCount;
            ThresholdFilter   = new ThingFilter(job.Notify_ThresholdFilterChanged);
            ThresholdFilter.SetDisallowAll();

            // limit selection to stone, chunks, minerals and components only.
            ParentFilter = new ThingFilter();
            ParentFilter.SetDisallowAll();
            ParentFilter.SetAllow(ThingCategoryDefOf.Chunks, true);
            ParentFilter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true);
            ParentFilter.SetAllow(ThingCategoryDefOf.PlantMatter, false);
            ParentFilter.SetAllow(ThingDefOf.ComponentIndustrial, true);
        }
Exemplo n.º 20
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, IEnumerable <ThingDef> forceHiddenDefs = null, IEnumerable <SpecialThingFilterDef> forceHiddenFilters = null, List <ThingDef> suppressSmallVolumeTags = null)
        {
            Widgets.DrawMenuSection(rect);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);

            if (Widgets.ButtonText(rect2, "ClearAll".Translate()))
            {
                filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), 24f);

            if (Widgets.ButtonText(rect3, "AllowAll".Translate()))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 2f;

            DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            DrawMarketValueFilterConfig(ref num2, viewRect.width, filter);
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, viewRect.width, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, forceHiddenDefs, forceHiddenFilters, suppressSmallVolumeTags);

            listing_TreeThingFilter.Begin(rect4);
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                node = parentFilter.DisplayRootCategory;
            }
            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
        public static ThingFilter DefaultFilter_MeatZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            for (int t = 0; t < database.Count; t++)
            {
                if (database[t].IsIngestible && database[t].ingestible.sourceDef != null && database[t].ingestible.sourceDef.race != null && !database[t].ingestible.sourceDef.race.Humanlike && database[t].ingestible.sourceDef.race.FleshType != FleshTypeDefOf.Insectoid)
                {
                    filter.SetAllow(database[t], true);
                }
            }
            filter.SetAllow(ThingCategoryDefOf.Corpses, false);
            return(filter);
        }
Exemplo n.º 22
0
 public Trigger_Threshold( ManagerJob_Production job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = job.MainProduct.MaxUpperThreshold;
     // TODO: Better way of setting sensible defaults?
     Count = MaxUpperThreshold / 20;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     if ( job.MainProduct.ThingDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.ThingDef, true );
     }
     if ( job.MainProduct.CategoryDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.CategoryDef, true );
     }
 }
 public Trigger_Threshold( ManagerJob_Production job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = job.MainProduct.MaxUpperThreshold;
     // TODO: Better way of setting sensible defaults?
     Count = MaxUpperThreshold / 20;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     if ( job.MainProduct.ThingDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.ThingDef, true );
     }
     if ( job.MainProduct.CategoryDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.CategoryDef, true );
     }
 }
 public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1)
 {
     Widgets.DrawMenuSection(rect);
     Text.Font = GameFont.Tiny;
     var num = rect.width - 2f;
     var rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);
     if (Widgets.ButtonText(rect2, "ClearAll".Translate()))
     {
         filter.SetDisallowAll();
     }
     var rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f - 1f, 24f);
     if (Widgets.ButtonText(rect3, "AllowAll".Translate()))
     {
         filter.SetAllowAll(parentFilter);
     }
     Text.Font = GameFont.Small;
     rect.yMin = rect2.yMax;
     var viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);
     Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
     var num2 = 0f;
     num2 += 2f;
     DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
     DrawQualityFilterConfig(ref num2, viewRect.width, filter);
     var num3 = num2;
     var rect4 = new Rect(0f, num2, 9999f, 9999f);
     var listing_TreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter);
     var node = ThingCategoryNodeDatabase.RootNode;
     if (parentFilter != null)
     {
         if (parentFilter.DisplayRootCategory == null)
         {
             parentFilter.RecalculateDisplayRootCategory();
         }
         node = parentFilter.DisplayRootCategory;
     }
     listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
     listing_TreeThingFilter.End();
     if (Event.current.type == EventType.Layout)
     {
         viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
     }
     Widgets.EndScrollView();
 }
        public static ThingFilter DefaultFilter_OutdoorZone()
        {
            List <ThingDef> list   = new List <ThingDef>();
            ThingFilter     filter = new ThingFilter();

            filter.SetDisallowAll();

            list.AddRange(ThingCategoryDefOf.ResourcesRaw.DescendantThingDefs);
            list.AddRange(ThingCategoryDefOf.Items.DescendantThingDefs);

            for (int t = 0; t < list.Count; t++)
            {
                if (list[t].GetStatValueAbstract(StatDefOf.DeteriorationRate) == 0 && !list[t].comps.Any(c => c is CompProperties_Rottable) && !list[t].IsIngestible)
                {
                    filter.SetAllow(list[t], true);
                }
            }

            return(filter);
        }
Exemplo n.º 26
0
 public void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1)
 {
     Widgets.DrawMenuSection(rect);
     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()))
     {
         filter.SetDisallowAll();
     }
     Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f);
     if (Widgets.TextButton(rect3, "AllowAll".Translate()))
     {
         filter.SetAllowAll(parentFilter);
     }
     Text.Font = GameFont.Small;
     rect.yMin = rect2.yMax;
     Rect viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);
     Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
     float num2 = 0f;
     num2 += 2f;
     DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
     DrawQualityFilterConfig(ref num2, viewRect.width, filter);
     float num3 = num2;
     Rect rect4 = new Rect(0f, num2, 9999f, 9999f);
     Listing_TreeThingFilter listingTreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter, 210f, true);
     TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;
     if (parentFilter != null)
     {
         if (parentFilter.DisplayRootCategory == null)
         {
             parentFilter.RecalculateDisplayRootCategory();
         }
         node = parentFilter.DisplayRootCategory;
     }
     listingTreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
     listingTreeThingFilter.End();
     viewHeight = num3 + listingTreeThingFilter.CurHeight + 90f;
     Log.Message(viewHeight.ToString(CultureInfo.InvariantCulture));
     Widgets.EndScrollView();
 }
Exemplo n.º 27
0
        public override void GenerateRewards(ThingFilter filter, FloatRange totalValue, IntRange countRange, TechLevel?techLevel, float?totalMass)
        {
            base.GenerateRewards(filter, totalValue, countRange, techLevel, totalMass);

            filter.SetDisallowAll();
            filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true);
            filter.SetAllow(ThingCategoryDefOf.Items, true);

            ThingSetMaker_MarketValue maker  = new ThingSetMaker_MarketValue();
            ThingSetMakerParams       parms2 = default;

            parms2.totalMarketValueRange = new FloatRange(300, 800);
            parms2.countRange            = new IntRange(2, 4);
            parms2.filter = filter;

            maker.fixedParams = parms2;

            List <Thing> items = maker.Generate();

            items.ForEach(i => Rewards.Add(i));
        }
Exemplo n.º 28
0
        public override void DoWindowContents(Rect inRect)
        {
            if (thingFilter.AllowedThingDefs.Count() > 1)
            {
                thingFilter = new ThingFilter();
                thingFilter.AllowedQualityLevels     = SelectQualities;
                thingFilter.AllowedHitPointsPercents = SelectHitPointsPercents;
                thingFilter.SetDisallowAll(null, null);
            }
            SelectThingDef          = thingFilter.AllowedThingDefs.FirstOrDefault();
            SelectQualities         = thingFilter.AllowedQualityLevels;
            SelectHitPointsPercents = thingFilter.AllowedHitPointsPercents;

            const float mainListingSpacing = 6f;

            var btnSize      = new Vector2(140f, 40f);
            var buttonYStart = inRect.height - btnSize.y;

            /*
             * var ev = Event.current;
             * if (Widgets.ButtonText(new Rect(0, buttonYStart, btnSize.x, btnSize.y), "OCity_DialogInput_Ok".Translate())
             || ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return)
             */
            if (SelectThingDef != null)
            {
                Close();
            }

            if (Widgets.ButtonText(new Rect(inRect.width - btnSize.x, buttonYStart, btnSize.x, btnSize.y), "OCity_DialogInput_Cancele".Translate()))
            {
                Close();
            }

            //выше кнопок
            Rect workRect = new Rect(inRect.x, inRect.y, inRect.width, buttonYStart - mainListingSpacing);

            ThingFilterUI.DoThingFilterConfigWindow(workRect, ref this.scrollPosition, thingFilter, null, 8);
        }
        public ManagerJob_Fishing(Manager manager) : base(manager)
        {
            var thingFilter = new ThingFilter(Notify_ThresholdFilterChanged);

            thingFilter.SetDisallowAll();
            var parentFilter = new ThingFilter();

            parentFilter.SetAllowAll(null);
            Trigger = new Trigger_Threshold(this.manager)
            {
                Op = Trigger_Threshold.Ops.LowerThan,
                MaxUpperThreshold = Trigger_Threshold.DefaultMaxUpperThreshold,
                TargetCount       = Trigger_Threshold.DefaultCount,
                ThresholdFilter   = thingFilter,
                ParentFilter      = parentFilter,
                countAllOnMap     = true
            };
            History = new History(new[] { I18n.HistoryStock, I18n.HistoryDesignated }, new[] { Color.white, Color.grey });
            if (Scribe.mode == LoadSaveMode.Inactive)
            {
                RefreshAllowedFish();
            }
        }
        public static ThingFilter DefaultFilter_IndoorZone()
        {
            List <ThingDef> database = DefDatabase <ThingDef> .AllDefsListForReading;
            ThingFilter     filter   = new ThingFilter();

            filter.SetDisallowAll();

            for (int t = 0; t < database.Count; t++)
            {
                if (database[t].GetStatValueAbstract(StatDefOf.DeteriorationRate) > 0)
                {
                    filter.SetAllow(database[t], true);
                }
            }
            filter.SetAllow(ThingCategoryDefOf.Corpses, false);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowRotten"), false);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowPlantFood"), true);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowNonDeadmansApparel"), true);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowSmeltable"), true);
            filter.SetAllow(SpecialThingFilterDef.Named("AllowNonSmeltableWeapons"), true);

            return(filter);
        }
Exemplo n.º 31
0
        public static List <RecipeDef> GenAlloySmeltDefs(IReadOnlyList <AlloyDef> alloys)
        {
            if (alloys == null)
            {
                return(null);
            }

            var field = typeof(RecipeDef).GetField("ingredientValueGetterInt", BindingFlags.NonPublic | BindingFlags.Instance);

            if (field == null)
            {
                Core.Error("Failed to find RecipeDef.ingredientValueGetterInt field. Has RimWorld updated and broken everything?");
                return(null);
            }

            StringBuilder str = new StringBuilder(128);

            string MakeDesc(AlloyDef alloy, int multi)
            {
                str.Clear();
                foreach (var item in alloy.input)
                {
                    var equivalents = AlloyHelper.GetEquivalentResources(item.resource);
                    if (equivalents.Count == 1)
                    {
                        str.Append(" •");
                        str.Append(item.resource.LabelCap);
                        str.Append(" x");
                        str.Append(item.count * multi).AppendLine();
                    }
                    else
                    {
                        str.Append(" •");
                        for (int i = 0; i < equivalents.Count; i++)
                        {
                            var    eq      = equivalents[i];
                            string modName = eq.modContentPack == null ? "???" : eq.modContentPack.IsCoreMod ? null : eq.modContentPack.Name;
                            if (modName != null)
                            {
                                str.Append("<i>").Append(modName).Append("</i> ");
                            }
                            str.Append(eq.LabelCap);
                            if (i != equivalents.Count - 1)
                            {
                                str.Append(" or ");
                            }
                        }
                        str.Append(" x");
                        str.Append(item.count * multi).AppendLine();
                    }
                }
                str.Append("\nRequires forge temperature: <color=#ff5555ff>").Append(alloy.MinTemperature.ToStringTemperature()).Append("</color>");
                return($"{alloy.description?.TrimEnd()}\n\nMake {alloy.output.resource.label} x{alloy.output.count * multi} using:\n\n{str.ToString().TrimEnd()}".TrimStart());
            }

            RecipeDef CreateDef(AlloyDef alloy, bool bulk)
            {
                var output = alloy.output.resource;

                int multi = bulk ? alloy.bulkMultiplier : 1;

                RecipeDef def = new RecipeDef();

                def.defName = $"RF_Smelt_{output.defName}{(bulk ? "_Bulk" : "")}_AutoGenerated";
                def.label   = $"Create {output.label}";
                if (bulk)
                {
                    def.label += " (bulk)";
                }
                def.description    = MakeDesc(alloy, multi);
                def.workAmount     = alloy.baseWork * multi;
                def.jobString      = $"Creating {output.label} at the forge.";
                def.modContentPack = alloy.modContentPack ?? output.modContentPack;
                def.fileName       = "fuckoffitsautogeneratedwhatdoyouexpect.xml";
                def.generated      = true;
                field.SetValue(def, new IngredientValueGetter_IgnoreVolume());

                // Add output.
                def.products.Add(new ThingDefCountClass(alloy.output.resource, alloy.output.count * multi));

                // Add inputs.
                ThingFilter masterFilter = new ThingFilter();

                masterFilter.SetDisallowAll();
                foreach (var item in alloy.input)
                {
                    var ingredient    = new IngredientCount();
                    var allowedInputs = AlloyHelper.GetEquivalentResources(item.resource);
                    foreach (var item2 in allowedInputs)
                    {
                        ingredient.filter.SetAllow(item2, true);
                        masterFilter.SetAllow(item2, true);
                    }

                    ingredient.SetBaseCount(item.count * multi);
                    def.ingredients.Add(ingredient);
                }
                def.fixedIngredientFilter = masterFilter;
                return(def);
            }

            var list = new List <RecipeDef>(alloys.Count);

            foreach (var alloy in alloys)
            {
                if (alloy == null || !alloy.IsValid)
                {
                    continue;
                }

                var simple = CreateDef(alloy, false);
                list.Add(simple);
                AlloyHelper.RegisterAlloyRecipe(simple, alloy);

                if (alloy.allowBulk)
                {
                    var bulk = CreateDef(alloy, true);
                    list.Add(bulk);
                    AlloyHelper.RegisterAlloyRecipe(bulk, alloy);
                }
            }

            DefGenHelper.TryPostGenerate(list);


            return(list);
        }
        public static void DoThingFilterConfigWindowHeader(ref Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, IEnumerable <ThingDef> forceHiddenDefs = null, IEnumerable <SpecialThingFilterDef> forceHiddenFilters = null, List <ThingDef> suppressSmallVolumeTags = null)
        {
            bool showSearch = showSearchCount-- > 0 && searchOptions.Count != 0;

            showSearchCount = Math.Max(0, showSearchCount);

            if (showSearch)
            {
                /*      Layout
                 *                   buttonSpacing    2x buttonSpacing                                                             buttonsInset
                 *                     |                |                                                                           |        |
                 *                   |<>|            |<--->|                                                                      |<>|       |
                 *                                                                                                                           |
                 *   +---------------------------------------------------------------------------------------------------------------+   -   |
                 *   |                                                                                                               |   o---+
                 *   |  +------------+--+------------+-----+----------------------------------------------------------------------+  |   -
                 *   |  |            |  |            |     |                                                                      |  |   ^
                 *   |  |   CLEAR    |  |   ALLOW    |     |                                                                      |  |   |
                 *   |  |            |  |            |     |              SEARCH BOX                                              |  |   |- buttonSize
                 *   |  |    ALL     |  |    ALL     |     |                                                                      |  |   |
                 *   |  |            |  |            |     |                                                                      |  |   v
                 *   |  +------------+--+------------+-----+------------ headRect ------------------------------------------------+  |   -
                 *   |                                                                                                               |
                 *
                 *
                 *      |<------ restWidth --------->|     |<--------------------------- searchWidth ---------------------------->|
                 *
                 *
                 *      |<--------->|   |<---------->|
                 *              |             |
                 *              clearAllowWidth
                 *              (clamped to min
                 *               buttonSize+2*2)
                 */


                var headRect = new Rect(rect.x + buttonsInset, rect.y + buttonsInset, rect.width - (2 * buttonsInset), buttonSize);
                Text.Font = GameFont.Tiny;
                var restWidth       = headRect.width * (1 - Settings.SearchWidth) - 3 * buttonSpacing;
                var clearAllowWidth = Math.Max(buttonSize, restWidth / 2f);


                Text.Font = GameFont.Tiny;
                var clear = "ClearAll".Translate();
                var allow = "AllowAll".Translate();

                // check min width "clear"/"allow" texts would need
                var minWidth = new[] { clear, allow }.Max(c => Text.CurFontStyle.CalcSize(new GUIContent(c)).x);

                Func <Rect, string, object, bool> drawButton;

                if (minWidth + 4f > clearAllowWidth)
                {
                    // use icons
                    drawButton = (r, t, o) => ExtraWidgets.ButtonImage(r, (Texture2D)o, true, new TipSignal {
                        text = t
                    }, new Rect(r.x + (r.width - buttonSize) / 2f, r.y, buttonSize, buttonSize));
                }
                else
                {
                    // use text buttons
                    drawButton = (r, t, _) => Widgets.ButtonText(r, t, true, false, true);
                }

                Rect rect2 = new Rect(headRect.x, headRect.y, clearAllowWidth, buttonSize);
                if (drawButton(rect2, clear, Widgets.CheckboxOffTex))
                {
                    filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
                }
                Rect rect3 = new Rect(headRect.x + clearAllowWidth + buttonSpacing, headRect.y, clearAllowWidth, buttonSize);
                if (drawButton(rect3, allow, Widgets.CheckboxOnTex))
                {
                    filter.SetAllowAll(parentFilter);
                }

                var searchWidth = headRect.width - (2 * clearAllowWidth + 3 * buttonSpacing);

                Rect searchRect = new Rect(headRect.xMax - searchWidth, headRect.y, searchWidth, buttonSize);

                var options = searchOptions.Dequeue();
                DoSearchBlock(searchRect, options.Term, options.Watermark);
                ThingFilter_InjectFilter.Projections.Enqueue(options.Term.FilterNodes);

                rect.yMin = searchRect.yMax;
            }
            else
            {
                Text.Font = GameFont.Tiny;
                float num   = rect.width - 2f;
                Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);
                if (Widgets.ButtonText(rect2, "ClearAll".Translate(), true, false, true))
                {
                    filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
                }
                Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), 24f);
                if (Widgets.ButtonText(rect3, "AllowAll".Translate(), true, false, true))
                {
                    filter.SetAllowAll(parentFilter);
                }
                Text.Font = GameFont.Small;
                rect.yMin = rect2.yMax + 1;
            }
        }
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> menuList = new List <FloatMenuOption>();

            menuList.Add(new FloatMenuOption("CSSP_GeneralFreezer".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Foods, true);
                filter.SetAllow(ThingDefOf.Ambrosia, true);
                filter.SetAllow(ThingDefOf.Beer, true);
                filter.SetAllow(ThingDefOf.Wort, true);
                filter.SetAllow(ThingCategoryDefOf.PlantMatter, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowRotten, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_FreezerNoMeals".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Foods, true);
                filter.SetAllow(ThingCategoryDefOf.FoodMeals, false);
                filter.SetAllow(ThingDefOf.Ambrosia, true);
                filter.SetAllow(ThingDefOf.Beer, true);
                filter.SetAllow(ThingDefOf.Wort, true);
                filter.SetAllow(ThingCategoryDefOf.PlantMatter, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowRotten, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Meals".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.FoodMeals, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowRotten, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_GeneralStorage".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Manufactured, true);
                filter.SetAllow(ThingDefOf.Ambrosia, false);
                filter.SetAllow(ThingDefOf.Beer, false);
                filter.SetAllow(ThingDefOf.Wort, false);
                filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true);
                filter.SetAllow(ThingCategoryDefOf.PlantMatter, false);
                filter.SetAllow(ThingCategoryDefOf.Items, true);
                filter.SetAllow(ThingCategoryDefOf.Weapons, true);
                filter.SetAllow(ThingCategoryDefOf.Apparel, true);
                filter.SetAllow(ThingCategoryDefOf.Buildings, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesMechanoid, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_GeneralMedical".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Medicine, true);
                filter.SetAllow(ThingCategoryDefOf.Drugs, true);
                filter.SetAllow(ThingDefOf.Ambrosia, false);
                filter.SetAllow(ThingDefOf.Beer, false);
                filter.SetAllow(ThingDefOf.Neutroamine, true);
                filter.SetAllow(ThingCategoryDefOf.BodyParts, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Drugs".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Drugs, true);
                filter.SetAllow(ThingDefOf.Ambrosia, false);
                filter.SetAllow(ThingDefOf.Beer, false);
                filter.SetAllow(ThingDefOf.Neutroamine, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_MaterialsOutside".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.StoneBlocks, true);
                filter.SetAllow(ThingDefOf.Plasteel, true);
                filter.SetAllow(ThingDefOf.Silver, true);
                filter.SetAllow(ThingDefOf.Steel, true);
                filter.SetAllow(ThingDefOf.Uranium, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Materials".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true);
                filter.SetAllow(ThingCategoryDefOf.PlantMatter, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_VariousOthers".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Manufactured, true);
                filter.SetAllow(ThingCategoryDefOf.Medicine, false);
                filter.SetAllow(ThingCategoryDefOf.Drugs, false);
                filter.SetAllow(ThingDefOf.Neutroamine, false);
                filter.SetAllow(ThingDefOf.Wort, false);
                filter.SetAllow(ThingCategoryDefOf.Items, true);
                filter.SetAllow(ThingCategoryDefOf.BodyParts, false);
                filter.SetAllow(ThingCategoryDefOf.Weapons, true);
                filter.SetAllow(ThingCategoryDefOf.Apparel, true);
                filter.SetAllow(ThingCategoryDefOf.Buildings, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesMechanoid, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowDeadmansApparel, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Shells".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(AdditionalThingCategoryDefOf.MortarShells, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Weapons".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Weapons, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_CleanApparel".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Apparel, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowDeadmansApparel, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_TaintedApparel".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Apparel, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowNonDeadmansApparel, false);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Chunks".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Chunks, true);
            }));

            menuList.Add(new FloatMenuOption("CSSP_Rotting".Translate(), delegate
            {
                filter.SetDisallowAll();
                filter.SetAllow(ThingCategoryDefOf.Apparel, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesHumanlike, true);
                filter.SetAllow(ThingCategoryDefOf.CorpsesAnimal, true);
                filter.SetAllow(SpecialThingFilterDefOf.AllowFresh, false);
                filter.SetAllow(SpecialThingFilterDefOf.AllowNonDeadmansApparel, false);
            }));

            Find.WindowStack.Add(new FloatMenu(menuList));
        }
Exemplo n.º 34
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, string filterText = null)
        {
            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))
            {
                filter.SetDisallowAll();
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f);

            if (Widgets.TextButton(rect3, "AllowAll".Translate(), true, false))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, HelperThingFilterUI.viewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 0f;

            num2 += 2f;
            HelperThingFilterUI.DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            HelperThingFilterUI.DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, 9999f, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter, 210f, true);
            TreeNode_ThingCategory  node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            if (filterText != null && filterText.Length > 2)
            {
                var rootNode = new TreeNode_ThingCategory(new ThingCategoryDef());

                node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower()));

                foreach (ThingDef currentThing in node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower())))
                {
                    rootNode.catDef.childThingDefs.Add(currentThing);
                }

                node = rootNode;
            }

            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                HelperThingFilterUI.viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
Exemplo n.º 35
0
 public Trigger_Threshold( ManagerJob_Hunting job )
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true );
 }
Exemplo n.º 36
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, IEnumerable <ThingDef> forceHiddenDefs = null, IEnumerable <SpecialThingFilterDef> forceHiddenFilters = null, string filterText = null)
        {
            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.ButtonText(rect2, "ClearAll".Translate(), true, false, true))
            {
                filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
            }
            if (Widgets.ButtonText(new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f), "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, HelperThingFilterUI.viewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 2f;

            HelperThingFilterUI.DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            HelperThingFilterUI.DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            float num3 = num2;
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(new Rect(0f, num2, viewRect.width, 9999f), filter, parentFilter, forceHiddenDefs, forceHiddenFilters);
            TreeNode_ThingCategory  treeNode_ThingCategory  = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                treeNode_ThingCategory = parentFilter.DisplayRootCategory;
            }
            if (filterText != null && filterText.Length > 0)
            {
                TreeNode_ThingCategory treeNode_ThingCategory2 = new TreeNode_ThingCategory(new ThingCategoryDef());
                from td in treeNode_ThingCategory.catDef.DescendantThingDefs
                where td.label.ToLower().Contains(filterText.ToLower())
                select td;
                IEnumerable <ThingDef> arg_1D5_0 = treeNode_ThingCategory.catDef.DescendantThingDefs;
                Func <ThingDef, bool> < > 9__1;
                Func <ThingDef, bool> arg_1D5_1;
                if ((arg_1D5_1 = < > 9__1) == null)
                {
                    arg_1D5_1 = (< > 9__1 = ((ThingDef td) => td.label.ToLower().Contains(filterText.ToLower())));
                }
                foreach (ThingDef current in arg_1D5_0.Where(arg_1D5_1))
                {
                    treeNode_ThingCategory2.catDef.childThingDefs.Add(current);
                }
                treeNode_ThingCategory = treeNode_ThingCategory2;
            }
            listing_TreeThingFilter.DoCategoryChildren(treeNode_ThingCategory, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                HelperThingFilterUI.viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
        public void DoThingFilterConfigWindow(Rect canvas, ref Vector2 scrollPosition, ThingFilter filter,
                                              ThingFilter parentFilter = null, int openMask = 1,
                                              bool buttonsAtBottom     = false)
        {
            // respect your bounds!
            GUI.BeginGroup(canvas);
            canvas = canvas.AtZero();

            // set up buttons
            Text.Font = GameFont.Tiny;
            float width           = canvas.width - 2f;
            var   clearButtonRect = new Rect(canvas.x + 1f, canvas.y + 1f, width / 2f, 24f);
            var   allButtonRect   = new Rect(clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f);

            // offset canvas position for buttons.
            if (buttonsAtBottom)
            {
                clearButtonRect.y = canvas.height - clearButtonRect.height;
                allButtonRect.y   = canvas.height - clearButtonRect.height;
                canvas.yMax      -= clearButtonRect.height;
            }
            else
            {
                canvas.yMin = clearButtonRect.height;
            }

            // draw buttons + logic
            if (Widgets.ButtonTextSubtle(clearButtonRect, "ClearAll".Translate()))
            {
                filter.SetDisallowAll();
            }
            if (Widgets.ButtonTextSubtle(allButtonRect, "AllowAll".Translate()))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;

            // do list
            var curY     = 2f;
            var viewRect = new Rect(0f, 0f, canvas.width - ScrollbarWidth, viewHeight);

            // scrollview
            Widgets.BeginScrollView(canvas, ref scrollPosition, viewRect);

            // slider(s)
            DrawHitPointsFilterConfig(ref curY, viewRect.width, filter);
            DrawQualityFilterConfig(ref curY, viewRect.width, filter);

            // main listing
            var listingRect            = new Rect(0f, curY, viewRect.width, 9999f);
            var listingTreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, null, null, null);

            listingTreeThingFilter.Begin(listingRect);
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            // draw the actual thing
            listingTreeThingFilter.DoCategoryChildren(node, 0, openMask, Find.CurrentMap, true);
            listingTreeThingFilter.End();

            // update height.
            viewHeight = curY + listingTreeThingFilter.CurHeight;
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
 public Trigger_Threshold( ManagerJob_Foraging job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
 }
        public void DoThingFilterConfigWindow( Rect canvas, ref Vector2 scrollPosition, ThingFilter filter,
                                               ThingFilter parentFilter = null, int openMask = 1,
                                               bool buttonsAtBottom = false )
        {
            // respect your bounds!
            GUI.BeginGroup( canvas );
            canvas = canvas.AtZero();

            // set up buttons
            Text.Font = GameFont.Tiny;
            float width = canvas.width - 2f;
            var clearButtonRect = new Rect( canvas.x + 1f, canvas.y + 1f, width / 2f, 24f );
            var allButtonRect = new Rect( clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f );

            // offset canvas position for buttons.
            if ( buttonsAtBottom )
            {
                clearButtonRect.y = canvas.height - clearButtonRect.height;
                allButtonRect.y = canvas.height - clearButtonRect.height;
                canvas.yMax -= clearButtonRect.height;
            }
            else
            {
                canvas.yMin = clearButtonRect.height;
            }

            // draw buttons + logic
            if ( Widgets.ButtonTextSubtle( clearButtonRect, "ClearAll".Translate() ) )
            {
                filter.SetDisallowAll();
            }
            if ( Widgets.ButtonTextSubtle( allButtonRect, "AllowAll".Translate() ) )
            {
                filter.SetAllowAll( parentFilter );
            }
            Text.Font = GameFont.Small;

            // do list
            var curY = 2f;
            var viewRect = new Rect( 0f, 0f, canvas.width - 16f, viewHeight );

            // scrollview
            Widgets.BeginScrollView( canvas, ref scrollPosition, viewRect );

            // slider(s)
            DrawHitPointsFilterConfig( ref curY, viewRect.width, filter );
            DrawQualityFilterConfig( ref curY, viewRect.width, filter );

            // main listing
            var listingRect = new Rect( 0f, curY, viewRect.width, 9999f );
            var listingTreeThingFilter = new Listing_TreeThingFilter( listingRect, filter, parentFilter, null, null );
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;
            if ( parentFilter != null )
            {
                if ( parentFilter.DisplayRootCategory == null )
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            // draw the actual thing
            listingTreeThingFilter.DoCategoryChildren( node, 0, openMask, true );
            listingTreeThingFilter.End();

            // update height.
            viewHeight = curY + listingTreeThingFilter.CurHeight;
            Widgets.EndScrollView();
            GUI.EndGroup();
        }