Beispiel #1
0
    private IEnumerator UpdateCoroutine()
    {
label_1:
        do
        {
            yield return((object)CoroutineEx.waitForEndOfFrame);
        }while (Application.isReceiving != null || Application.isLoading != null || (ColliderGrid.Paused || this.grid == null));
        this.ResetTimeout();
        for (int x = 0; x < this.grid.CellCount; ++x)
        {
            for (int z = 0; z < this.grid.CellCount; ++z)
            {
                ColliderCell colliderCell = this.grid.get_Item(x, z);
                if (colliderCell.NeedsRefresh())
                {
                    IEnumerator enumerator = colliderCell.RefreshAsync();
                    while (enumerator.MoveNext())
                    {
                        yield return(enumerator.Current);
                    }
                    enumerator = (IEnumerator)null;
                }
                if (this.NeedsTimeout)
                {
                    yield return((object)CoroutineEx.waitForEndOfFrame);

                    this.ResetTimeout();
                }
            }
        }
        goto label_1;
    }
Beispiel #2
0
    private ColliderGroup CreateColliderGroup(ColliderGrid grid, ColliderCell cell, ColliderKey key)
    {
        ColliderGroup colliderGroup = Facepunch.Pool.Get <ColliderGroup>();

        colliderGroup.Initialize(grid, cell, key);
        return(colliderGroup);
    }
Beispiel #3
0
    private ColliderGroup CreateColliderGroup(
        ColliderGrid grid,
        ColliderCell cell,
        ColliderKey key)
    {
        M0 m0 = Pool.Get <ColliderGroup>();

        ((ColliderGroup)m0).Initialize(grid, cell, key);
        return((ColliderGroup)m0);
    }
Beispiel #4
0
 public void EnterPool()
 {
     this.Invalidated  = false;
     this.NeedsRefresh = false;
     this.Processing   = false;
     this.Preserving   = false;
     this.Colliders.Clear();
     this.TempColliders.Clear();
     this.Batches.Clear();
     this.TempBatches.Clear();
     this.TempInstances.Clear();
     this.grid = null;
     this.cell = null;
     this.key  = new ColliderKey();
 }
Beispiel #5
0
    void SpawnColliders()
    {
        GameObject[] gameObjArr = new GameObject[PointList.Count];
        int          count      = 0;

        foreach (var point in PointList)
        {
            GameObject cell = Instantiate(_gridCellObject.gameObject, _rootObject.transform);
            gameObjArr[count]            = cell;
            cell.transform.localPosition = point;

            ColliderCell cellCollider = cell.GetComponent <ColliderCell>();
            cellCollider.cellCollider.size = _gridCellSize;
            _cellList.Add(cell.GetComponent <ColliderCell>());
            count++;
        }
    }
    public void Add()
    {
        if (this.batchGroup != null)
        {
            this.Remove();
        }
        if (!Batching.colliders)
        {
            return;
        }
        if (this.BatchTransform == null)
        {
            return;
        }
        if (this.BatchCollider == null)
        {
            return;
        }
        if (this.BatchCollider.sharedMesh.subMeshCount > Batching.collider_submeshes)
        {
            return;
        }
        if (this.BatchCollider.sharedMesh.vertexCount > Batching.collider_vertices)
        {
            return;
        }
        ColliderCell item = SingletonComponent <ColliderGrid> .Instance[this.BatchTransform.position];

        this.batchGroup = item.FindBatchGroup(this);
        this.batchGroup.Add(this);
        this.batchInstance.mesh      = this.BatchCollider.sharedMesh;
        this.batchInstance.position  = this.BatchTransform.position;
        this.batchInstance.rotation  = this.BatchTransform.rotation;
        this.batchInstance.scale     = this.BatchTransform.lossyScale;
        this.batchInstance.transform = this.BatchTransform;
        this.batchInstance.rigidbody = this.BatchRigidbody;
        this.batchInstance.collider  = this.BatchCollider;
        this.batchInstance.bounds    = new OBB(this.BatchTransform, this.BatchCollider.sharedMesh.bounds);
        if (Rust.Application.isLoading)
        {
            this.BatchCollider.enabled = false;
        }
    }
    private IEnumerator UpdateCoroutine()
    {
        ColliderGrid colliderGrid = null;

        while (true)
        {
            yield return(CoroutineEx.waitForEndOfFrame);

            if (!Rust.Application.isReceiving && !Rust.Application.isLoading && !ColliderGrid.Paused && colliderGrid.grid != null)
            {
                colliderGrid.ResetTimeout();
                for (int i = 0; i < colliderGrid.grid.CellCount; i++)
                {
                    for (int j = 0; j < colliderGrid.grid.CellCount; j++)
                    {
                        ColliderCell item = colliderGrid.grid[i, j];
                        if (item.NeedsRefresh())
                        {
                            IEnumerator enumerator = item.RefreshAsync();
                            while (enumerator.MoveNext())
                            {
                                yield return(enumerator.Current);
                            }
                            enumerator = null;
                        }
                        if (colliderGrid.NeedsTimeout)
                        {
                            yield return(CoroutineEx.waitForEndOfFrame);

                            colliderGrid.ResetTimeout();
                        }
                    }
                }
            }
        }
    }
