Ejemplo n.º 1
0
        public void AddChunkRenderComponent(Entity chunkRenderEntity, Entity chunkEntity, ref Chunk chunk, int materialID, int skeletonID)// byte buildState = 0)
        {
            ChunkRenderer chunkRender = new ChunkRenderer {
            };

            chunkRender.chunk      = chunkEntity;
            chunkRender.materialID = (byte)materialID;
            chunkRender.SetMetaData(voxelSpawnSystem.meta, voxelSpawnSystem.voxelIDs);
            //, ChunkSpawnSystem.maxCacheVerts, ChunkSpawnSystem.maxCacheTriangles);
            chunkRender.Value = chunk.Value;

            /*if (skeletonID != 0)
             * {
             *  chunkRender.hasWeights = 1;
             *  chunkRender.InitializeBoneWeights(ChunkSpawnSystem.maxCacheVerts,
             *      worldSpawnSystem.skeletonsMeta[chunk.worldID].data.datas);
             * }*/
            if (World.EntityManager.HasComponent <ChunkRenderer>(chunkRenderEntity))
            {
                World.EntityManager.SetComponentData(chunkRenderEntity, chunkRender);
            }
            else
            {
                World.EntityManager.AddComponentData(chunkRenderEntity, chunkRender);
            }
            ChunkSides sides = new ChunkSides();

            sides.Init(chunk.Value.voxelDimensions);
            World.EntityManager.SetComponentData(chunkRenderEntity, sides);

            ChunkMesh chunkMesh = new ChunkMesh();

            chunkMesh.Init(chunk.Value.voxelDimensions);
            World.EntityManager.SetComponentData(chunkRenderEntity, chunkMesh);
        }
Ejemplo n.º 2
0
 public static void DestroyChunkRender(EntityManager EntityManager, Entity e)
 {
     if (EntityManager.Exists(e))
     {
         if (EntityManager.HasComponent <ChunkRenderer>(e))
         {
             ChunkRenderer chunkRenderer = EntityManager.GetComponentData <ChunkRenderer>(e);
             chunkRenderer.Dispose();
         }
         if (EntityManager.HasComponent <ChunkSides>(e))
         {
             ChunkSides chunkSides = EntityManager.GetComponentData <ChunkSides>(e);
             chunkSides.Dispose();
         }
         if (EntityManager.HasComponent <RenderMesh>(e))
         {
             RenderMesh renderer = EntityManager.GetSharedComponentData <RenderMesh>(e);
             GameObject.Destroy(renderer.mesh);
         }
         else if (EntityManager.HasComponent <ChunkMesh>(e))
         {
             var renderer = EntityManager.GetSharedComponentData <ChunkMeshLink>(e);
             GameObject.Destroy(renderer.mesh);
         }
         EntityManager.DestroyEntity(e);
     }
 }