Class Universe
- Namespace
- Shard.Gameplay.Universe
- Assembly
- Shard.Gameplay.Universe.dll
Owns the loaded gameplay worlds for a server instance.
public sealed class Universe : IAsyncDisposable
- Inheritance
-
Universe
- Implements
- Inherited Members
Remarks
World load, unload, and disposal are serialized through one lifecycle lock. The first admitted load attempt freezes the Store definition registry before composing its candidate. The same immutable definitions are then reused by every later world, even when that first attempt fails. Disposal synchronously closes world publication and clears both lookup indexes before waiting for the lifecycle lock.
Fields
DefaultWorldName
Default world name used when server config does not provide one.
public const string DefaultWorldName = "default"
Field Value
Properties
LoadedWorldNames
Gets a snapshot of loaded world names.
public IReadOnlyCollection<string> LoadedWorldNames { get; }
Property Value
LoadedWorldUuids
Gets a snapshot of loaded world UUIDs.
public IReadOnlyCollection<Guid> LoadedWorldUuids { get; }
Property Value
SolidBlockId
Gets the block ID used to fill solid terrain voxels. The host resolves it from the active biome material. It defaults to the placeholder value when the material is unavailable.
public ushort SolidBlockId { get; set; }
Property Value
TerrainDensityFactory
Builds the world's terrain density from its seed using the Hytale v2 generator assets. When null, the world uses the placeholder heightmap.
public Func<long, Density?>? TerrainDensityFactory { get; set; }
Property Value
WorldDefaults
World asset defaults used by join weather/environment; set once assets are available.
public IWorldDefaults? WorldDefaults { get; set; }
Property Value
- IWorldDefaults
Methods
AddPlayerAsync(PlayerJoinStart, CancellationToken)
Admits one authenticated setup connection as a Player and then into its initial World.
public Task<Player> AddPlayerAsync(PlayerJoinStart start, CancellationToken cancellationToken)
Parameters
startPlayerJoinStartcancellationTokenCancellationToken
Returns
DisposeAsync()
Unloads and disposes every world owned by the universe.
public ValueTask DisposeAsync()
Returns
Remarks
The first caller synchronously prevents further world publication and captures all currently loaded worlds. Every caller observes the same cached completion. Disposal attempts every captured world before reporting an AggregateException containing any failures.
Get()
Get a instance of Universe
public static Universe Get()
Returns
LoadInitialWorldsAsync(string?, CancellationToken)
Loads worlds required during server boot.
public Task LoadInitialWorldsAsync(string? defaultWorldName = "default", CancellationToken cancellationToken = default)
Parameters
defaultWorldNamestringcancellationTokenCancellationToken
Returns
Remarks
This is the future hook for loading saved worlds before creating the default fallback.
LoadWorldAsync(string, WorldConfig?, WorldStorage?)
Creates, starts, and registers a world using the frozen Store definitions.
public Task LoadWorldAsync(string name, WorldConfig? config = null, WorldStorage? storage = null)
Parameters
namestringconfigWorldConfigstorageWorldStorage
Returns
Remarks
The lifecycle lock prevents concurrent definition application during first load and keeps publication ordered with unload and disposal. A failed candidate is disposed without being published; freezing is not rolled back.
TryGetWorld(Guid, out World?)
Attempts to resolve a loaded world by UUID.
public bool TryGetWorld(Guid uuid, out World? world)
Parameters
Returns
TryGetWorld(string, out World?)
Attempts to resolve a loaded world by name.
public bool TryGetWorld(string name, out World? world)
Parameters
Returns
UnloadWorldAsync(string)
Unloads and disposes a world by name.
public Task<bool> UnloadWorldAsync(string name)
Parameters
namestring