private void RebalanceFetches()
    {
        TreeFilterable component = GetComponent <TreeFilterable>();

        Tag[]     tags          = component.GetTags();
        ChoreType creatureFetch = Db.Get().ChoreTypes.CreatureFetch;
        Storage   component2    = GetComponent <Storage>();
        int       num           = creatureLimit - storedCreatureCount;
        int       count         = fetches.Count;
        int       num2          = 0;
        int       num3          = 0;
        int       num4          = 0;
        int       num5          = 0;

        for (int num6 = fetches.Count - 1; num6 >= 0; num6--)
        {
            if (fetches[num6].IsComplete())
            {
                fetches.RemoveAt(num6);
                num2++;
            }
        }
        int num7 = 0;

        for (int i = 0; i < fetches.Count; i++)
        {
            if (!fetches[i].InProgress)
            {
                num7++;
            }
        }
        if (num7 == 0 && fetches.Count < num)
        {
            FetchOrder2 fetchOrder = new FetchOrder2(creatureFetch, tags, requiredFetchTags, null, component2, 1f, FetchOrder2.OperationalRequirement.Operational, 0);
            fetchOrder.Submit(OnFetchComplete, false, OnFetchBegun);
            fetches.Add(fetchOrder);
            num3++;
        }
        int num8 = fetches.Count - num;
        int num9 = fetches.Count - 1;

        while (num9 >= 0 && num8 > 0)
        {
            if (!fetches[num9].InProgress)
            {
                fetches[num9].Cancel("fewer creatures in room");
                fetches.RemoveAt(num9);
                num8--;
                num4++;
            }
            num9--;
        }
        while (num8 > 0 && fetches.Count > 0)
        {
            fetches[fetches.Count - 1].Cancel("fewer creatures in room");
            fetches.RemoveAt(fetches.Count - 1);
            num8--;
            num5++;
        }
    }
 private void OnOnlyFetchMarkedItemsSettingChanged(object data)
 {
     OnFilterChanged(filterable.GetTags());
 }