示例#1
0
        private bool Visible(SpecialThingFilterDef filter)
        {
            bool result;

            if (this.parentFilter != null && !this.parentFilter.Allows(filter))
            {
                result = false;
            }
            else
            {
                if (this.hiddenSpecialFilters == null)
                {
                    this.CalculateHiddenSpecialFilters();
                }
                for (int i = 0; i < this.hiddenSpecialFilters.Count; i++)
                {
                    if (this.hiddenSpecialFilters[i] == filter)
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
 public void SetAllow(SpecialThingFilterDef sfDef, bool allow)
 {
     if (!sfDef.configurable)
     {
         return;
     }
     if (allow == this.Allows(sfDef))
     {
         return;
     }
     if (allow)
     {
         if (this.disallowedSpecialFilters.Contains(sfDef))
         {
             this.disallowedSpecialFilters.Remove(sfDef);
         }
     }
     else if (!this.disallowedSpecialFilters.Contains(sfDef))
     {
         this.disallowedSpecialFilters.Add(sfDef);
     }
     if (this.settingsChangedCallback != null)
     {
         this.settingsChangedCallback();
     }
 }
 private void DoSpecialFilter(SpecialThingFilterDef sfDef, int nestLevel)
 {
     if (sfDef.configurable)
     {
         LabelLeft("*" + sfDef.LabelCap, sfDef.description, nestLevel);
         bool checkOn = filter.Allows(sfDef);
         bool flag    = checkOn;
         Widgets.Checkbox(new Vector2(LabelWidth, curY), ref checkOn, lineHeight, disabled: false, paintable: true);
         if (checkOn != flag)
         {
             filter.SetAllow(sfDef, checkOn);
         }
         EndLine();
     }
 }
示例#4
0
 private void DoSpecialFilter(SpecialThingFilterDef sfDef, int nestLevel)
 {
     if (sfDef.configurable)
     {
         base.LabelLeft("*" + sfDef.LabelCap, sfDef.description, nestLevel);
         bool flag  = this.filter.Allows(sfDef);
         bool flag2 = flag;
         Widgets.Checkbox(new Vector2(this.LabelWidth, this.curY), ref flag, this.lineHeight, false, true, null, null);
         if (flag != flag2)
         {
             this.filter.SetAllow(sfDef, flag);
         }
         base.EndLine();
     }
 }
 private bool Visible_NewTemp(SpecialThingFilterDef filter, TreeNode_ThingCategory node)
 {
     if (parentFilter != null && !parentFilter.Allows(filter))
     {
         return(false);
     }
     if (hiddenSpecialFilters == null)
     {
         CalculateHiddenSpecialFilters(node);
     }
     for (int i = 0; i < hiddenSpecialFilters.Count; i++)
     {
         if (hiddenSpecialFilters[i] == filter)
         {
             return(false);
         }
     }
     return(true);
 }
示例#6
0
 public void SetAllow(SpecialThingFilterDef sfDef, bool allow)
 {
     if (sfDef.configurable && allow != Allows(sfDef))
     {
         if (allow)
         {
             if (disallowedSpecialFilters.Contains(sfDef))
             {
                 disallowedSpecialFilters.Remove(sfDef);
             }
         }
         else if (!disallowedSpecialFilters.Contains(sfDef))
         {
             disallowedSpecialFilters.Add(sfDef);
         }
         if (settingsChangedCallback != null)
         {
             settingsChangedCallback();
         }
     }
 }
示例#7
0
 public void SetAllow(SpecialThingFilterDef sfDef, bool allow)
 {
     if (!sfDef.configurable || allow == Allows(sfDef))
     {
         return;
     }
     if (allow)
     {
         if (disallowedSpecialFilters.Contains(sfDef))
         {
             disallowedSpecialFilters.Remove(sfDef);
         }
     }
     else if (!disallowedSpecialFilters.Contains(sfDef))
     {
         disallowedSpecialFilters.Add(sfDef);
     }
     if (settingsChangedCallback != null)
     {
         settingsChangedCallback();
     }
     displayRootCategoryInt = null;
 }
 internal bool <> m__1(SpecialThingFilterDef sf)
 {
     return(sf.configurable && (this.exceptedFilters == null || !this.exceptedFilters.Contains(sf)));
 }
 private static bool <SetAllowAll> m__1(SpecialThingFilterDef sf)
 {
     return(sf.configurable);
 }
 public bool Allows(SpecialThingFilterDef sf)
 {
     return(!this.disallowedSpecialFilters.Contains(sf));
 }
        public void ResolveReferences()
        {
            for (int i = 0; i < DefDatabase <SpecialThingFilterDef> .AllDefsListForReading.Count; i++)
            {
                SpecialThingFilterDef specialThingFilterDef = DefDatabase <SpecialThingFilterDef> .AllDefsListForReading[i];
                if (!specialThingFilterDef.allowedByDefault)
                {
                    this.SetAllow(specialThingFilterDef, false);
                }
            }
            if (this.thingDefs != null)
            {
                for (int j = 0; j < this.thingDefs.Count; j++)
                {
                    if (this.thingDefs[j] != null)
                    {
                        this.SetAllow(this.thingDefs[j], true);
                    }
                    else
                    {
                        Log.Error("ThingFilter could not find thing def named " + this.thingDefs[j], false);
                    }
                }
            }
            if (this.categories != null)
            {
                for (int k = 0; k < this.categories.Count; k++)
                {
                    ThingCategoryDef named = DefDatabase <ThingCategoryDef> .GetNamed(this.categories[k], true);

                    if (named != null)
                    {
                        this.SetAllow(named, true, null, null);
                    }
                }
            }
            if (this.tradeTagsToAllow != null)
            {
                for (int l = 0; l < this.tradeTagsToAllow.Count; l++)
                {
                    List <ThingDef> allDefsListForReading = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int m = 0; m < allDefsListForReading.Count; m++)
                    {
                        ThingDef thingDef = allDefsListForReading[m];
                        if (thingDef.tradeTags != null && thingDef.tradeTags.Contains(this.tradeTagsToAllow[l]))
                        {
                            this.SetAllow(thingDef, true);
                        }
                    }
                }
            }
            if (this.tradeTagsToDisallow != null)
            {
                for (int n = 0; n < this.tradeTagsToDisallow.Count; n++)
                {
                    List <ThingDef> allDefsListForReading2 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num = 0; num < allDefsListForReading2.Count; num++)
                    {
                        ThingDef thingDef2 = allDefsListForReading2[num];
                        if (thingDef2.tradeTags != null && thingDef2.tradeTags.Contains(this.tradeTagsToDisallow[n]))
                        {
                            this.SetAllow(thingDef2, false);
                        }
                    }
                }
            }
            if (this.thingSetMakerTagsToAllow != null)
            {
                for (int num2 = 0; num2 < this.thingSetMakerTagsToAllow.Count; num2++)
                {
                    List <ThingDef> allDefsListForReading3 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num3 = 0; num3 < allDefsListForReading3.Count; num3++)
                    {
                        ThingDef thingDef3 = allDefsListForReading3[num3];
                        if (thingDef3.thingSetMakerTags != null && thingDef3.thingSetMakerTags.Contains(this.thingSetMakerTagsToAllow[num2]))
                        {
                            this.SetAllow(thingDef3, true);
                        }
                    }
                }
            }
            if (this.thingSetMakerTagsToDisallow != null)
            {
                for (int num4 = 0; num4 < this.thingSetMakerTagsToDisallow.Count; num4++)
                {
                    List <ThingDef> allDefsListForReading4 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num5 = 0; num5 < allDefsListForReading4.Count; num5++)
                    {
                        ThingDef thingDef4 = allDefsListForReading4[num5];
                        if (thingDef4.thingSetMakerTags != null && thingDef4.thingSetMakerTags.Contains(this.thingSetMakerTagsToDisallow[num4]))
                        {
                            this.SetAllow(thingDef4, false);
                        }
                    }
                }
            }
            if (this.disallowedCategories != null)
            {
                for (int num6 = 0; num6 < this.disallowedCategories.Count; num6++)
                {
                    ThingCategoryDef named2 = DefDatabase <ThingCategoryDef> .GetNamed(this.disallowedCategories[num6], true);

                    if (named2 != null)
                    {
                        this.SetAllow(named2, false, null, null);
                    }
                }
            }
            if (this.specialFiltersToAllow != null)
            {
                for (int num7 = 0; num7 < this.specialFiltersToAllow.Count; num7++)
                {
                    this.SetAllow(SpecialThingFilterDef.Named(this.specialFiltersToAllow[num7]), true);
                }
            }
            if (this.specialFiltersToDisallow != null)
            {
                for (int num8 = 0; num8 < this.specialFiltersToDisallow.Count; num8++)
                {
                    this.SetAllow(SpecialThingFilterDef.Named(this.specialFiltersToDisallow[num8]), false);
                }
            }
            if (this.stuffCategoriesToAllow != null)
            {
                for (int num9 = 0; num9 < this.stuffCategoriesToAllow.Count; num9++)
                {
                    this.SetAllow(this.stuffCategoriesToAllow[num9], true);
                }
            }
            if (this.allowAllWhoCanMake != null)
            {
                for (int num10 = 0; num10 < this.allowAllWhoCanMake.Count; num10++)
                {
                    this.SetAllowAllWhoCanMake(this.allowAllWhoCanMake[num10]);
                }
            }
            if (this.disallowWorsePreferability != FoodPreferability.Undefined)
            {
                List <ThingDef> allDefsListForReading5 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num11 = 0; num11 < allDefsListForReading5.Count; num11++)
                {
                    ThingDef thingDef5 = allDefsListForReading5[num11];
                    if (thingDef5.IsIngestible && thingDef5.ingestible.preferability != FoodPreferability.Undefined && thingDef5.ingestible.preferability < this.disallowWorsePreferability)
                    {
                        this.SetAllow(thingDef5, false);
                    }
                }
            }
            if (this.disallowInedibleByHuman)
            {
                List <ThingDef> allDefsListForReading6 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num12 = 0; num12 < allDefsListForReading6.Count; num12++)
                {
                    ThingDef thingDef6 = allDefsListForReading6[num12];
                    if (thingDef6.IsIngestible && !ThingDefOf.Human.race.CanEverEat(thingDef6))
                    {
                        this.SetAllow(thingDef6, false);
                    }
                }
            }
            if (this.allowWithComp != null)
            {
                List <ThingDef> allDefsListForReading7 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num13 = 0; num13 < allDefsListForReading7.Count; num13++)
                {
                    ThingDef thingDef7 = allDefsListForReading7[num13];
                    if (thingDef7.HasComp(this.allowWithComp))
                    {
                        this.SetAllow(thingDef7, true);
                    }
                }
            }
            if (this.disallowWithComp != null)
            {
                List <ThingDef> allDefsListForReading8 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num14 = 0; num14 < allDefsListForReading8.Count; num14++)
                {
                    ThingDef thingDef8 = allDefsListForReading8[num14];
                    if (thingDef8.HasComp(this.disallowWithComp))
                    {
                        this.SetAllow(thingDef8, false);
                    }
                }
            }
            if (this.disallowCheaperThan != -3.40282347E+38f)
            {
                List <ThingDef> list = new List <ThingDef>();
                foreach (ThingDef thingDef9 in this.allowedDefs)
                {
                    if (thingDef9.BaseMarketValue < this.disallowCheaperThan)
                    {
                        list.Add(thingDef9);
                    }
                }
                for (int num15 = 0; num15 < list.Count; num15++)
                {
                    this.SetAllow(list[num15], false);
                }
            }
            if (this.disallowedThingDefs != null)
            {
                for (int num16 = 0; num16 < this.disallowedThingDefs.Count; num16++)
                {
                    if (this.disallowedThingDefs[num16] != null)
                    {
                        this.SetAllow(this.disallowedThingDefs[num16], false);
                    }
                    else
                    {
                        Log.Error("ThingFilter could not find excepted thing def named " + this.disallowedThingDefs[num16], false);
                    }
                }
            }
            this.RecalculateDisplayRootCategory();
        }
 private bool Visible(SpecialThingFilterDef filter)
 {
     return(Visible_NewTemp(filter, new TreeNode_ThingCategory(ThingCategoryDefOf.Root)));
 }
        public void ResolveReferences()
        {
            for (int i = 0; i < DefDatabase <SpecialThingFilterDef> .AllDefsListForReading.Count; i++)
            {
                SpecialThingFilterDef specialThingFilterDef = DefDatabase <SpecialThingFilterDef> .AllDefsListForReading[i];
                if (!specialThingFilterDef.allowedByDefault)
                {
                    this.SetAllow(specialThingFilterDef, false);
                }
            }
            if (this.thingDefs != null)
            {
                for (int j = 0; j < this.thingDefs.Count; j++)
                {
                    if (this.thingDefs[j] != null)
                    {
                        this.SetAllow(this.thingDefs[j], true);
                    }
                    else
                    {
                        Log.Error("ThingFilter could not find thing def named " + this.thingDefs[j]);
                    }
                }
            }
            if (this.categories != null)
            {
                for (int k = 0; k < this.categories.Count; k++)
                {
                    ThingCategoryDef named = DefDatabase <ThingCategoryDef> .GetNamed(this.categories[k], true);

                    if (named != null)
                    {
                        this.SetAllow(named, true, null, null);
                    }
                }
            }
            if (this.exceptedThingDefs != null)
            {
                for (int l = 0; l < this.exceptedThingDefs.Count; l++)
                {
                    if (this.exceptedThingDefs[l] != null)
                    {
                        this.SetAllow(this.exceptedThingDefs[l], false);
                    }
                    else
                    {
                        Log.Error("ThingFilter could not find excepted thing def named " + this.exceptedThingDefs[l]);
                    }
                }
            }
            if (this.exceptedCategories != null)
            {
                for (int m = 0; m < this.exceptedCategories.Count; m++)
                {
                    ThingCategoryDef named2 = DefDatabase <ThingCategoryDef> .GetNamed(this.exceptedCategories[m], true);

                    if (named2 != null)
                    {
                        this.SetAllow(named2, false, null, null);
                    }
                }
            }
            if (this.specialFiltersToAllow != null)
            {
                for (int n = 0; n < this.specialFiltersToAllow.Count; n++)
                {
                    this.SetAllow(SpecialThingFilterDef.Named(this.specialFiltersToAllow[n]), true);
                }
            }
            if (this.specialFiltersToDisallow != null)
            {
                for (int num = 0; num < this.specialFiltersToDisallow.Count; num++)
                {
                    this.SetAllow(SpecialThingFilterDef.Named(this.specialFiltersToDisallow[num]), false);
                }
            }
            if (this.stuffCategoriesToAllow != null)
            {
                for (int num2 = 0; num2 < this.stuffCategoriesToAllow.Count; num2++)
                {
                    this.SetAllow(this.stuffCategoriesToAllow[num2], true);
                }
            }
            if (this.allowAllWhoCanMake != null)
            {
                for (int num3 = 0; num3 < this.allowAllWhoCanMake.Count; num3++)
                {
                    this.SetAllowAllWhoCanMake(this.allowAllWhoCanMake[num3]);
                }
            }
            this.RecalculateDisplayRootCategory();
        }
