Table of Contents

Class MapMarkerRegistry

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The set of MapMarker components currently in the world, for the map panels to draw from.

public static class MapMarkerRegistry
Inheritance
MapMarkerRegistry
Inherited Members

Remarks

A registry rather than a per-frame scene search. The map refreshes several times a second and would otherwise call FindObjectsByType at that rate over every object in a streamed-in zone, which is the single most expensive way to answer a question the objects themselves already know the answer to.

Membership is not visibility. Everything with a marker component is in here, including objects the local player must not see on the map; the filtering is the client's job and happens on the way out. That split is deliberate — a registry that filtered on entry would have to be rebuilt whenever a party changed or a player moved, and the one thing worse than a map that shows too much is a map whose contents depend on when a GameObject happened to be enabled.

Properties

Count

How many markers are registered.

public static int Count { get; }

Property Value

int

Markers

Every registered marker. Do not mutate.

public static IReadOnlyCollection<MapMarker> Markers { get; }

Property Value

IReadOnlyCollection<MapMarker>

Methods

Clear()

Empties the registry.

public static void Clear()

Remarks

Called on quit to login. Every marker unregisters itself when its object is disabled, so in the ordinary case this finds nothing — but a scene teardown that destroys objects without disabling them first leaves entries behind, and a static collection holding destroyed MonoBehaviours keeps their whole GameObject hierarchy alive for the rest of the session.

Prune()

Drops any entries whose component has been destroyed.

public static int Prune()

Returns

int

How many entries were removed.

Remarks

A safety net for the disable-less teardown described on Clear(), run occasionally by the map panels rather than every refresh: the comparison against null on a MonoBehaviour is an engine call, and doing it for every marker on every frame is a measurable cost to catch a case that is rare by design.

Register(MapMarker)

Adds a marker to the registry.

public static void Register(MapMarker marker)

Parameters

marker MapMarker

The marker to add. Null is ignored.

Unregister(MapMarker)

Removes a marker from the registry.

public static void Unregister(MapMarker marker)

Parameters

marker MapMarker

The marker to remove. Null is ignored.

Events

OnMarkerRegistered

Raised when a marker joins the registry.

public static event Action<MapMarker> OnMarkerRegistered

Event Type

Action<MapMarker>

Remarks

The map panels poll the collection rather than maintaining their own copy from these, so nothing subscribes today. They exist for a panel that wants to react to an arrival without polling — a "new landmark discovered" notification, for instance.

OnMarkerUnregistered

Raised when a marker leaves the registry.

public static event Action<MapMarker> OnMarkerUnregistered

Event Type

Action<MapMarker>