Table of Contents

Class SceneContentLoads

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The content a scene fetches for itself after it has loaded: its terrain arrays, biome templates, river flow and the like, each an Addressable load a component starts from its own lifecycle. Those run outside the scene load and outside AddressableLoadProcessor's batches, so nothing that waits on either sees them. The client's loading screen holds world entry until this is empty, so the player arrives in a finished world instead of watching ground and water arrive from the cache or the web server.

public static class SceneContentLoads
Inheritance
SceneContentLoads
Inherited Members

Remarks

A load is a token: Begin(string) when the fetch starts, End() on every way it can finish (success, failure, the owner disabled or destroyed). End is idempotent, so an owner can call it from both its completion callback and its teardown without counting twice. A forgotten End holds the overlay only until the loading screen's own deadline, never forever.

Work. Content that has arrived is not finished: a biome registering makes the grass and scatter take their terrains again, and props merge into pools, each a few milliseconds a frame. A system with such work adds a SceneContentLoads.Work probe once (AddWork(string, Func<bool>, Func<float>)); the loading screen keeps the world covered while any probe says it is busy, and while it does (Covered) those systems spend Budget(double) a frame instead of their usual slice, so the work finishes behind the overlay rather than as hitches on the screen after it.

Progress. Loads begun while others are in flight are one wave: the bar reads the wave's finished loads plus the running ones' progress over all it has begun, so it only moves forward as loads join and end.

Fields

CoveredBudgetMilliseconds

The most milliseconds a frame a builder may spend while Covered (still yields, so the overlay animates).

public const double CoveredBudgetMilliseconds = 24

Field Value

double

Properties

Busy

Whether anything is loading, or being prepared from what has loaded.

public static bool Busy { get; }

Property Value

bool

Covered

Set by the loading screen while it covers the world for content: nothing is on screen, so work may take far more of a frame than its usual slice (Budget(double)).

public static bool Covered { get; set; }

Property Value

bool

FirstPending

The first fetch still in flight, or null when none is.

public static string FirstPending { get; }

Property Value

string

Pending

Number of fetches still in flight.

public static int Pending { get; }

Property Value

int

Progress

Progress of the current wave (1 when nothing is in flight): its ended loads plus the running ones' progress, over every load it has begun. A mean of the running loads alone went backwards each time one finished and the next started from 0.

public static float Progress { get; }

Property Value

float

WaveBegun

Loads begun in the current wave.

public static int WaveBegun { get; }

Property Value

int

WaveEnded

Loads of the current wave that have ended.

public static int WaveEnded { get; }

Property Value

int

Methods

AddWork(string, Func<bool>, Func<float>)

Adds (or replaces, by what) a probe of work done on content after it arrives. Systems add one from their hook; replacing by name keeps a re-hook (domain reload off) from adding it twice.

public static SceneContentLoads.Work AddWork(string what, Func<bool> busy, Func<float> progress = null)

Parameters

what string

What the work prepares, for the hint ("grass").

busy Func<bool>

True while the work the camera would see is not done.

progress Func<float>

Optional 0 to 1 of that work.

Returns

SceneContentLoads.Work

Begin(string)

Starts tracking a fetch named what (e.g. "terrain").

public static SceneContentLoads.Load Begin(string what)

Parameters

what string

Returns

SceneContentLoads.Load

Budget(double)

milliseconds, or CoveredBudgetMilliseconds when larger and the world is covered.

public static double Budget(double milliseconds)

Parameters

milliseconds double

Returns

double

BusyWork()

The first probe that reports busy, or null.

public static SceneContentLoads.Work BusyWork()

Returns

SceneContentLoads.Work

Describe()

The names of the fetches still in flight and of busy work, for a warning.

public static string Describe()

Returns

string

RemoveWork(string)

Removes the probe added as what, if any.

public static void RemoveWork(string what)

Parameters

what string

TryDescribe(out string, out float)

What the overlay says about the content stage: the loads while any is in flight (with the wave's count), else the first busy work. False when nothing is running.

public static bool TryDescribe(out string hint, out float progress)

Parameters

hint string

The line under the bar.

progress float

0 to 1, or -1 when the work reports none (the bar is left as it is).

Returns

bool