Beispiel #1
0
        private static void SetAllowInCategory(Listing_TreeThingFilter instance, TreeNode_ThingCategory node, bool allow, List <ThingDef> exceptedDefs, List <SpecialThingFilterDef> exceptedFilters)
        {
            ThingFilter      filter      = fieldFilter.GetValue(instance) as ThingFilter;
            ThingCategoryDef categoryDef = node.catDef;

            if (!ThingCategoryNodeDatabase.initialized)
            {
                Log.Error("SetAllow categories won't work before ThingCategoryDatabase is initialized.", false);
            }

            foreach (ThingDef thingDef in categoryDef.DescendantThingDefs)
            {
                if ((exceptedDefs == null || !exceptedDefs.Contains(thingDef)) && SearchUtility.CheckVisible(thingDef))
                {
                    if (SearchUtility.CheckVisible(thingDef))
                    {
                        filter.SetAllow(thingDef, allow);
                    }
                }
            }
            foreach (SpecialThingFilterDef specialThingFilterDef in categoryDef.DescendantSpecialThingFilterDefs)
            {
                if (exceptedFilters == null || !exceptedFilters.Contains(specialThingFilterDef))
                {
                    filter.SetAllow(specialThingFilterDef, allow);
                }
            }

            (fieldSettingsChangedCallback.GetValue(filter) as Action)?.Invoke();
        }
Beispiel #2
0
 public static void VisiblePostfix(ref bool __result, ThingDef td)
 {
     if (__result && !string.IsNullOrEmpty(SearchUtility.Keyword) && !SearchUtility.CheckVisible(td))
     {
         __result = false;
     }
 }
Beispiel #3
0
 private static List <TransferableOneWay> QueryTransferable(List <TransferableOneWay> cachedTransferables)
 {
     if (!string.IsNullOrEmpty(SearchUtility.Keyword))
     {
         return((from x in cachedTransferables where SearchUtility.CheckVisible(x) select x).ToList());
     }
     else
     {
         return(cachedTransferables);
     }
 }
Beispiel #4
0
 private static List <Tradeable> QueryTradable(List <Tradeable> cachedTradeables)
 {
     return(cachedTradeables.Where(x => SearchUtility.CheckVisible(x)).ToList());
 }