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.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
NetworkEntityBehaviour,ITeleportAwareTrigger,IDontSplit,IForcedPresenceOnServer,ISavable<SpiritModeDoorwaySaveData>,ISavableSave<SpiritModeDoorwaySaveData>,ISavableSaveBase - Derived types
SpiritModeDoorwaySaveData - Nested types
UnlockModificationPair
Constructors
| Member | What it is |
|---|---|
SpiritModeDoorway() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private BoxCollider boxCollider | Trigger collider of the doorway. Its size is saved and synced. |
private SpiritModeDoorwayMode doorwayMode | Whether the door adds or removes spirit mode. |
private bool isOneWayDoor | When true, teleporting through only counts from the door's forward side. |
private PlayerUnlock playerUnlock | The unlock given as spirit mode. |
private SoundEffectSet spiritDoorPassSfx | Sound played when a player passes through and their mode changes. |
private MethodSyncStruct<SpiritModeDoorway.UnlockModificationPair> syncPlayerUnlockDoorModification | Method sync for the add or remove unlock message. |
private MethodSync syncSaveData | Method sync for the door settings. |
Methods
| Member | What 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
| Member | What 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. |