/// <summary>
        /// Create a new level
        /// </summary>
        /// <param name="seed"></param>
        /// <param name="chunkBounds">the max x y and z chunk sizes of the world</param>
        Level(
            Coordinate chunkBounds,
            IVoxelSource voxelSource,
            IVoxelMeshGenerator meshGenerator,
            IChunkResolutionAperture[] resolutionApertures
            )
        {
            this.chunkBounds         = chunkBounds;
            this.voxelSource         = voxelSource;
            this.meshGenerator       = meshGenerator;
            this.resolutionApertures = resolutionApertures;

            levelFociByID = new Dictionary <int, ILevelFocus>();

            /// subscribe all apetures to the terrain gen channel
            foreach (ChunkResolutionAperture resolutionAperture in resolutionApertures)
            {
                resolutionAperture.setLevel(this);
                World.EventSystem.subscribe(resolutionAperture, Evix.EventSystems.WorldEventSystem.Channels.LevelFocusUpdates);
            }
            // also subscribe this to the activation channel, in case an active chunk needs a mesh
            World.EventSystem.subscribe(resolutionApertures[(int)FocusResolutionLayers.Meshed], Evix.EventSystems.WorldEventSystem.Channels.ChunkActivationUpdates);

            seed = voxelSource.seed;
        }
예제 #2
0
 /// <summary>
 /// Construct
 /// </summary>
 /// <param name="chunkBounds"></param>
 /// <param name="voxelSource"></param>
 public HashedChunkLevel(
     Coordinate chunkBounds,
     IVoxelSource voxelSource,
     IVoxelMeshGenerator meshGenerator
     ) : base(chunkBounds, voxelSource, meshGenerator)
 {
     loadedChunks = new Dictionary <long, VoxelStorageType>(
         chunkBounds.x * chunkBounds.y * chunkBounds.z
         );
     chunkMeshes = new Dictionary <long, IMesh>(
         chunkBounds.x * chunkBounds.y * chunkBounds.z
         );
 }
        /// <summary>
        /// Create a new level using the given chunk storage type
        /// </summary>
        /// <typeparam name="ChunkDataStorageType"></typeparam>
        /// <param name="chunkBounds"></param>
        /// <param name="voxelSource"></param>
        /// <param name="meshGenerator"></param>
        /// <param name="chunkResolutionManagerTypes"></param>
        /// <returns></returns>
        public static Level Create <ChunkDataStorageType> (
            Coordinate chunkBounds,
            IVoxelSource voxelSource,
            IVoxelMeshGenerator meshGenerator,
            IChunkResolutionAperture[] chunkResolutionManagerTypes
            ) where ChunkDataStorageType : IChunkDataStorage
        {
            Level level = new Level(chunkBounds, voxelSource, meshGenerator, chunkResolutionManagerTypes);
            ChunkDataStorageType chunkDataStorage = (ChunkDataStorageType)Activator.CreateInstance(typeof(ChunkDataStorageType), level);

            level.chunkDataStorage = chunkDataStorage;

            return(level);
        }
예제 #4
0
 /// <summary>
 /// construct
 /// </summary>
 /// <param name="chunkBounds"></param>
 /// <param name="voxelSource"></param>
 public ColumnLoadedLevel(Coordinate chunkBounds, IVoxelSource voxelSource, IVoxelMeshGenerator meshGenerator) : base(chunkBounds, voxelSource, meshGenerator)
 {
     chunkLoadQueueManagerJob    = new JLoadChunks(this);
     chunkUnloadQueueManagerJob  = new JUnloadChunks(this);
     chunkMeshGenQueueManagerJob = new JGenerateChunkMeshes(this);
 }