notSpore/evolve-die-repeat/shared/npc/npc2D.gd

39 lines
1.1 KiB
GDScript

extends CharacterBody2D
class_name NPC2D
@export var maxHealth: int = 0
var health: int = maxHealth
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
spawn()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func spawn() -> void:
pass
func take_damage(dmg: int) -> void:
self.health -= dmg;
if self.health < 0:
self.die()
# I think the move per npc is to model concrete behaviours in functions.
# How the npc acts can be determined elsewhere, these functions just implement the behvaiour
func flee(direction: Vector3) -> void:
push_error("Function flee() not implemented.")
# Im envisioning we feed on "sustenance (to be classed)" only; when something dies it should spawn some sustenance
func feed(source ) -> void:
push_error("Function feed() not implemented.")
func die() -> void:
queue_free()
# TODO: should associate this class with a loot table (or equivalent), and can then implement logic for dying in parent class here.
func move(destination: Vector3) -> void:
push_error("Function move() not implemented.")