Added abstract food class
This commit is contained in:
21
evolve-die-repeat/molecular/food/food.gd
Normal file
21
evolve-die-repeat/molecular/food/food.gd
Normal 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