Esempio n. 1
0
 public void OnChunkUnloaded(ChunkEventArgs args)
 {
     if (ChunkUnloaded != null)
     {
         ChunkUnloaded(this, args);
     }
 }
Esempio n. 2
0
 protected internal void OnChunkModified(ChunkEventArgs e)
 {
     if (ChunkModified != null)
     {
         ChunkModified(this, e);
     }
 }
Esempio n. 3
0
        private void SecureFile_ChunkUpdate(object sender, ChunkEventArgs e)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                chunkUpdate_progressBar.Value = Convert.ToInt32(e.CompletedChunks / (float)e.TotalChunks * 100F);
                double eta     = e.TotalTime.TotalMilliseconds / e.CompletedChunks * (e.TotalChunks - e.CompletedChunks) / 1000;
                eta_label.Text = $"ETA: {eta.ToString("0.0")} Seconds";

                LogMessage($"ChunkCompleted[{e.CompletedChunks}/{e.TotalChunks}]:" +
                           $" Size: {e.ChunkSize} bytes Time: {e.ChunkTime.TotalMilliseconds.ToString("0.0")}ms");
            }));
        }
Esempio n. 4
0
 private void Game_Client_ChunkLoaded(object sender, ChunkEventArgs e)
 {
     ChunkRenderer.Enqueue(e.Chunk);
     for (int i = 0; i < AdjacentCoordinates.Length; i++)
     {
         ReadOnlyChunk adjacent = Game.Client.World.GetChunk(
             AdjacentCoordinates[i] + e.Chunk.Coordinates);
         if (adjacent != null)
         {
             ChunkRenderer.Enqueue(adjacent);
         }
     }
 }
Esempio n. 5
0
    private void DrawBlockThreaded(object context)
    {
        ChunkEventArgs ch = (ChunkEventArgs)context;

        for (int xx = 0; xx < blockSize; xx++)
        {
            for (int yy = 0; yy < blockSize; yy++)
            {
                texturePixels[CoordToBroadIndex((ch.x * blockSize) + xx, (ch.y * blockSize) + yy)] = ch.block != null ? ch.block.BlockColor : Color.clear;
            }
        }
        IsDirty = true;
    }
Esempio n. 6
0
        private void OnChunkLoaded(object sender, ChunkEventArgs e)
        {
            var worldContexts = _world.WorldContexts;

            foreach (var worldContext in worldContexts)
            {
                var entityManager = worldContext.EntityManager;
                var entities      = entityManager.GetEntities(e.Position);
                foreach (var entity in entities)
                {
                    SpawnEntity(entity);
                }
            }
        }
Esempio n. 7
0
        private void SecureFile_ProcessCompleted(object sender, ChunkEventArgs e)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                if (deleteOrig_checkBox.Checked)
                {
                    start_button.Enabled = false;
                    _filePath            = "";
                }

                ChangeAllEnabled(true);
                LogMessage($"{e.Type.ToString()} Successfully Completed in {e.TotalTime.ToString("c")}");
            }));
        }
    private void OnChunkLoaded(object sender, ChunkEventArgs args)
    {
        for (int x = 0; x < Chunk.Size; x++)
        {
            for (int y = 0; y < Chunk.Size; y++)
            {
                Tile tileAt = args.Chunk.GetTileAt(x, y);
                if (tileAt == null)
                {
                    continue;
                }

                CreateTileGameObject(tileAt);
            }
        }
    }
    private void OnChunkUnloaded(object sender, ChunkEventArgs args)
    {
        for (int x = 0; x < Chunk.Size; x++)
        {
            for (int y = 0; y < Chunk.Size; y++)
            {
                Tile tileAt = args.Chunk.GetTileAt(x, y);
                if (tileAt == null || !tileGameObjectMap.ContainsKey(tileAt))
                {
                    continue;
                }

                ObjectPool.Destroy(tileGameObjectMap[tileAt]);
                tileGameObjectMap.Remove(tileAt);
            }
        }
    }
Esempio n. 10
0
    void OnChunkAddedEvent(object sender, EventArgs args)
    {
        if (null == VFVoxelTerrain.self)
        {
            return;
        }

        ChunkEventArgs chunkArgs = args as ChunkEventArgs;
        IntVector3     chunkPos  = new IntVector3(chunkArgs._pos.x, chunkArgs._pos.y, chunkArgs._pos.z);

        if (VoxelVolumes.ContainsKey(chunkPos))
        {
            foreach (KeyValuePair <IntVector3, VFVoxel> kv in VoxelVolumes[chunkPos])
            {
                VFVoxel voxel = VFVoxelTerrain.self.Voxels.SafeRead(kv.Key.x, kv.Key.y, kv.Key.z);
                voxel.Volume = kv.Value.Volume;
                voxel.Type   = kv.Value.Type;
                VFVoxelTerrain.self.AlterVoxelInBuild(kv.Key, voxel);
            }
        }
    }
Esempio n. 11
0
        private void OnChunkUnloaded(object sender, ChunkEventArgs e)
        {
            var toRemove = new HashSet <IEntity>();

            var unloadedChunk = e.Position;
            var worldContexts = _world.WorldContexts;

            foreach (var worldContext in worldContexts)
            {
                var entityManager = worldContext.EntityManager;
                foreach (var entity in entityManager)
                {
                    var chunkPosition = ChunkPosition.FromWorld(entity.Position);
                    if (unloadedChunk != chunkPosition)
                    {
                        continue;
                    }

                    toRemove.Add(entity);
                }
            }

            RemoveEntities(toRemove);
        }
Esempio n. 12
0
 private void Game_Client_ChunkModified(object sender, ChunkEventArgs e)
 {
     ChunkRenderer.Enqueue(e.Chunk, true);
 }
Esempio n. 13
0
 private void World_ChunkRenderReady(object sender, ChunkEventArgs e)
 {
     _renderer.AddChunk(e.Chunk);
 }
Esempio n. 14
0
    private void OnChunkReady(object sender, ChunkEventArgs args)
    {
        args.chunk.ChunkReady -= OnChunkReady;
        readyChunks.Add(args.chunk);

        if (readyChunks.Count == chunks.Count)
        {
            isLoadingChunks = false;
            StartCoroutine(HideAndDisplayChunks());
        }
    }