inventaire fonctionnel #13

This commit is contained in:
Altaezio
2025-08-03 19:38:46 +02:00
committed by Zacharie Guet
parent b164141d00
commit bca2300443
16 changed files with 112 additions and 46 deletions

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="GetSeedInteraction" load_steps=2 format=3 uid="uid://chmmu2jlo2eu0"]
[ext_resource type="Script" uid="uid://j5xvcabrspyb" path="res://entities/interactables/scripts/actions/get_seed.gd" id="1_ys78p"]
[resource]
script = ExtResource("1_ys78p")
metadata/_custom_type_script = "uid://j5xvcabrspyb"

View File

@@ -0,0 +1,8 @@
extends InteractableAction
class_name GetSeedInteraction
func action(p: Player, i : Interactable):
if i is Plant:
p.inventory.add_item(i.seed_item)
else :
printerr("No plant selected or interactable is not a plant")

View File

@@ -0,0 +1 @@
uid://j5xvcabrspyb

View File

@@ -1,8 +1,8 @@
extends InteractableAction
class_name WaterPlantAction
func action(_p: Player, _i : Interactable):
if _i is Plant:
_i.watered = true
func action(_p: Player, i : Interactable):
if i is Plant:
i.watered = true
else :
printerr("No plant selected or interactable is not a plant")

View File

@@ -1,7 +1,7 @@
extends Area2D
class_name Interactable
@export var actions : Array[InteractableAction] = [];
@export var actions : Array[InteractableAction] = []
func interact(p : Player):
for a in actions: