Table of Contents

Class ObserverStreamingRegistry

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Server-side scheduler that applies ObserverStreamingPolicy to every registered character: scales each one's observer range by local density, and for every viewing client ranks what it can see and rate limits everything beyond the cap.

public static class ObserverStreamingRegistry
Inheritance
ObserverStreamingRegistry
Inherited Members

Remarks

Characters register from CharacterPredictionController.OnStartServer, so this covers exactly the predicted characters — players, monsters, pets — whose NetworkTransform and other per-tick traffic is what an observer's bandwidth is spent on. Interactables and world items are static and keep their prefab conditions untouched.

Runs one pass every RescheduleIntervalTicks ticks off FishNet.Managing.Timing.TimeManager.OnPostTick. A pass is O(entries) for density (uniform grid) plus O(viewers × entries) for ranking, with entries grouped by Unity scene so characters in different scenes never compare positions. At 200 players and 700 characters that is ~140k score evaluations per half second, all field reads.

Properties

Count

Number of characters currently registered.

public static int Count { get; }

Property Value

int

LastPassBudgetExcluded

(viewer, observed) pairs excluded by the visibility budget in the last pass.

public static int LastPassBudgetExcluded { get; }

Property Value

int

LastPassLimitedPairs

(viewer, observed) pairs rate limited in the last pass.

public static int LastPassLimitedPairs { get; }

Property Value

int

LastPassPinned

Characters pinned into a visibility budget in the last pass.

public static int LastPassPinned { get; }

Property Value

int

LastPassRangeChanges

Characters whose observer range was changed in the last pass.

public static int LastPassRangeChanges { get; }

Property Value

int

LastPassViewers

Viewers ranked in the last pass.

public static int LastPassViewers { get; }

Property Value

int

Methods

Clear()

public static void Clear()

Get(NetworkObject)

Returns the entry for a registered object, or null.

public static ObserverStreamingEntry Get(NetworkObject networkObject)

Parameters

networkObject NetworkObject

Returns

ObserverStreamingEntry

IsWithinVisibilityBudget(int, int, bool, out bool)

Whether a character is inside a viewer's visibility budget.

public static bool IsWithinVisibilityBudget(int viewerClientId, int observedObjectId, bool currentlyVisible, out bool hasRanking)

Parameters

viewerClientId int

Client id of the viewing connection.

observedObjectId int

Object id of the character being tested.

currentlyVisible bool

True when the viewer already observes it; widens the budget by the hysteresis.

hasRanking bool

False when this viewer has no ranking yet.

Returns

bool

True when the character is inside the budget.

Remarks

The budget condition's whole implementation. hasRanking distinguishes "ranked and excluded" from "no pass has run for this viewer yet" — the caller must not treat the second as a rejection, or everything stays hidden until the first pass lands.

LogSummary()

Logs a one-line summary of the last pass. For diagnostics.

public static void LogSummary()

Register(NetworkObject, ICharacter)

Registers a character. Installs the entry as the object's observer send filter.

public static ObserverStreamingEntry Register(NetworkObject networkObject, ICharacter character)

Parameters

networkObject NetworkObject
character ICharacter

Returns

ObserverStreamingEntry

RunPass()

Runs one scheduling pass over every registered character. Public so a server can force a pass after a bulk change (a load boundary) and so tests can drive it.

public static void RunPass()

Unregister(NetworkObject)

Unregisters a character, restoring its prefab range and removing the send filter.

public static void Unregister(NetworkObject networkObject)

Parameters

networkObject NetworkObject