Table of Contents

Interface IAbilitySystem

Namespace
FishMMO.Server.Core.World.SceneServer
Assembly
FishMMO.Server.dll

Engine-agnostic public API for granting crafted abilities on scene servers.

public interface IAbilitySystem : IServerBehaviour, IServerComponent

Remarks

The one funnel every path that gives a character a new Ability goes through. It exists because there were three copies of "build the ability, learn it, persist it" and only the item layer had worked out what they were missing: the database mints the row's identity, and an ability whose ID is still the constructor's -1 is filed into KnownAbilities[-1] — so a second craft silently replaced the first, and a hotkey bound to either one resolved against the sentinel.

The identity is therefore applied BEFORE the ability is learned. That is why the learn is a continuation of the persist rather than something the caller does when this returns: an ability has no slot to lock while its identity is unknown, and the instance id is its key on the server, in the client's known-ability table, in every activation broadcast, and inside every persisted hotkey row. See AbilitySystem for the item-layer comparison.

Methods

TryGrantAbility(IPlayerCharacter, AbilityTemplate, IReadOnlyList<int>, Func<IPlayerCharacter, bool>, Action, Action<IPlayerCharacter, Ability>, Action<IPlayerCharacter>)

Builds and grants a new crafted ability to character.

bool TryGrantAbility(IPlayerCharacter character, AbilityTemplate template, IReadOnlyList<int> events, Func<IPlayerCharacter, bool> settle, Action releaseGuard, Action<IPlayerCharacter, Ability> onGranted, Action<IPlayerCharacter> onFailed)

Parameters

character IPlayerCharacter

The character receiving the ability.

template AbilityTemplate

The ability template the crafted ability is built from.

events IReadOnlyList<int>

The crafted event template ids to attach, or null for none.

settle Func<IPlayerCharacter, bool>

Takes the caller's charge on the main thread once the row exists. Null when the grant is free. Returns false, having answered the player, to have the row revoked.

releaseGuard Action

Releases the caller's in-flight guard. Always invoked, exactly once, by this system.

onGranted Action<IPlayerCharacter, Ability>

Runs on the main thread once the ability is settled, learned and broadcast.

onFailed Action<IPlayerCharacter>

Runs on the main thread when the ability could not be recorded.

Returns

bool

true when the grant was admitted; false when it was refused outright.

Remarks

Asynchronous by contract. A true return means the request was admitted, not that the ability exists yet. Exactly one of onGranted or onFailed runs later, on the main thread, once the database has answered.

This method takes ownership of releaseGuard. It is invoked exactly once on whichever path finishes the request — a synchronous refusal, a refused enqueue, or the persist's continuation — so a caller must NOT also release it, and a caller that holds a request-open guard across this call passes the release in here instead of running it in its own finally.

A refusal is synchronous and already reports itself through the return value, so onFailed is reserved for a persist that was attempted and did not land. Callers answer a false return themselves.

Payment is settled on completion, not before the call. A caller that charges for the ability passes the charge as settle; it runs on the main thread once the row exists and only if the character is still resident, and the ability is learned strictly after it returns true. If the character has left, or settle returns false, the row is revoked and nothing is learned, announced or owed. Charging before the call was how a persist that failed after the player left became an unrefundable loss. A false from settle means the caller has already answered the player; neither onGranted nor onFailed runs for it.