Table of Contents

Class InteractableSystem

Namespace
FishMMO.Server.Implementation.World.SceneServer.Interactable
Assembly
FishMMO.Server.dll

Validates and processes client interactions with interactable objects: dialogue, containers and portals; modules handle their own kinds through OnPlayerInteracting.

[CreateAssetMenu(fileName = "InteractableSystem", menuName = "FishMMO/Server/SceneServer/Interactable System", order = 1)]
[RequiresDataContainer(typeof(InteractableSystemMainThreadQueueData))]
[RequiresDataContainer(typeof(InteractableSystemRuntimeData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class InteractableSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IInteractableSystem, IServerBehaviour, IServerComponent
Inheritance
Object
ScriptableObject
InteractableSystem
Implements
IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

What this file does not do. It never decides a use of a portal; that is PortalGate, called by the teleporters in the shared assembly. The gate reads and writes the store installed here as Current; this file hears about the writes (CharacterActivated, WorldActivated) and does the two things the shared assembly cannot: persist them and announce them.

Reading. A character's own activations (character_portals) are read when it finishes loading, the way the dialogue choice cache is; a scene's world openings (world_portal_state) when its first portal registers, and again every FishMMO.Server.Implementation.World.SceneServer.Interactable.InteractableSystem.portalWorldRefreshSeconds so an opening made on another scene server reaches this one. Until a record is read the gate refuses with "not ready" rather than treating the portal as closed.

Writing. Each activation is merged at once; whatever the database has not confirmed stays dirty in the store and is retried every FishMMO.Server.Implementation.World.SceneServer.Interactable.InteractableSystem.portalFlushIntervalSeconds and when the character leaves. Both merges are idempotent (OR, and the later deadline), so a retry can never undo anything.

Telling clients. Broadcasts only (the observer policy): the full set for a scene to a player entering it or once its records load, one change to the owner for a per-character activation, and one change to every player in the scene for a world opening.

Without the two database services the store is memory-only and every record counts as loaded: portals still work, and forget on restart.

Fields

DialogueLeaveChoiceIndex

Choice index meaning "leave the conversation" rather than "take choice N".

public const int DialogueLeaveChoiceIndex = -1

Field Value

int

Remarks

A dialogue node whose choices are all filtered out — every one already taken, or every one's conditions unmet — leaves the client with no buttons at all, and the panel has no close of its own. Escaping out of it left the session open on the server, so the next interaction with anything was validated against a node the player had walked away from. This gives the client a way to say so. It reuses DialogueChoiceBroadcast rather than adding a message, because everything the leave path needs to validate — the session, the node, the range — is already carried on it.

Methods

EndDialogueSession(IPlayerCharacter)

Ends the dialogue session for the specified character without sending a broadcast.

public void EndDialogueSession(IPlayerCharacter character)

Parameters

character IPlayerCharacter

The player character whose session to end.

InitializeOnce()

Initializes the InteractableSystem: validates dependencies, registers all network broadcast handlers, subscribes to dialogue events, and clamps configuration values.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

Initialization status indicating success or failure.

OnDeinitialize()

Deinitializes the InteractableSystem: drains queued actions, clears ingress guards, unregisters network broadcast handlers, unsubscribes from dialogue events, and clears dialogue session state.

public override void OnDeinitialize()

OnInteractNPC(IPlayerCharacter, IInteractable)

Updates an NPC to face the interacting character and enter idle state.

public void OnInteractNPC(IPlayerCharacter character, IInteractable interactable)

Parameters

character IPlayerCharacter

Interacting player character.

interactable IInteractable

Interacted NPC object.

OnUpdate(float)

Called every frame. Drains a bounded number of queued main-thread actions and sweeps stale debounce entries.

protected override void OnUpdate(float deltaTime)

Parameters

deltaTime float

Time elapsed since the last frame.

SendNewItemBroadcast<T>(T, ICharacter, IInventoryController, Item)

Grants an item to a character's inventory through the inventory system's grant funnel: placed, broadcast to the owner, persisted, identity assigned.

public bool SendNewItemBroadcast<T>(T conn, ICharacter character, IInventoryController inventoryController, Item newItem)

Parameters

conn T
character ICharacter
inventoryController IInventoryController
newItem Item

Returns

bool

Type Parameters

T

Remarks

The body that used to live here — place, broadcast, persist — is now CharacterInventorySystem.TryGrantItem, because it was one of three copies (the quest and achievement systems had their own) and only this one handed the item its database identity. A server without an inventory system refuses the grant rather than persisting without a write-back: an item that never learns its id is an item that cannot be equipped, used or moved, and the caller's own fallback (put it back on the corpse, refund the purchase) is the better outcome.

StartDialogueSession(IPlayerCharacter, ISceneObject, IDialogueInteractable)

Starts a new dialogue session for the character from an interactable interaction. Evaluates the start node's conditions and sends DialogueStartBroadcast to the client.

public void StartDialogueSession(IPlayerCharacter character, ISceneObject sceneObject, IDialogueInteractable dialogue)

Parameters

character IPlayerCharacter

The player character starting the dialogue.

sceneObject ISceneObject

The scene object hosting the interactable.

dialogue IDialogueInteractable

The dialogue interactable.

StartECADialogueSession(IPlayerCharacter, DialogueTemplate, IInteractable)

Starts a new dialogue session triggered by an ECA action.

public void StartECADialogueSession(IPlayerCharacter character, DialogueTemplate template, IInteractable interactable = null)

Parameters

character IPlayerCharacter

The player character starting the dialogue.

template DialogueTemplate

The dialogue template to use.

interactable IInteractable

The interactable the dialogue is anchored to, or null.

Remarks

interactable is what anchors the conversation to a place in the world. Every dialogue in the game reaches the server through this method — the interactable-typed StartDialogueSession(IPlayerCharacter, ISceneObject, IDialogueInteractable) overload has no callers — so when this passed a hard-coded 0 for the scene object ID, every session was unanchored and the choice handler's range check was dead code for all of them. A player could open a conversation, walk to the far side of the zone, and keep taking choices — including any that hand out items or currency.

Events

OnPlayerInteracting

Raised for every interaction the system accepts — validated, in range, rate limited — before the interactable's own triggers run.

public event Action<IPlayerCharacter, IInteractable> OnPlayerInteracting

Event Type

Action<IPlayerCharacter, IInteractable>

Remarks

How a module handles an interaction kind the interactable carries intrinsically rather than through a trigger list: the Commerce module opens a corpse's loot window here, so any NPC that can die is lootable without a content author having to remember a trigger, and a game without Commerce has corpses nobody can open. Handlers run on the main thread and must not throw.