Beispiel #1
0
    public void Refresh()
    {
        this.interrupt = false;
        BufferList <ColliderGroup> values = this.batches.get_Values();

        for (int index = 0; index < values.get_Count(); ++index)
        {
            ColliderGroup grp = values.get_Item(index);
            if (!grp.Processing)
            {
                if (grp.Count > 0)
                {
                    grp.Start();
                    if (grp.Processing)
                    {
                        grp.UpdateData();
                        grp.CreateBatches();
                        grp.RefreshBatches();
                        grp.ApplyBatches();
                        grp.DisplayBatches();
                    }
                    grp.End();
                }
                else
                {
                    grp.Clear();
                    this.DestroyColliderGroup(ref grp);
                    this.batches.RemoveAt(index--);
                }
            }
        }
    }
Beispiel #2
0
    public int BatchedMeshCount()
    {
        int num = 0;
        BufferList <ColliderGroup> values = this.batches.get_Values();

        for (int index = 0; index < values.get_Count(); ++index)
        {
            num += values.get_Item(index).BatchedMeshCount();
        }
        return(num);
    }
Beispiel #3
0
    public bool NeedsRefresh()
    {
        BufferList <ColliderGroup> values = this.batches.get_Values();

        for (int index = 0; index < values.get_Count(); ++index)
        {
            if (values.get_Item(index).NeedsRefresh)
            {
                return(true);
            }
        }
        return(false);
    }
