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.
- Listed in Players and characters
- Inherits or implements
PlayerStateBase - Derived types
DeadToPlayingTransition,DownedToDeadTransition,PlayingToDeadTransition - Documented in Player states
Constructors
| Member | What it is |
|---|---|
DeadState() | Creates a DeadState with default values. |
Fields
4 private and internal fields
| Member | What it is |
|---|---|
private AltaCoroutine animationCoroutine | Client: the running death animation, stopped when the state ends. |
private AltaCoroutine handleDeathCoroutine | Server: the running WaitForRespawnOnServer coroutine. |
private Transform[] hands | The two hand transforms freed from IK when the body falls. |
private static Logger logger | Class logger. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
private DeadStateSettings Settings { get; } | The state's DeadStateSettings (timings, stats to reset, drag). |
Methods
| Member | What 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
| Member | What 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. |