Added abstract food class
This commit is contained in:
parent
66233d8fad
commit
6094980d00
|
|
@ -0,0 +1,21 @@
|
||||||
|
@abstract
|
||||||
|
class_name AbstractFood
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
@export var val: int = 10
|
||||||
|
@export var food_name: String = "Food"
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
body_entered.connect(_on_body_entered)
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
|
if body.is_in_group("player"):
|
||||||
|
eat(body)
|
||||||
|
|
||||||
|
func eat(consumer: Node2D) -> void:
|
||||||
|
print("Player ate: ", food_name)
|
||||||
|
apply_effect(consumer)
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func apply_effect(consumer: Node2D) -> void:
|
||||||
|
pass
|
||||||
Loading…
Reference in New Issue