public static void GatherNearbyFetchChores(FetchChore root_chore, Precondition.Context context, int x, int y, int radius, List <Precondition.Context> succeeded_contexts, List <Precondition.Context> failed_contexts)
    {
        ListPool <ScenePartitionerEntry, FetchAreaChore> .PooledList pooledList = ListPool <ScenePartitionerEntry, FetchAreaChore> .Allocate();

        GameScenePartitioner.Instance.GatherEntries(x - radius, y - radius, radius * 2 + 1, radius * 2 + 1, GameScenePartitioner.Instance.fetchChoreLayer, pooledList);
        for (int i = 0; i < pooledList.Count; i++)
        {
            ScenePartitionerEntry scenePartitionerEntry = pooledList[i];
            FetchChore            fetchChore            = scenePartitionerEntry.obj as FetchChore;
            fetchChore.CollectChoresFromGlobalChoreProvider(context.consumerState, succeeded_contexts, failed_contexts, true);
        }
        pooledList.Recycle();
    }
    public bool FindNextChore(ref Chore.Precondition.Context out_context)
    {
        if (debug)
        {
            int num = 0;
            num++;
        }
        preconditionSnapshot.Clear();
        consumerState.Refresh();
        if (consumerState.hasSolidTransferArm)
        {
            Debug.Assert(stationaryReach > 0);
            CellOffset offset  = Grid.GetOffset(Grid.PosToCell(this));
            Extents    extents = new Extents(offset.x, offset.y, stationaryReach);
            ListPool <ScenePartitionerEntry, ChoreConsumer> .PooledList pooledList = ListPool <ScenePartitionerEntry, ChoreConsumer> .Allocate();

            GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.fetchChoreLayer, pooledList);
            foreach (ScenePartitionerEntry item in pooledList)
            {
                if (item.obj == null)
                {
                    DebugUtil.Assert(false, "FindNextChore found an entry that was null");
                }
                else
                {
                    FetchChore fetchChore = item.obj as FetchChore;
                    if (fetchChore == null)
                    {
                        DebugUtil.Assert(false, "FindNextChore found an entry that wasn't a FetchChore");
                    }
                    else if (fetchChore.target == null)
                    {
                        DebugUtil.Assert(false, "FindNextChore found an entry with a null target");
                    }
                    else if (fetchChore.isNull)
                    {
                        Debug.LogWarning("FindNextChore found an entry that isNull");
                    }
                    else
                    {
                        int cell = Grid.PosToCell(fetchChore.gameObject);
                        if (consumerState.solidTransferArm.IsCellReachable(cell))
                        {
                            fetchChore.CollectChoresFromGlobalChoreProvider(consumerState, preconditionSnapshot.succeededContexts, preconditionSnapshot.failedContexts, false);
                        }
                    }
                }
            }
            pooledList.Recycle();
        }
        else
        {
            for (int i = 0; i < providers.Count; i++)
            {
                ChoreProvider choreProvider = providers[i];
                choreProvider.CollectChores(consumerState, preconditionSnapshot.succeededContexts, preconditionSnapshot.failedContexts);
            }
        }
        preconditionSnapshot.succeededContexts.Sort();
        List <Chore.Precondition.Context> succeededContexts = preconditionSnapshot.succeededContexts;
        bool flag = ChooseChore(ref out_context, succeededContexts);

        if (flag)
        {
            preconditionSnapshot.CopyTo(lastSuccessfulPreconditionSnapshot);
        }
        return(flag);
    }