Class Damageable
This class handles the player's ability to take damage, die, and respawn. It also manages interactions like blocking, parrying, and dropping items when hit.
Inheritance
Namespace: Player
Assembly: cs.temp.dll.dll
Syntax
public class Damageable : MonoBehaviour
Fields
damage
The current accumulated damage of the player.
Declaration
public float damage
Field Value
| Type | Description |
|---|---|
| float |
damageSelfDebug
If true, applies damage to self for debugging purposes.
Declaration
public bool damageSelfDebug
Field Value
| Type | Description |
|---|---|
| bool |
dying
Indicates whether the player is currently dying.
Declaration
public bool dying
Field Value
| Type | Description |
|---|---|
| bool |
force
The force applied to the player when hit.
Declaration
public float force
Field Value
| Type | Description |
|---|---|
| float |
lives
The number of lives the player has.
Declaration
public int lives
Field Value
| Type | Description |
|---|---|
| int |
maxDamage
The maximum damage the player can take before dying.
Declaration
public float maxDamage
Field Value
| Type | Description |
|---|---|
| float |
Methods
Damage(float)
Adds a specified amount of damage to the player.
Declaration
public void Damage(float damage)
Parameters
| Type | Name | Description |
|---|---|---|
| float | damage | The amount of damage to add. |
HandleDeath()
Handles player state after death and resets dying state after respawn.
Declaration
public void HandleDeath()
ResetDamage()
Resets the player's damage to zero.
Declaration
public void ResetDamage()
Respawn()
Respawns the player at the spawn position and resets damage/health bar.
Declaration
public void Respawn()
Events
OnPlayerDeath
Event triggered when a player dies.
Declaration
public event Action<GameObject> OnPlayerDeath
Event Type
| Type | Description |
|---|---|
| System.Action<T><GameObject> |
OnPlayerPunched
Event triggered when the player is punched.
Declaration
public event Action<GameObject> OnPlayerPunched
Event Type
| Type | Description |
|---|---|
| System.Action<T><GameObject> |
OnPlayerRespawn
Event triggered when a player respawns.
Declaration
public event Action<GameObject> OnPlayerRespawn
Event Type
| Type | Description |
|---|---|
| System.Action<T><GameObject> |