Table of Contents

Class World

Namespace
Shard.Gameplay.Universe.World
Assembly
Shard.Gameplay.Universe.dll

Runtime simulation world that owns one ECS Store and progresses it on a dedicated tick thread.

public sealed class World : TickingThread, IAsyncDisposable
Inheritance
World
Implements
Inherited Members

Properties

Chunks

The world's cubic chunks (generated on demand within the config bounds).

public ChunkStorage Chunks { get; }

Property Value

ChunkStorage

Config

Gets the loaded world configuration.

public WorldConfig Config { get; }

Property Value

WorldConfig

EntitySeed

Per-world seed the client uses for entity-visual determinism (sent via SetEntitySeed).

public int EntitySeed { get; }

Property Value

int

IsIdle

Allows derived loops to reduce spin timing while still processing tasks and ticks.

protected override bool IsIdle { get; }

Property Value

bool

Name

Gets the stable world name used by the server runtime.

public string Name { get; }

Property Value

string

Players

Gets the exact committed players for this loaded world.

public PlayerInWorldTracker Players { get; }

Property Value

PlayerInWorldTracker

Storage

Gets storage information for the world save.

public WorldStorage Storage { get; }

Property Value

WorldStorage

Uuid

Gets the world UUID from the loaded configuration.

public Guid Uuid { get; }

Property Value

Guid

Methods

DisposeAsyncCore()

Performs disposal once for the task published by DisposeAsync().

protected override Task DisposeAsyncCore()

Returns

Task

Remarks

Overrides must await this implementation and release derived resources in a finally block so every caller observes the same completion.

ExecuteAsync(Action<World>)

Executes synchronous Store work on the world thread.

public Task ExecuteAsync(Action<World> callback)

Parameters

callback Action<World>

Returns

Task

Remarks

Use this as the cross-thread gate to world-owned ECS state. The callback must not keep Store-owned handles for later use

ExecuteAsync<T>(Func<World, T>)

Executes synchronous Store work on the world thread and returns its result.

public Task<T> ExecuteAsync<T>(Func<World, T> callback)

Parameters

callback Func<World, T>

Returns

Task<T>

Type Parameters

T

Remarks

Use this as the cross-thread gate to world-owned ECS state. The callback must not keep Store-owned handles for later use

GetStoreDiagnostics()

Gets a point-in-time diagnostics snapshot for the owned Store.

public StoreDiagnostics GetStoreDiagnostics()

Returns

StoreDiagnostics

IsModuleEnabledAsync(string)

Gets runtime module activation on the world thread.

public Task<bool> IsModuleEnabledAsync(string moduleId)

Parameters

moduleId string

Returns

Task<bool>

OnShutdown()

Runs once on the loop thread after the tick loop exits.

protected override void OnShutdown()

OnStart()

Runs once on the loop thread before the start task completes.

protected override void OnStart()

OpenTransaction()

Opens a synchronous transaction owned by this world's tick thread.

public Transaction OpenTransaction()

Returns

Transaction

Exceptions

InvalidOperationException

Thrown when called off the world thread or while the world is not running.

PublishModulePackets(World, string, IReadOnlyList<IToClientPacket>)

Publishes a module-owned packet batch from this world's current Store callback.

public void PublishModulePackets(World source, string moduleId, IReadOnlyList<IToClientPacket> packets)

Parameters

source World
moduleId string
packets IReadOnlyList<IToClientPacket>

ReportPipelineFailure(Exception)

Defers a managed system exception until execution returns from Flecs.

public void ReportPipelineFailure(Exception exception)

Parameters

exception Exception

SetModuleEnabledAsync(string, bool)

Changes runtime module activation on the world thread.

public Task<bool> SetModuleEnabledAsync(string moduleId, bool enabled)

Parameters

moduleId string
enabled bool

Returns

Task<bool>

Whether the activation profile changed.

SetTicksPerSecondAsync(int)

Queues a runtime TPS change onto the world thread.

public Task SetTicksPerSecondAsync(int ticksPerSecond)

Parameters

ticksPerSecond int

Returns

Task

Tick(float)

Runs one measured tick on the loop thread.

protected override void Tick(float deltaSeconds)

Parameters

deltaSeconds float