public SkyIslandMapImagesPhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IAsyncFactory <ChunkOverheadKey, IDisposableValue <IReadOnlySkyIslandMapChunk> > chunkFactory, IKeyValueStore statsStore, SkyIslandMapImagesOptions imageOptions = null, GenerationOptions generationOptions = null) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(statsStore != null); var phaseIdentity = new GenerationPhaseIdentity(nameof(SkyIslandMapImagesPhase)); var chunkKeys = new ChunkOverheadKeyCollection(stageBounds); var chunkProcessor = new SkyIslandMapChunkImagesProcessor(stageBounds, statsStore, imageOptions); this.Phase = new ChunkedPhase <ChunkOverheadKey, IReadOnlySkyIslandMapChunk>( stageIdentity, phaseIdentity, chunkKeys, chunkFactory, chunkProcessor, generationOptions); }
public ChunkedPhase( IStageIdentity stageIdentity, IGenerationPhaseIdentity phaseIdentity, IReadOnlyLargeCollection <TKey> chunkKeys, IAsyncFactory <TKey, IDisposableValue <TChunk> > chunkFactory, IChunkProcessor <TChunk> chunkProcessor, GenerationOptions options = null) : base(options?.CancellationToken ?? DefaultCancellationToken) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(phaseIdentity != null); Contracts.Requires.That(chunkKeys != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(chunkProcessor != null); this.StageIdentity = stageIdentity; this.PhaseIdentity = phaseIdentity; this.chunkKeys = chunkKeys; this.chunkFactory = chunkFactory; this.chunkProcessor = chunkProcessor; this.Progress = this.progress.AsObservable(); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism, CancellationToken = this.CancellationToken, }; this.processChunks = new ActionBlock <TKey>(this.ProcessChunk, dataflowOptions); this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount); }
public StageSeedConfig(IStageIdentity stage, IEnumerable <IGenerationPhase> phases) { IStageSeedConfigContracts.Constructor(stage, phases); this.StageIdentity = stage; this.PhasesToGenerate = phases.ToReadOnlyList(); }
/// <summary> /// Initializes a new instance of the <see cref="StageGenerationException" /> class. /// </summary> /// <param name="stage">The stage.</param> /// <param name="phase">The phase.</param> public StageGenerationException(IStageIdentity stage, IGenerationPhaseIdentity phase) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); this.StageIdentity = stage; this.PhaseIdentity = phase; }
/// <summary> /// Initializes a new instance of the <see cref="StageGenerationException"/> class. /// </summary> /// /// <param name="stage">The stage.</param> /// <param name="phase">The phase.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException"> /// The exception that is the cause of the current exception, or a null reference /// if no inner exception is specified. /// </param> public StageGenerationException( IStageIdentity stage, IGenerationPhaseIdentity phase, string message, Exception innerException) : base(message, innerException) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); this.StageIdentity = stage; this.PhaseIdentity = phase; }
public static void Constructor(IStageIdentity stage, IEnumerable <IGenerationPhase> phases) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phases.AllAndSelfNotNull()); foreach (var phase in phases) { Contracts.Requires.That( phase.StageIdentity.Equals(stage), "All phases must belong to the same stage."); } }
public GenerationPhaseProgress( IStageIdentity stage, IGenerationPhaseIdentity phase, string message, long countCompleted, long totalCount) : base(countCompleted, totalCount) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); Contracts.Requires.That(!message.IsNullOrWhiteSpace()); this.StageIdentity = stage; this.PhaseIdentity = phase; this.Message = message; }
public ChunkedBatchingPhase( IStageIdentity stageIdentity, IGenerationPhaseIdentity phaseIdentity, IReadOnlyLargeCollection <TKey> chunkKeys, IAsyncFactory <TKey, TPersistable> chunkFactory, IChunkStore <TKey, TPersistable> chunkStore, int maxBatchedChunks, BatchGenerationOptions options = null) : base(options?.CancellationToken ?? DefaultCancellationToken) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(phaseIdentity != null); Contracts.Requires.That(chunkKeys != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(chunkStore != null); Contracts.Requires.That(maxBatchedChunks > 0); this.StageIdentity = stageIdentity; this.PhaseIdentity = phaseIdentity; this.chunkKeys = chunkKeys; this.chunkFactory = chunkFactory; this.chunkStore = chunkStore; this.Progress = this.progress.AsObservable(); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism, BoundedCapacity = maxBatchedChunks, CancellationToken = this.CancellationToken, }; this.generateChunks = new TransformBlock <TKey, TPersistable>( chunkIndex => this.chunkFactory.CreateAsync(chunkIndex), dataflowOptions); this.saveChunks = BatchActionBlock.Create <TPersistable>( this.SaveChunks, maxBatchedChunks, options?.Batching ?? DefaultBatching, dataflowOptions); var linkOptions = new DataflowLinkOptions() { PropagateCompletion = true }; this.generateChunks.LinkTo(this.saveChunks, linkOptions); this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount); }
public ContourPhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IRasterChunkConfig <Index3D> voxelChunkConfig, IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory, IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer, IChunkStore <ChunkKey, SerializedMeshChunk> meshChunkStore, int maxBufferedChunks, BatchSerializeGenerationOptions options = null) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(voxelChunkConfig != null); Contracts.Requires.That(voxelChunkFactory != null); Contracts.Requires.That(contourer != null); Contracts.Requires.That(meshChunkStore != null); Contracts.Requires.That(maxBufferedChunks > 0); var phaseIdentity = new GenerationPhaseIdentity(nameof(ContourPhase <TSurfaceData>)); var chunkKeys = new ChunkKeyCollection(stageBounds); var poolOptions = new PoolOptions <IMutableDivisibleMesh <NormalColorTextureVertex> >() { ResetAction = mesh => mesh.Clear(), }; this.pool = Pool.WithFactory.New( Factory.From <IMutableDivisibleMesh <NormalColorTextureVertex> >( () => new MutableDivisibleMesh <NormalColorTextureVertex>()), poolOptions); var chunkFactory = new ContourMeshFactory <TSurfaceData>( voxelChunkConfig, voxelChunkFactory, this.pool, contourer); var serializer = DivisibleMeshSerializer.NormalColorTextureVertices.WithColorAlpha[ options?.SerializationEndianness ?? DefaultSerializationEndianness]; var persistableFactory = new SerializeMeshChunkFactory(chunkFactory, serializer); this.Phase = new ChunkedBatchingPhase <ChunkKey, SerializedMeshChunk>( stageIdentity, phaseIdentity, chunkKeys, persistableFactory, meshChunkStore, maxBufferedChunks, options); this.Completion = this.CompleteAsync(); }
public SkyIslandMapAbsolutePhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IRasterChunkConfig <Index2D> chunkConfig, IAsyncChunkPopulator <ISkyIslandMapChunk> chunkPopulator, IChunkStore <ChunkOverheadKey, SerializedSkyIslandMapChunk> chunkStore, int maxBufferedChunks, BatchSerializeGenerationOptions options = null) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(chunkConfig != null); Contracts.Requires.That(chunkPopulator != null); Contracts.Requires.That(chunkStore != null); Contracts.Requires.That(maxBufferedChunks > 0); var phaseIdentity = new GenerationPhaseIdentity(nameof(SkyIslandMapAbsolutePhase)); var chunkKeys = new ChunkOverheadKeyCollection(stageBounds); var poolOptions = new PoolOptions <SkyIslandMapChunkResources>() { }; this.pool = Pool.WithFactory.New(new SkyIslandMapChunkResourcesFactory(chunkConfig), poolOptions); var chunkFactory = new SkyIslandMapChunkPoolingFactory(this.pool, chunkPopulator); var serializer = new SkyIslandMapChunkResourcesSerializer( SkyIslandMapsSerializer.Get[options?.SerializationEndianness ?? DefaultSerializationEndianness], chunkConfig); var persister = new SkyIslandMapChunkPersister(serializer); var persistableFactory = ChunkFactory.Persister.Create(chunkFactory, persister); this.Phase = new ChunkedBatchingPhase <ChunkOverheadKey, SerializedSkyIslandMapChunk>( stageIdentity, phaseIdentity, chunkKeys, persistableFactory, chunkStore, maxBufferedChunks, options); this.Completion = this.CompleteAsync(); }
public StageSeedConfig(IStageIdentity stage, params IGenerationPhase[] phases) : this(stage, (IEnumerable <IGenerationPhase>)phases) { }