Skip to main content

CombatState

A class in Root.Township, Alta.PlayerStates.

The player state while fighting, a sub-state of playing. Ends by itself after a timer that resets whenever the player is in combat again; shows a combat shell on clients.

Constructors​

MemberWhat it is
CombatState(PlayingState playingState)Creates a CombatState from playingState.

Fields​

3 private and internal fields
MemberWhat it is
private float currentOutOfCombatTimerSeconds left until the player leaves combat. Reset by hits and saved to disk.
private AltaCoroutine getOutOfCombatCoroutineThe running GetOutOfCombat coroutine.
private static Logger loggerClass logger.

Properties​

MemberWhat it is
override string Name { get; set; }"Combat State".
CombatStateSettings Settings { get; }The combat state's settings (timer, distance curve, shell, cripple stat).
override PlayerStateType StateType { get; }PlayerStateType.Combat.

Methods​

MemberWhat it is
void ResetCurrentCombatTimer(float distanceSquared)Restarts the out of combat timer, scaled by a curve over how far apart the fighters are.
override void SerializeDisk(Stream stream)Saves and loads the time left on the out of combat timer.
override bool ValidateStateActivation(bool isDuringLoading)Refuses to start combat while the player is loading.
protected override void OnActivate()Server: allows combat to combat transitions and starts the out of combat timer.
protected override void OnActivateRemote(bool isPlayerCharacterSpawned)Client: shows the combat shell and, for the local player, plays the enter combat sound.
protected override void OnDeactivate()Server: clears the locomotion cooldown, refills the cripple stat and stops the timer.
protected override void OnDeactivateRemote(bool isPlayerCharacterSpawned)Client: hides the combat shell (if alive) and plays the wave effect.
3 private and internal methods
MemberWhat it is
private IEnumerator GetOutOfCombat() (iterator)Coroutine that counts the out of combat timer down to zero, then ends the state.
private void PlaySound()Starts PlaySoundCoroutine.
private IEnumerator PlaySoundCoroutine() (iterator)Waits DelayBetweenHitAndSound, then plays the enter combat sound at the player's head.