SpiritState
A class in Root.Township, Alta.PlayerStates.
Player state for spirit mode during a climbing challenge (a PlayerUnlock with orbs to collect). Hunger and docks are off, weight comes from the orbs, and falls send you back to the checkpoint. Sits on PlayingState.
- Listed in Players and characters
- Inherits or implements
PlayerStateBase<PlayingState> - Derived types
PlayingToSpiritTransition,SpiritToPlayingTransition - Documented in Player states
Constructors
| Member | What it is |
|---|---|
SpiritState(PlayingState playingState) | Creates a SpiritState from playingState. |
Fields
4 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<uint, GameObject> beltOrbs | Orb objects shown on the player's body, by orb index. |
private LocomotionController locomotion | The controller's locomotion, watched for position changes on the server. |
private PlayerHealth playerHealth | The player's health, whose damage is handled by this state. |
private PlayerWeight weight | The player's PlayerWeight. Its weight is overridden and its docks hidden while in spirit mode. |
Properties
| Member | What it is |
|---|---|
override string Name { get; set; } | "Spirit State". |
SpiritStateSettings Settings { get; } | The SpiritStateSettings asset (hunger stat, snap distance, sounds, fall damage threshold). |
override PlayerStateType StateType { get; } | PlayerStateType.Spirit. |
Methods
| Member | What it is |
|---|---|
protected override void OnActivate() | Server: adds the spirit-to-playing transition. |
protected override void OnActivateRemote(bool isPlayerCharacterSpawned) | Client: plays the enter-spirit sound and glow on the player. |
protected override void OnDeactivateRemote(bool isPlayerCharacterSpawned) | Client: plays the exit-spirit sound and glow. |
protected override void OnPlayerControllerFound(PlayerController playerController, bool isFromOnActivate) | Marks the character as a spirit, turns off hunger and docks, hooks damage and unlock changes. On the server, moving too far from the checkpoint cancels the unlock. |
protected override void OnPlayerControllerLost(bool isFromOnDeactivate) | Undoes the spirit setup: hunger, docks and weight back to normal, belt orbs removed. |
8 private and internal methods
| Member | What it is |
|---|---|
private bool CanPlaySfx(SoundEffectSet spiritModeStateSfx) | True when the sound set exists and the player has a controller. |
private void HandleDamage(DamageState damageState) | Swallows all damage. Big command or fall damage ends the state if no unlock is running, or teleports to the checkpoint. |
private void MovedOutOfBounds(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function) | Server: cancels the unlock when the player moves further than SnapDistance from the unlock checkpoint. |
private void PlaySoundEffectForPlayer(SoundEffectSet spiritModeStateSfx) | Plays a sound on the player's head. |
private void PlaySpiritModeGlow(bool isEnteringSpiritMode) | Plays the enter or exit spirit mode effect, except on headless builds. |
private void RemoveSpiritMode(PlayerController player) | Cancels the player's current unlock, which ends spirit mode. |
private void ResetPlayerToLastCheckpoint() | Teleports the player back to the unlock's checkpoint. |
private void UnlocksModified() | Spawns and removes the orbs on the player's belt and sets carried weight from them. Server ends the state when no unlock is active. |