Townportalregistry
Overview
The TownportalRegistry component maintains a global registry of town portals within the world, tracks the currently activated portal, and manages inter-portal linking logic. It responds to activation/deactivation events, portal registration/removal, and WagPunk barrier state changes to determine which portals can be teleported between. This component runs exclusively on the master simulation.
Dependencies & Tags
- Required Components (on event payloads):
townportalentities must have aTransformcomponent (used for position queries).townportalentities may haveinventoryitemand/orchannelablecomponents (used optionally for ownership and state management).
- Tags: None explicitly added or removed by this component.
- Environment: Asserts
TheWorld.ismastersim; does not instantiate on clients.
Properties
No explicit public properties are defined via self. assignment in _ctor. All state is stored in private local variables inside the constructor closure.
| Property | Type | Default Value | Description |
|---|---|---|---|
| (none) | — | — | No public instance properties are initialized. Internal state (_townportals, _activetownportal, linkedportals) is kept in private scope. |
Main Functions
self:GetDebugString()
- Description: Returns a human-readable debug string summarizing the current state, including the number of registered portals and whether a portal is active.
- Parameters: None.
IsATownPortalActive()
- Description: Returns
trueif a town portal is currently activated (i.e.,_activetownportalis notnil), otherwisefalse. - Parameters: None.
Events & Listeners
-
Listens For:
"ms_registertownportal"→ triggersOnRegisterTownPortal(inst, townportal)"townportalactivated"→ triggersOnTownPortalActivated(inst, townportal)"townportaldeactivated"→ triggersOnTownPortalDeactivated(inst, portal)"ms_wagpunk_barrier_isactive"→ triggersOnBarrierIsActive(inst, isactive)"ms_wagpunk_barrier_playerentered"→ triggersOnPlayerEnteredOrLeftBarrier(inst, player)"ms_wagpunk_barrier_playerleft"→ triggersOnPlayerEnteredOrLeftBarrier(inst, player)"onremove"(on individual town portal entities) → triggersOnRemoveTownPortal(townportal)
-
Pushes Events:
townportal:PushEvent("linktownportals")— clears link state on deactivation or barrier entry.townportal:PushEvent("linktownportals", other_portal)— notifies a portal of a new active link to another portal."linktownportals"is used to signal changes in portal linkage status to subscribers (e.g., UI or portal components).