Пример #1
0
        /// <summary>
        /// Creates a new world container for the given world.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="world">The world.</param>
        internal WorldContainer(WorldProperties worldProperties)
        {
            World     = new World(worldProperties.ChunkSize, worldProperties.ID);
            BlockList = new ServerBlockList();

            EventQueue = new EventQueue();

            ChunkLoader = new ChunkLoader();
            ChunkLoader.AddChunkLoadHandler(new WorldLoader(World.ID));
            ChunkLoader.AddChunkLoadHandler(worldProperties.WorldGenerator);

            WorldSaver = new WorldSaver(World.ID);

            RemeshHandler = new RemeshHandler();
            RemeshHandler.AddDistributor(new StandardDistributor(World.ChunkSize, BlockList));
        }
Пример #2
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);
        }