示例#14
0
        public void ResolveReferences()
        {
            for (int i = 0; i < DefDatabase <SpecialThingFilterDef> .AllDefsListForReading.Count; i++)
            {
                SpecialThingFilterDef specialThingFilterDef = DefDatabase <SpecialThingFilterDef> .AllDefsListForReading[i];
                if (!specialThingFilterDef.allowedByDefault)
                {
                    SetAllow(specialThingFilterDef, allow: false);
                }
            }
            if (thingDefs != null)
            {
                for (int j = 0; j < thingDefs.Count; j++)
                {
                    if (thingDefs[j] != null)
                    {
                        SetAllow(thingDefs[j], allow: true);
                    }
                    else
                    {
                        Log.Error("ThingFilter could not find thing def named " + thingDefs[j]);
                    }
                }
            }
            if (categories != null)
            {
                for (int k = 0; k < categories.Count; k++)
                {
                    ThingCategoryDef named = DefDatabase <ThingCategoryDef> .GetNamed(categories[k]);

                    if (named != null)
                    {
                        SetAllow(named, allow: true);
                    }
                }
            }
            if (tradeTagsToAllow != null)
            {
                for (int l = 0; l < tradeTagsToAllow.Count; l++)
                {
                    List <ThingDef> allDefsListForReading = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int m = 0; m < allDefsListForReading.Count; m++)
                    {
                        ThingDef thingDef = allDefsListForReading[m];
                        if (thingDef.tradeTags != null && thingDef.tradeTags.Contains(tradeTagsToAllow[l]))
                        {
                            SetAllow(thingDef, allow: true);
                        }
                    }
                }
            }
            if (tradeTagsToDisallow != null)
            {
                for (int n = 0; n < tradeTagsToDisallow.Count; n++)
                {
                    List <ThingDef> allDefsListForReading2 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num = 0; num < allDefsListForReading2.Count; num++)
                    {
                        ThingDef thingDef2 = allDefsListForReading2[num];
                        if (thingDef2.tradeTags != null && thingDef2.tradeTags.Contains(tradeTagsToDisallow[n]))
                        {
                            SetAllow(thingDef2, allow: false);
                        }
                    }
                }
            }
            if (thingSetMakerTagsToAllow != null)
            {
                for (int num2 = 0; num2 < thingSetMakerTagsToAllow.Count; num2++)
                {
                    List <ThingDef> allDefsListForReading3 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num3 = 0; num3 < allDefsListForReading3.Count; num3++)
                    {
                        ThingDef thingDef3 = allDefsListForReading3[num3];
                        if (thingDef3.thingSetMakerTags != null && thingDef3.thingSetMakerTags.Contains(thingSetMakerTagsToAllow[num2]))
                        {
                            SetAllow(thingDef3, allow: true);
                        }
                    }
                }
            }
            if (thingSetMakerTagsToDisallow != null)
            {
                for (int num4 = 0; num4 < thingSetMakerTagsToDisallow.Count; num4++)
                {
                    List <ThingDef> allDefsListForReading4 = DefDatabase <ThingDef> .AllDefsListForReading;
                    for (int num5 = 0; num5 < allDefsListForReading4.Count; num5++)
                    {
                        ThingDef thingDef4 = allDefsListForReading4[num5];
                        if (thingDef4.thingSetMakerTags != null && thingDef4.thingSetMakerTags.Contains(thingSetMakerTagsToDisallow[num4]))
                        {
                            SetAllow(thingDef4, allow: false);
                        }
                    }
                }
            }
            if (disallowedCategories != null)
            {
                for (int num6 = 0; num6 < disallowedCategories.Count; num6++)
                {
                    ThingCategoryDef named2 = DefDatabase <ThingCategoryDef> .GetNamed(disallowedCategories[num6]);

                    if (named2 != null)
                    {
                        SetAllow(named2, allow: false);
                    }
                }
            }
            if (specialFiltersToAllow != null)
            {
                for (int num7 = 0; num7 < specialFiltersToAllow.Count; num7++)
                {
                    SetAllow(SpecialThingFilterDef.Named(specialFiltersToAllow[num7]), allow: true);
                }
            }
            if (specialFiltersToDisallow != null)
            {
                for (int num8 = 0; num8 < specialFiltersToDisallow.Count; num8++)
                {
                    SetAllow(SpecialThingFilterDef.Named(specialFiltersToDisallow[num8]), allow: false);
                }
            }
            if (stuffCategoriesToAllow != null)
            {
                for (int num9 = 0; num9 < stuffCategoriesToAllow.Count; num9++)
                {
                    SetAllow(stuffCategoriesToAllow[num9], allow: true);
                }
            }
            if (allowAllWhoCanMake != null)
            {
                for (int num10 = 0; num10 < allowAllWhoCanMake.Count; num10++)
                {
                    SetAllowAllWhoCanMake(allowAllWhoCanMake[num10]);
                }
            }
            if (disallowWorsePreferability != 0)
            {
                List <ThingDef> allDefsListForReading5 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num11 = 0; num11 < allDefsListForReading5.Count; num11++)
                {
                    ThingDef thingDef5 = allDefsListForReading5[num11];
                    if (thingDef5.IsIngestible && thingDef5.ingestible.preferability != 0 && (int)thingDef5.ingestible.preferability < (int)disallowWorsePreferability)
                    {
                        SetAllow(thingDef5, allow: false);
                    }
                }
            }
            if (disallowInedibleByHuman)
            {
                List <ThingDef> allDefsListForReading6 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num12 = 0; num12 < allDefsListForReading6.Count; num12++)
                {
                    ThingDef thingDef6 = allDefsListForReading6[num12];
                    if (thingDef6.IsIngestible && !ThingDefOf.Human.race.CanEverEat(thingDef6))
                    {
                        SetAllow(thingDef6, allow: false);
                    }
                }
            }
            if (allowWithComp != null)
            {
                List <ThingDef> allDefsListForReading7 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num13 = 0; num13 < allDefsListForReading7.Count; num13++)
                {
                    ThingDef thingDef7 = allDefsListForReading7[num13];
                    if (thingDef7.HasComp(allowWithComp))
                    {
                        SetAllow(thingDef7, allow: true);
                    }
                }
            }
            if (disallowWithComp != null)
            {
                List <ThingDef> allDefsListForReading8 = DefDatabase <ThingDef> .AllDefsListForReading;
                for (int num14 = 0; num14 < allDefsListForReading8.Count; num14++)
                {
                    ThingDef thingDef8 = allDefsListForReading8[num14];
                    if (thingDef8.HasComp(disallowWithComp))
                    {
                        SetAllow(thingDef8, allow: false);
                    }
                }
            }
            if (disallowCheaperThan != float.MinValue)
            {
                List <ThingDef> list = new List <ThingDef>();
                foreach (ThingDef allowedDef in allowedDefs)
                {
                    if (allowedDef.BaseMarketValue < disallowCheaperThan)
                    {
                        list.Add(allowedDef);
                    }
                }
                for (int num15 = 0; num15 < list.Count; num15++)
                {
                    SetAllow(list[num15], allow: false);
                }
            }
            if (disallowedThingDefs == null)
            {
                return;
            }
            for (int num16 = 0; num16 < disallowedThingDefs.Count; num16++)
            {
                if (disallowedThingDefs[num16] != null)
                {
                    SetAllow(disallowedThingDefs[num16], allow: false);
                }
                else
                {
                    Log.Error("ThingFilter could not find excepted thing def named " + disallowedThingDefs[num16]);
                }
            }
        }