/// <summary> /// Setup of readonly fields and non-optional steps. /// </summary> private World(WorldInformation information, string worldDirectory, string chunkDirectory, IWorldGenerator generator) { positionsToActivate = new HashSet<(int x, int z)>(); positionsActivating = new HashSet<(int, int)>(); chunksToGenerate = new UniqueQueue<Chunk>(); chunkGenerateTasks = new List<Task>(MaxGenerationTasks); chunksGenerating = new Dictionary<int, Chunk>(MaxGenerationTasks); positionsToLoad = new UniqueQueue<(int x, int z)>(); chunkLoadingTasks = new List<Task<Chunk?>>(MaxLoadingTasks); positionsLoading = new Dictionary<int, (int x, int z)>(MaxLoadingTasks); activeChunks = new Dictionary<ValueTuple<int, int>, Chunk>(); positionsToReleaseOnActivation = new HashSet<(int x, int z)>(); chunksToSave = new UniqueQueue<Chunk>(); chunkSavingTasks = new List<Task>(MaxSavingTasks); chunksSaving = new Dictionary<int, Chunk>(MaxSavingTasks); positionsSaving = new HashSet<(int x, int z)>(MaxSavingTasks); positionsActivatingThroughSaving = new HashSet<(int x, int z)>(); Information = information; WorldDirectory = worldDirectory; ChunkDirectory = chunkDirectory; this.generator = generator; UpdateCounter = new UpdateCounter(); Setup(); }
/// <summary> /// This constructor is meant for worlds that already exist. /// </summary> protected World(WorldInformation information, string path) : this( information, path, path + "/Chunks", new ComplexGenerator(information.Seed)) { logger.LogInformation(Events.WorldIO, "Loaded existing world"); }