27 lines
419 B
GDScript3
27 lines
419 B
GDScript3
|
extends CharacterBody2D
|
||
|
class_name Bunny
|
||
|
|
||
|
@export var health : int
|
||
|
|
||
|
var team : int
|
||
|
|
||
|
var on_death_callbacks : Array
|
||
|
|
||
|
func damage(damage : int):
|
||
|
health -= health
|
||
|
if(health <= 0): on_death()
|
||
|
pass
|
||
|
|
||
|
func heal(health : int):
|
||
|
health += health
|
||
|
pass
|
||
|
|
||
|
func on_death():
|
||
|
for callback in on_death_callbacks:
|
||
|
callback.call(self)
|
||
|
pass
|
||
|
|
||
|
func sub_on_death(callback : Callable):
|
||
|
on_death_callbacks.push_front(callback)
|
||
|
pass
|