Beispiel #8
0
 public void Initialize(ColliderGrid grid, ColliderCell cell, ColliderKey key)
 {
     this.grid = grid;
     this.cell = cell;
     this.key  = key;
 }
Beispiel #9
0
    public IEnumerator RefreshAsync()
    {
        ColliderCell colliderCell = null;
        int          num;
        IEnumerator  enumerator;

        colliderCell.interrupt = false;
        BufferList <ColliderGroup> values = colliderCell.batches.Values;

        for (int i = 0; i < values.Count; i++)
        {
            ColliderGroup item = values[i];
            if (item.Count > 0)
            {
                item.Start();
            }
        }
        for (num = 0; num < values.Count && !colliderCell.interrupt; num++)
        {
            ColliderGroup colliderGroup = values[num];
            if (colliderGroup.Processing)
            {
                if (!Batching.collider_threading)
                {
                    colliderGroup.UpdateData();
                    if (colliderCell.grid.NeedsTimeout)
                    {
                        yield return(CoroutineEx.waitForEndOfFrame);

                        colliderCell.grid.ResetTimeout();
                    }
                }
                else
                {
                    enumerator = colliderGroup.UpdateDataAsync();
                    while (enumerator.MoveNext())
                    {
                        yield return(enumerator.Current);
                    }
                    colliderCell.grid.ResetTimeout();
                    enumerator = null;
                }
            }
        }
        for (num = 0; num < values.Count && !colliderCell.interrupt; num++)
        {
            ColliderGroup item1 = values[num];
            if (item1.Processing)
            {
                item1.CreateBatches();
                if (colliderCell.grid.NeedsTimeout)
                {
                    yield return(CoroutineEx.waitForEndOfFrame);

                    colliderCell.grid.ResetTimeout();
                }
            }
        }
        for (num = 0; num < values.Count && !colliderCell.interrupt; num++)
        {
            ColliderGroup colliderGroup1 = values[num];
            if (colliderGroup1.Processing)
            {
                if (!Batching.collider_threading)
                {
                    colliderGroup1.RefreshBatches();
                    if (colliderCell.grid.NeedsTimeout)
                    {
                        yield return(CoroutineEx.waitForEndOfFrame);

                        colliderCell.grid.ResetTimeout();
                    }
                }
                else
                {
                    enumerator = colliderGroup1.RefreshBatchesAsync();
                    while (enumerator.MoveNext())
                    {
                        yield return(enumerator.Current);
                    }
                    colliderCell.grid.ResetTimeout();
                    enumerator = null;
                }
            }
        }
        for (num = 0; num < values.Count && !colliderCell.interrupt; num++)
        {
            ColliderGroup item2 = values[num];
            if (item2.Processing)
            {
                for (int k = 0; k < item2.TempBatches.Count && !colliderCell.interrupt; k++)
                {
                    item2.TempBatches[k].Apply();
                    if (colliderCell.grid.NeedsTimeout)
                    {
                        yield return(CoroutineEx.waitForEndOfFrame);

                        colliderCell.grid.ResetTimeout();
                    }
                }
            }
            item2 = null;
        }
        for (int l = 0; l < values.Count && !colliderCell.interrupt; l++)
        {
            ColliderGroup colliderGroup2 = values[l];
            if (colliderGroup2.Processing)
            {
                colliderGroup2.DisplayBatches();
            }
        }
        for (int m = 0; m < values.Count; m++)
        {
            ColliderGroup item3 = values[m];
            if (item3.Processing || item3.Preserving)
            {
                item3.End();
            }
            else if (item3.Count == 0 && !colliderCell.interrupt)
            {
                item3.Clear();
                colliderCell.DestroyColliderGroup(ref item3);
                int num1 = m;
                m = num1 - 1;
                colliderCell.batches.RemoveAt(num1);
            }
        }
    }