Table of Contents

Class DungeonDifficultyRegistry

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Which difficulty ruleset applies inside each loaded dungeon scene, on this process.

public static class DungeonDifficultyRegistry
Inheritance
DungeonDifficultyRegistry
Inherited Members

Remarks

The bridge between a scene row and the things spawning inside the scene it produced. An NPC waking up in a dungeon knows the Unity scene it is in and nothing else — not which instance row asked for it, not which party owns it, and certainly not what difficulty they chose. It cannot ask the server systems either: those live in the server assembly and this code is shared with the client.

So the scene server, which does know all of that, publishes the answer here as it finishes loading a scene and withdraws it as the scene unloads. Everything downstream is a dictionary lookup on a scene handle, which is cheap enough for a spawn path and for a loot roll.

Scene handles are process-local, and that is exactly right here. Nothing in this registry is ever persisted or sent anywhere: it describes scenes loaded in this process, for the lifetime of those scenes. The cross-process identity of an instance remains its scene row ID, and this is deliberately not that.

Not thread-safe, and not intended to be. Registration happens on the main thread as a scene finishes loading, and every reader — spawning, loot, death rules — is on the main thread too.

Methods

Clear()

Drops every published ruleset. For server shutdown and domain reload.

public static void Clear()

Remarks

Static state survives entering and leaving play mode in the editor when domain reload is disabled, and a registry carried across would describe scenes from the previous session.

GetLootMultipliers(int, out float, out float)

The loot quantity and currency multipliers for one scene, defaulting to no change.

public static void GetLootMultipliers(int sceneHandle, out float lootQuantityMultiplier, out float currencyMultiplier)

Parameters

sceneHandle int

Scene manager handle to look up.

lootQuantityMultiplier float

Receives the item quantity multiplier.

currencyMultiplier float

Receives the currency multiplier.

Remarks

A convenience for the loot paths, which want two floats and do not care whether the scene had a difficulty at all — the open world simply gets 1 and 1.

Register(int, DungeonDifficultyDefinition)

Publishes the rules that apply inside one loaded scene.

public static void Register(int sceneHandle, DungeonDifficultyDefinition difficulty)

Parameters

sceneHandle int

Scene manager handle of the loaded scene.

difficulty DungeonDifficultyDefinition

The ruleset, or null to publish nothing.

TryGet(int, out DungeonDifficultyDefinition)

The rules that apply inside one scene, if any were published for it.

public static bool TryGet(int sceneHandle, out DungeonDifficultyDefinition difficulty)

Parameters

sceneHandle int

Scene manager handle to look up.

difficulty DungeonDifficultyDefinition

Receives the ruleset.

Returns

bool

True when the scene has a difficulty; false for the open world and for dungeons that declare none.

Unregister(int)

Withdraws the rules for a scene that is unloading.

public static void Unregister(int sceneHandle)

Parameters

sceneHandle int

Scene manager handle of the scene being unloaded.

Remarks

Must be called for every registered scene. Scene handles are drawn from a per-process counter and are reused, so an entry that outlived its scene would eventually be read as the rules for an unrelated one.