Table of Contents

Class CharacterStateValidation

Namespace
FishMMO.Shared.Core
Assembly
FishMMO.Shared.dll

The one rule for whether a character may act on a major event: dead, teleporting, frozen, stunned, mesmerised and unloaded characters may not.

public static class CharacterStateValidation
Inheritance
CharacterStateValidation
Inherited Members

Remarks

Shared, not server-only. The server asks it at the start of every broadcast handler that mutates game state; the owning client asks it before it queues a request that the server would answer with the same rule — an equip, an unequip, a container swap — so a refusal costs no round trip and the two peers cannot disagree about who may act. The flags it reads travel in the character's spawn payload, so the owner holds the same answer the server does.

It used to live in the server assembly, which client code cannot reference, and the client grew its own partial copies of the rule as a result. There is one now.

Methods

CanAct(ICharacter)

Returns true if the character is in a valid state to perform actions. Logs and rejects dead, teleporting, incapacitated, and unloaded characters.

public static bool CanAct(ICharacter character)

Parameters

character ICharacter

Returns

bool

CanAct(IPlayerCharacter)

Returns true if the character is in a valid state to perform actions. The IPlayerCharacter form of CanAct(ICharacter); the rule is the same.

public static bool CanAct(IPlayerCharacter character)

Parameters

character IPlayerCharacter

Returns

bool

CanActOrMove(IPlayerCharacter)

Returns true if the character is in a valid state to perform movement. Same as CanAct(IPlayerCharacter) but also rejects characters in combat (prevents combat-escape via teleport or scene change).

public static bool CanActOrMove(IPlayerCharacter character)

Parameters

character IPlayerCharacter

Returns

bool

TryGetPlayerAndValidate(NetworkConnection, out IPlayerCharacter)

Resolves the IPlayerCharacter from conn and validates it via CanAct(IPlayerCharacter). This is the canonical pattern for server-side broadcast handlers: every state-mutating handler must call this (or CanActOrMove(IPlayerCharacter) for movement-gated operations) before processing.

Usage:

if (!CharacterStateValidation.TryGetPlayerAndValidate(conn, out IPlayerCharacter player))
    return;
public static bool TryGetPlayerAndValidate(NetworkConnection conn, out IPlayerCharacter player)

Parameters

conn NetworkConnection

The network connection to resolve the player from.

player IPlayerCharacter

The resolved and validated player character, or null.

Returns

bool

True if the player was resolved and is in a valid state to act.