Class PortalActivationRules
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
MinTimedSeconds
Shortest timed opening, seconds. A shorter one would close before the traveller arrived.
public const float MinTimedSeconds = 10
Field Value
NoExpiry
RemainingSeconds(long) of an opening that never ends.
public const int NoExpiry = -1
Field Value
Methods
ClampDuration(float)
Clamps an authored timed duration into [MinTimedSeconds, MaxTimedSeconds].
public static float ClampDuration(float seconds)
Parameters
secondsfloat
Returns
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
activebool?From IsActive(PortalActivationScope, bool?, PortalWorldState?, long).
hasRequirementsboolWhether the portal names any condition or a key.
anyConditionMetboolWhether at least one of its conditions passed for the player. Ignored unless closed.
keyHeldboolWhether the player holds the key. Ignored unless closed and no condition passed.
Returns
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
scopePortalActivationScopeThe portal's scope; it decides which record counts.
characterActivebool?The player's own record for this portal; null when not loaded.
worldPortalWorldState?The world record for this portal; null when the scene's rows are not loaded, default when none exists.
nowUnixMslongThe 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
scopePortalActivationScope
Returns
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
scopePortalActivationScopecharacterActivebool?worldPortalWorldState?nowUnixMslong
Returns
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
scopePortalActivationScopeThe portal's scope. PerCharacter yields the empty state.
durationSecondsfloatThe timed opening's length; clamped.
nowUnixMslongThe moment of activation.