Beispiel #4
0
    public IEnumerator RefreshAsync()
    {
        this.interrupt = false;
        BufferList <ColliderGroup> batchGroups = this.batches.get_Values();

        for (int index = 0; index < batchGroups.get_Count(); ++index)
        {
            ColliderGroup colliderGroup = batchGroups.get_Item(index);
            if (colliderGroup.Count > 0)
            {
                colliderGroup.Start();
            }
        }
        int         i;
        IEnumerator enumerator;

        for (i = 0; i < batchGroups.get_Count() && !this.interrupt; ++i)
        {
            ColliderGroup colliderGroup = batchGroups.get_Item(i);
            if (colliderGroup.Processing)
            {
                if (Batching.collider_threading)
                {
                    enumerator = colliderGroup.UpdateDataAsync();
                    while (enumerator.MoveNext())
                    {
                        yield return(enumerator.Current);
                    }
                    this.grid.ResetTimeout();
                    enumerator = (IEnumerator)null;
                }
                else
                {
                    colliderGroup.UpdateData();
                    if (this.grid.NeedsTimeout)
                    {
                        yield return((object)CoroutineEx.waitForEndOfFrame);

                        this.grid.ResetTimeout();
                    }
                }
            }
        }
        for (i = 0; i < batchGroups.get_Count() && !this.interrupt; ++i)
        {
            ColliderGroup colliderGroup = batchGroups.get_Item(i);
            if (colliderGroup.Processing)
            {
                colliderGroup.CreateBatches();
                if (this.grid.NeedsTimeout)
                {
                    yield return((object)CoroutineEx.waitForEndOfFrame);

                    this.grid.ResetTimeout();
                }
            }
        }
        for (i = 0; i < batchGroups.get_Count() && !this.interrupt; ++i)
        {
            ColliderGroup colliderGroup = batchGroups.get_Item(i);
            if (colliderGroup.Processing)
            {
                if (Batching.collider_threading)
                {
                    enumerator = colliderGroup.RefreshBatchesAsync();
                    while (enumerator.MoveNext())
                    {
                        yield return(enumerator.Current);
                    }
                    this.grid.ResetTimeout();
                    enumerator = (IEnumerator)null;
                }
                else
                {
                    colliderGroup.RefreshBatches();
                    if (this.grid.NeedsTimeout)
                    {
                        yield return((object)CoroutineEx.waitForEndOfFrame);

                        this.grid.ResetTimeout();
                    }
                }
            }
        }
        for (i = 0; i < batchGroups.get_Count() && !this.interrupt; ++i)
        {
            ColliderGroup batchGroup = batchGroups.get_Item(i);
            if (batchGroup.Processing)
            {
                for (int j = 0; j < batchGroup.TempBatches.Count && !this.interrupt; ++j)
                {
                    batchGroup.TempBatches[j].Apply();
                    if (this.grid.NeedsTimeout)
                    {
                        yield return((object)CoroutineEx.waitForEndOfFrame);

                        this.grid.ResetTimeout();
                    }
                }
            }
            batchGroup = (ColliderGroup)null;
        }
        for (int index = 0; index < batchGroups.get_Count() && !this.interrupt; ++index)
        {
            ColliderGroup colliderGroup = batchGroups.get_Item(index);
            if (colliderGroup.Processing)
            {
                colliderGroup.DisplayBatches();
            }
        }
        for (int index = 0; index < batchGroups.get_Count(); ++index)
        {
            ColliderGroup grp = batchGroups.get_Item(index);
            if (grp.Processing || grp.Preserving)
            {
                grp.End();
            }
            else if (grp.Count == 0 && !this.interrupt)
            {
                grp.Clear();
                this.DestroyColliderGroup(ref grp);
                this.batches.RemoveAt(index--);
            }
        }
    }
 public void Cycle()
 {
     using (TimeWarning.New("StabilityCheckQueue", 0.1f))
         StabilityEntity.stabilityCheckQueue.RunQueue((double)Stability.stabilityqueue);
     using (TimeWarning.New("UpdateSurroundingsQueue", 0.1f))
         StabilityEntity.updateSurroundingsQueue.RunQueue((double)Stability.surroundingsqueue);
     using (TimeWarning.New("UpdateSkinQueue", 0.1f))
         BuildingBlock.updateSkinQueueServer.RunQueue(1.0);
     using (TimeWarning.New("BuildingDecayTick", 0.1f))
     {
         int num = 5;
         BufferList <BuildingManager.Building> values1 = this.buildingDictionary.get_Values();
         for (int tickBuildingIndex = this.decayTickBuildingIndex; tickBuildingIndex < values1.get_Count() && num > 0; ++tickBuildingIndex)
         {
             BufferList <DecayEntity> values2 = values1.get_Item(tickBuildingIndex).decayEntities.get_Values();
             for (int decayTickEntityIndex = this.decayTickEntityIndex; decayTickEntityIndex < values2.get_Count() && num > 0; ++decayTickEntityIndex)
             {
                 values2.get_Item(decayTickEntityIndex).DecayTick();
                 --num;
                 if (num <= 0)
                 {
                     this.decayTickBuildingIndex = tickBuildingIndex;
                     this.decayTickEntityIndex   = decayTickEntityIndex;
                 }
             }
             if (num > 0)
             {
                 this.decayTickEntityIndex = 0;
             }
         }
         if (num > 0)
         {
             this.decayTickBuildingIndex = 0;
         }
     }
     using (TimeWarning.New("WorldDecayTick", 0.1f))
     {
         int num = 5;
         BufferList <DecayEntity> values = this.decayEntities.get_Values();
         for (int decayTickWorldIndex = this.decayTickWorldIndex; decayTickWorldIndex < values.get_Count() && num > 0; ++decayTickWorldIndex)
         {
             values.get_Item(decayTickWorldIndex).DecayTick();
             --num;
             if (num <= 0)
             {
                 this.decayTickWorldIndex = decayTickWorldIndex;
             }
         }
         if (num > 0)
         {
             this.decayTickWorldIndex = 0;
         }
     }
     if (!ConVar.AI.nav_carve_use_building_optimization)
     {
         return;
     }
     using (TimeWarning.New("NavMeshCarving", 0.1f))
     {
         int ticks = 5;
         BufferList <BuildingManager.Building> values = this.buildingDictionary.get_Values();
         for (int tickBuildingIndex = this.navmeshCarveTickBuildingIndex; tickBuildingIndex < values.get_Count() && ticks > 0; ++tickBuildingIndex)
         {
             this.UpdateNavMeshCarver(values.get_Item(tickBuildingIndex), ref ticks, tickBuildingIndex);
         }
         if (ticks <= 0)
         {
             return;
         }
         this.navmeshCarveTickBuildingIndex = 0;
     }
 }