Ejemplo n.º 1
0
        /// <summary>
        /// Called when the BlockWorld behaviour is enabled.
        /// </summary>
        private void OnEnable()
        {
            if (m_WorldContainer != null)
            {
                return; // Already enabled
            }
            var chunkSize = new GridSize(4);

            var world     = new World(chunkSize);
            var blockList = new BlockTypeList();
            var remesh    = new RemeshHandler();
            var database  = new WorldDatabase("/home/thedudefromci/Bones3/TestWorld");

            remesh.AddDistributor(new StandardDistributor());

            m_WorldContainer = new WorldContainer(world, remesh, blockList, database);
            m_WorldContainer.BlockContainerProvider.OnBlockContainerCreated   += OnChunkCreated;
            m_WorldContainer.BlockContainerProvider.OnBlockContainerDestroyed += OnChunkDestroyed;
            m_WorldContainer.RemeshHandler.OnRemeshFinish += OnRemeshFinished;

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.EditorApplication.update += Update;
            }
#endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new block type preview object.
        /// </summary>
        /// <param name="blockTypes">The block type list to reference when rendering.</param>
        public BlockTypesPreview(BlockTypeList blockTypes)
        {
            this.blockTypes = blockTypes;

            EditorUtility.SetCameraAnimateMaterials(previewUtility.camera, true);

            remeshHandler = new RemeshHandler();
            remeshHandler.AddDistributor(new StandardDistributor());
            remeshHandler.OnRemeshFinish += OnRemeshFinish;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new world container for the given world.
        /// </summary>
        /// <param name="world">The world.</param>
        internal WorldContainer(World world, BlockWorld blockWorld)
        {
            World        = world;
            m_BlockWorld = blockWorld;

            ChunkLoader = new AsyncChunkLoader();
            ChunkLoader.AddChunkLoadHandler(new WorldLoader(world));

            RemeshHandler = new RemeshHandler(blockWorld);
            RemeshHandler.AddDistributor(new StandardDistributor(m_BlockWorld));
        }
Ejemplo n.º 4
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));
        }