Exemple #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);
        }
        /// <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);
        }