Table of Contents

Class PortalActivationRules

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The portal activation rules as pure functions: scope × conditions × stored state → what a use of the portal does. PortalGate is the only caller in the game; tests drive these directly.

public static class PortalActivationRules
Inheritance
PortalActivationRules
Inherited Members

Remarks

Unknown is not closed. A server that has not yet read a character's (or a scene's) activations from the database answers null for "is it open", and the verdict for that is NotReady, a refusal that changes nothing. Treating it as closed would let a player who already opened a portal open it again, and a portal that spends its key would take a second key for it.

Requirements are any-of. One passing condition opens the portal; the key is one more alternative, tried after the conditions so a player who qualifies some other way keeps the key. A portal with no conditions and no key opens for the first player who uses it — a generated portal ships that way until a designer assigns its requirements.

Fields

MaxTimedSeconds

Longest timed opening, seconds (thirty days). A longer one is a permanent portal.

public const float MaxTimedSeconds = 2592000

Field Value

float

MinTimedSeconds

Shortest timed opening, seconds. A shorter one would close before the traveller arrived.

public const float MinTimedSeconds = 10

Field Value

float

NoExpiry

RemainingSeconds(long) of an opening that never ends.

public const int NoExpiry = -1

Field Value

int

Methods

ClampDuration(float)

Clamps an authored timed duration into [MinTimedSeconds, MaxTimedSeconds].

public static float ClampDuration(float seconds)

Parameters

seconds float

Returns

float

Decide(bool?, bool, bool, bool)

What a use of the portal does.

public static PortalActivationVerdict Decide(bool? active, bool hasRequirements, bool anyConditionMet, bool keyHeld)

Parameters

active bool?

From IsActive(PortalActivationScope, bool?, PortalWorldState?, long).

hasRequirements bool

Whether the portal names any condition or a key.

anyConditionMet bool

Whether at least one of its conditions passed for the player. Ignored unless closed.

keyHeld bool

Whether the player holds the key. Ignored unless closed and no condition passed.

Returns

PortalActivationVerdict

IsActive(PortalActivationScope, bool?, PortalWorldState?, long)

Whether a portal is open for one player.

public static bool? IsActive(PortalActivationScope scope, bool? characterActive, PortalWorldState? world, long nowUnixMs)

Parameters

scope PortalActivationScope

The portal's scope; it decides which record counts.

characterActive bool?

The player's own record for this portal; null when not loaded.

world PortalWorldState?

The world record for this portal; null when the scene's rows are not loaded, default when none exists.

nowUnixMs long

The current time.

Returns

bool?

True open, false closed, null not known yet.

IsWorldScope(PortalActivationScope)

Whether a scope's opening is shared by the whole world.

public static bool IsWorldScope(PortalActivationScope scope)

Parameters

scope PortalActivationScope

Returns

bool

RemainingSeconds(PortalActivationScope, bool?, PortalWorldState?, long)

Seconds a portal stays open for one player, for the owner's client: NoExpiry for a per-character or permanent opening, the remainder for a timed one, 0 when closed or unknown.

public static int RemainingSeconds(PortalActivationScope scope, bool? characterActive, PortalWorldState? world, long nowUnixMs)

Parameters

scope PortalActivationScope
characterActive bool?
world PortalWorldState?
nowUnixMs long

Returns

int

WorldStateFor(PortalActivationScope, float, long)

The world record an activation writes for a world-scoped portal.

public static PortalWorldState WorldStateFor(PortalActivationScope scope, float durationSeconds, long nowUnixMs)

Parameters

scope PortalActivationScope

The portal's scope. PerCharacter yields the empty state.

durationSeconds float

The timed opening's length; clamped.

nowUnixMs long

The moment of activation.

Returns

PortalWorldState