Added abstract food class

This commit is contained in:
Martin committed 2026-02-03 21:10:39 +01:00
1 parent 66233d8fad
commit 6094980d00
1 file changed
+21
+21
View File
@@ -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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.