(wip) First food commit

This commit is contained in:
Martin committed 2026-02-07 13:23:54 +01:00
1 parent 22ffa3dac1
commit 098348b329
7 files changed
+35 -6

No files matched your search

+2 -2
View File
@@ -2,14 +2,14 @@
class_name AbstractFood
extends Area2D
@export var val: int = 10
@export var val: int = 1
@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"):
if body.has_method("collect_resource"): # TODO: Define a "consumer" group instead?
eat(body)
func eat(consumer: Node2D) -> void:
@@ -0,0 +1,7 @@
extends AbstractFood
class_name FoodMolecular
func apply_effect(consumer: Node2D) -> void:
if consumer.has_method("collect_resource"):
consumer.collect_resource(val) # val is from parent (default 1), override if required
# TODO: *Some cool effect here*
@@ -0,0 +1 @@
uid://cayxffay17o0u
@@ -0,0 +1,14 @@
[gd_scene format=3 uid="uid://dmvmu218pc0pe"]
[ext_resource type="Texture2D" uid="uid://dcedkos6vgv51" path="res://molecular/assets/food/food-normal.png" id="2_68e2u"]
[sub_resource type="CircleShape2D" id="CircleShape2D_0vfbj"]
radius = 5.0
[node name="FoodMol" type="Area2D" unique_id=595352294]
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=762721134]
shape = SubResource("CircleShape2D_0vfbj")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=98693723]
texture = ExtResource("2_68e2u")
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.