/// <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; }
/// <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); }
/// <summary> /// start test world /// </summary> public void initializeTestWorld(UnityLevelController levelController, IVoxelSource terrainSource) { players[0] = new Player(); Coordinate chunkBounds = (1000, 20, 1000); activeLevel = new ColumnLoadedLevel <VoxelDictionary>( chunkBounds, terrainSource, new MarchGenerator() ); Coordinate spawn = ( chunkBounds.x * Chunk.Diameter / 2, chunkBounds.y *Chunk.Diameter / 2, chunkBounds.z *Chunk.Diameter / 2 ); levelController.level = activeLevel; levelController.initialize(); listeningObservers.Add(levelController); activeLevel.initializeAround(spawn / Chunk.Diameter); }
/// <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); }
public void reset() { voxelSource = getConfiguredWaveSource(); levelController.clearAll(); World.Current.initializeTestWorld(levelController, voxelSource); }
// Start is called before the first frame update void Awake() { World.Current.worldController = this; voxelSource = getConfiguredPlainSource(); World.Current.initializeTestWorld(levelController, voxelSource); }