Ejemplo n.º 1
0
        /// <summary>
        /// Called when the world object is constructed to initialize data.
        /// </summary>
        protected void Awake()
        {
            var world = new World(ChunkSize, ID);

            m_WorldContainer = new WorldContainer(world, this);
            m_WorldSaver     = new WorldSaver(world);

            m_ChunkCreator     = new ChunkCreator(this);
            m_ChunkMeshBuilder = new ChunkMeshBuilder(this);
        }
Ejemplo n.º 2
0
        private void OnRemeshFinish(RemeshFinishEvent ev)
        {
            var report = ev.Report;
            var visual = report.VisualMesh;

            var meshBuilder = new ChunkMeshBuilder();

            meshBuilder.UpdateMesh(visual, mesh);

            materials = new Material[visual.TotalLayers];
            for (int i = 0; i < materials.Length; i++)
            {
                materials[i] = null;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new Unity world builder object.
        /// </summary>
        /// <param name="transform">The transform to add chunk gameobjects to.</param>
        /// <param name="blockList">The block list to read from.</param>
        /// <param name="chunkSize">The chunk size of the world.</param>
        /// <param name="id">The ID value of the world.</param>
        internal UnityWorldBuilder(Transform transform, BlockListManager blockList, WorldProperties worldProperties)
        {
            ChunkSize = worldProperties.ChunkSize;

            var container = new WorldContainer(worldProperties);

            container.EventQueue.OnWorldEvent += OnBlockWorldEvent;

            {
                // TODO TEMP CODE REMOVE THIS
                container.BlockList.UpdateBlockType(CreateBlock(2, "Grass", 0));
                container.BlockList.UpdateBlockType(CreateBlock(3, "SideDirt", 1));
                container.BlockList.UpdateBlockType(CreateBlock(4, "Dirt", 2));
            }

            m_ServerThread = new ServerThread(container);

            m_ChunkCreator     = new ChunkCreator(transform, ChunkSize);
            m_ChunkMeshBuilder = new ChunkMeshBuilder(blockList);
        }