Skip to main content

SpiritModeDoorway

A class in Root.Township, Features.Gameplay.ClimbingTower.

Trigger doorway in the climbing tower that puts players into spirit mode (sets their current unlock) or takes them out of it as they walk or teleport through. The change is sent as a message and applied on the server.

Constructors​

MemberWhat it is
SpiritModeDoorway()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private BoxCollider boxColliderTrigger collider of the doorway. Its size is saved and synced.
private SpiritModeDoorwayMode doorwayModeWhether the door adds or removes spirit mode.
private bool isOneWayDoorWhen true, teleporting through only counts from the door's forward side.
private PlayerUnlock playerUnlockThe unlock given as spirit mode.
private SoundEffectSet spiritDoorPassSfxSound played when a player passes through and their mode changes.
private MethodSyncStruct<SpiritModeDoorway.UnlockModificationPair> syncPlayerUnlockDoorModificationMethod sync for the add or remove unlock message.
private MethodSync syncSaveDataMethod sync for the door settings.

Methods​

MemberWhat it is
override void Initialize()Creates the save-data sync on SyncA and the unlock change sync on SettingsChanged.
override void OnConnected(Player player)Server: sends the door's settings to the joining player.
void OnTriggerEnter(Collider other)When a player character enters the collider, updates that player's spirit mode. The one-way check is not applied here.
void OnTriggerTeleportedThrough(IPlayer player)When a player teleports through, updates their spirit mode, honouring the one-way direction.
void SyncDoorwayModification(PlayerUnlock newUnlock, bool isGivingUnlock)Sends an add or remove unlock message to chunks; the receiving server applies it to the sender.
8 private and internal methods
MemberWhat it is
private bool CanEnterSpiritMode(IPlayer player)True if this door adds spirit mode and the player has no current unlock.
private bool CanExitSpiritMode(IPlayer player)True if this door removes spirit mode and the player has a current unlock.
private bool CanSyncDoorModification(Stream stream, SpiritModeDoorway.UnlockModificationPair unlockModificationPair)Only applies a received change on the server (or in a local test), and only when it carries an unlock.
private bool EnteredOneWayDoorFromCorrectDirection(IPlayer player)True if the player's head is on the door's forward side.
private void PlaySoundEffectForPlayer(IPlayer player)Plays the door pass sound on the player's head.
private void SyncPlayerUnlockDoorModification(IPlayer player, Stream stream, SpiritModeDoorway.UnlockModificationPair unlockModificationPair)Server: applies a received change, setting the unlock and a checkpoint at the player's feet, or cancelling the unlock.
private void SyncSaveData(IPlayer player, Stream stream)Server to client: sends the unlock, collider size, door mode and one-way flag.
private void UpdateSpiritMode(IPlayer player)Plays the sound and sends the add or remove message if the player qualifies.