Esempio n. 1
0
 public void UpdateChunks()
 {
     while (true)
     {
         if (!DwarfTime.LastTime.IsPaused)
         {
             ChunkUpdateTimer.Update(DwarfTime.LastTime);
             if (ChunkUpdateTimer.HasTriggered)
             {
                 ChunkUpdate.RunUpdate(this);
             }
         }
         Thread.Sleep(100);
     }
 }
Esempio n. 2
0
        public void Update(DwarfTime gameTime, Camera camera, GraphicsDevice g)
        {
            generateChunksTimer.Update(gameTime);
            if (generateChunksTimer.HasTriggered)
            {
                if (ToGenerate.Count > 0)
                {
                    NeedsGenerationEvent.Set();
                }
            }

            foreach (var chunk in ChunkData.GetChunkEnumerator())
            {
                chunk.RecieveNewPrimitive(gameTime);
            }

            // Todo: This belongs up in world manager.
            Splasher.Splash(gameTime, Water.GetSplashQueue());
            Splasher.HandleTransfers(gameTime, Water.GetTransferQueue());

            if (!gameTime.IsPaused)
            {
                ChunkUpdate.RunUpdate(this);
            }

            List <VoxelChangeEvent> localList = null;

            lock (ChangedVoxels)
            {
                localList     = ChangedVoxels;
                ChangedVoxels = new List <VoxelChangeEvent>();
            }

            foreach (var voxel in localList)
            {
                var box     = voxel.Voxel.GetBoundingBox();
                var hashmap = new HashSet <IBoundedObject>(World.CollisionManager.EnumerateIntersectingObjects(box, CollisionManager.CollisionType.Both));

                foreach (var intersectingBody in hashmap)
                {
                    var listener = intersectingBody as NewVoxelListener;
                    if (listener != null)
                    {
                        listener.OnVoxelChanged(voxel);
                    }
                }
            }
        }