Class PortalGate
The one place a portal use is decided: open → travel; closed and the player qualifies → activate, then travel; otherwise refuse with a toast. Server only.
public static class PortalGate
- Inheritance
-
PortalGate
- Inherited Members
Remarks
Called by TeleportAction (a Teleporter interaction) and SceneTeleporter (walking into a scene portal) just before they move the player. An object without a PortalActivation is not gated at all, so every teleporter that existed before portals keeps working unchanged.
Activation IS the use: there is no separate "activate" interaction. A player who meets a condition walks straight through, and the portal stays open for whoever its scope says. Every refusal answers the owner with the general ToastBroadcast, the same path every other teleport refusal takes.
Fields
NotReadyMessage
Told to a player whose record the server has not finished reading.
public const string NotReadyMessage = "The portal does not answer yet. Try again in a moment."
Field Value
Methods
FormatDuration(float)
"2 hours", "45 minutes", "30 seconds".
public static string FormatDuration(float seconds)
Parameters
secondsfloat
Returns
TryPass(IPlayerCharacter, PortalActivation, EventData, PortalActivationStore)
public static bool TryPass(IPlayerCharacter player, PortalActivation portal, EventData eventData, PortalActivationStore store)
Parameters
playerIPlayerCharacterportalPortalActivationeventDataEventDatastorePortalActivationStore
Returns
TryPass(IPlayerCharacter, GameObject, EventData)
Decides a use of the portal on portalObject, activating it when the
player qualifies.
public static bool TryPass(IPlayerCharacter player, GameObject portalObject, EventData eventData = null)
Parameters
playerIPlayerCharacterThe player using it.
portalObjectGameObjectThe teleporter's GameObject.
eventDataEventDataThe interaction's event data, if any; conditions read it.
Returns
- bool
True when the player may travel.
Use(ICharacter, PortalActivation, EventData, PortalActivationStore, out string)
The use itself, without the network: decides, activates when the verdict says so (spending the key first when the key opened it and the portal spends keys), and says what the player should be told. TryPass(IPlayerCharacter, PortalActivation, EventData, PortalActivationStore) sends that line; tests read it.
public static PortalActivationVerdict Use(ICharacter character, PortalActivation portal, EventData eventData, PortalActivationStore store, out string message)
Parameters
characterICharacterThe character using the portal.
portalPortalActivationThe portal.
eventDataEventDataConditions read it; may be null.
storePortalActivationStoreThe activation store.
messagestringWhat to tell the player, or null for nothing.
Returns
- PortalActivationVerdict
The verdict that applied. An ActivateWithKey whose key could not be spent comes back as Locked.