Skip to main content

DeadState

A class in Root.Township, Alta.PlayerStates.

The player state while dead. The server logs the killer, drops or destroys held and docked items, saves, then respawns the player after a delay. Clients play the death animation.

Constructors​

MemberWhat it is
DeadState()Creates a DeadState with default values.

Fields​

4 private and internal fields
MemberWhat it is
private AltaCoroutine animationCoroutineClient: the running death animation, stopped when the state ends.
private AltaCoroutine handleDeathCoroutineServer: the running WaitForRespawnOnServer coroutine.
private Transform[] handsThe two hand transforms freed from IK when the body falls.
private static Logger loggerClass logger.

Properties​

MemberWhat it is
DamageData KillingImpact { get; set; }The damage that killed the player. Its direction pushes the body in the death animation.
override string Name { get; set; }"Dead State".
override PlayerStateType StateType { get; }PlayerStateType.Dead.
1 private and internal property
MemberWhat it is
private DeadStateSettings Settings { get; }The state's DeadStateSettings (timings, stats to reset, drag).

Methods​

MemberWhat it is
override bool ValidateStateActivation(bool isDuringSaving)Refuses the state while saving, and moves the player back to playing instead.
protected override void OnActivate()Server: logs the kill, fires PlayerKilled, drops or destroys carried items, resets stats, saves and starts the respawn timer.
protected override void OnActivateRemote(bool isPlayerCharacterSpawned)Clients: stops interacting, turns off IK, plays the death animation and sound, and adds to the local player's deaths stat.
protected override void OnDeactivate()Server: stops the respawn timer.
protected override void OnDeactivateRemote(bool isPlayerCharacterSpawned)Clients: stops the death animation.
protected override void Sync(IPlayer player, Stream stream)Tells the dead player's client to fade to black before respawn.
5 private and internal methods
MemberWhat it is
private void AnimateBodyWithKillingBlow(BodyController body)Adds rigidbodies to the body and hands and pushes them along the killing hit's direction (or head forward).
private void DestroyPickups()Server: when drop on death is off, destroys items in the player's docks and held items that would be saved.
private void DropPickups()Server: when DropAllOnDeath is on, forces both hands to let go and undocks everything above the player's head.
private void Respawn()Server: destroys the old player controller and entities, then transitions to the playing state.
private IEnumerator WaitForRespawnOnServer() (iterator)Server coroutine: waits the fog and respawn time, tells the client to fade, waits the fade, then respawns.