Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HealthComponent

Makes the entity have health and damageable. When the health reaches zero, the entity is destroed

Hierarchy

Index

Constructors

constructor

Methods

addIncomingDamage

  • addIncomingDamage(amount: any): void
  • Predicts incoming damage, this is used so that for example arrow towers do not shoot projectiles towards enemies which will die anyways.

    Parameters

    • amount: any

    Returns void

changeMaxHealth

  • changeMaxHealth(maxHealth: any): void
  • Changes the base max health. @see setMaxHealthMultiplier for more details

    Parameters

    • maxHealth: any

    Returns void

damage

  • damage(amount: any): void
  • Damages the entity with the given amount of damage. Not supposed to get called directly, instead a damage form should call this

    Parameters

    • amount: any

    Returns void

deserialize

  • deserialize(data: any): any

getDebugString

  • getDebugString(): string

getPercentage

  • getPercentage(): number
  • Returns the current health as a percentage from 0 to 1

    Returns number

regenerate

  • regenerate(amount: any): void
  • Regenerates the given amount of health

    Parameters

    • amount: any

    Returns void

serialize

  • serialize(): object

setMaxHealthMultiplier

  • setMaxHealthMultiplier(multiplier: any): void
  • The max health multiplier is the multiplier which is used to calculate the maximum health. The reason this is splitted is due to the global health enhancement. The health component has a base max health, and also stores a multiplier. When changing the base max health or the multiplier, the effective max health is recomputed. This method sets the multiplier.

    Parameters

    • multiplier: any

    Returns void

willDieFromIncomingDamage

  • willDieFromIncomingDamage(): boolean
  • Returns if this entity will die at some point from the incoming damage, so we don't have to damage further

    Returns boolean

    true if the entity will die

Static getCachedSchema

  • getCachedSchema(): any

Static getId

  • getId(): string
  • Returns string

Static getSchema

  • getSchema(): object

Static verify

  • verify(data: any): string