mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-03 13:00:22 +01:00
Make Scenery a domain aggregate with no I/O
Parsing and loading move to Infrastructure/Sceneries. Weather becomes a value object owning the "does this differ from the file" rule.
This commit is contained in:
15
StarterNG/Application/Abstractions/IRandomSource.cs
Normal file
15
StarterNG/Application/Abstractions/IRandomSource.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Port over randomness. Scenery weather deliberately varies between runs (fog
|
||||
/// distance, overcast presets, texture randomiser); routing it through a port
|
||||
/// keeps those rules assertable instead of flaky.
|
||||
/// </summary>
|
||||
public interface IRandomSource
|
||||
{
|
||||
/// <summary>Inclusive lower bound, exclusive upper bound.</summary>
|
||||
int Next(int minInclusive, int maxExclusive);
|
||||
|
||||
/// <summary>Uniform value in [0, 1).</summary>
|
||||
double NextDouble();
|
||||
}
|
||||
24
StarterNG/Application/Abstractions/ISceneryRepository.cs
Normal file
24
StarterNG/Application/Abstractions/ISceneryRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using StarterNG.Domain.Sceneries;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>How far a scenery sweep has got, for the splash screen.</summary>
|
||||
public readonly record struct SceneryLoadProgress(int Loaded, int Total, string FileName);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the scenarios of an installation. The only route from a .scn on disk to
|
||||
/// a <see cref="Scenery"/>; nothing else constructs one from a path.
|
||||
/// </summary>
|
||||
public interface ISceneryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Every scenario in the installation, in no particular order. Files that
|
||||
/// fail to parse are logged and skipped rather than failing the load.
|
||||
/// </summary>
|
||||
IReadOnlyList<Scenery> LoadAll(IProgress<SceneryLoadProgress>? progress = null);
|
||||
|
||||
/// <summary>Reloads a single scenario; null when it is gone or unreadable.</summary>
|
||||
Scenery? Load(string path);
|
||||
}
|
||||
Reference in New Issue
Block a user