#13 inventaire fonctionnel
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://clpcqkdlj3d8e"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://clpcqkdlj3d8e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cega715smavh3" path="res://entities/interactables/plants/scripts/plant.gd" id="1_d8u7e"]
|
||||
[ext_resource type="Resource" uid="uid://lrl2okkhyxmx" path="res://common/inventory/resources/items/default_seed.tres" id="2_5foug"]
|
||||
[ext_resource type="Script" uid="uid://yutflvdgdk04" path="res://entities/interactables/scripts/interactable_action.gd" id="2_rs46h"]
|
||||
[ext_resource type="Resource" uid="uid://bk0kop0m75pjy" path="res://entities/interactables/resources/actions/default_water_plant.tres" id="3_5foug"]
|
||||
[ext_resource type="Texture2D" uid="uid://c6vby5r0pfni2" path="res://entities/interactables/plants/assets/sprites/default_plant.png" id="4_dq24f"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/interactables/plants/assets/sprites/default_plant_glowing.png" id="5_2gcie"]
|
||||
[ext_resource type="Resource" uid="uid://chmmu2jlo2eu0" path="res://entities/interactables/resources/actions/default_get_seed.tres" id="5_5foug"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_cdbrd"]
|
||||
|
||||
@@ -29,7 +31,8 @@ animations = [{
|
||||
|
||||
[node name="DefaultPlant" type="Area2D"]
|
||||
script = ExtResource("1_d8u7e")
|
||||
actions = Array[ExtResource("2_rs46h")]([ExtResource("3_5foug")])
|
||||
seed_item = ExtResource("2_5foug")
|
||||
actions = Array[ExtResource("2_rs46h")]([ExtResource("3_5foug"), ExtResource("5_5foug")])
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(4.01154, 4.01154)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
extends Interactable
|
||||
class_name Plant
|
||||
|
||||
var watered : bool = false : set = set_watered
|
||||
@export var seed_item : GenericItem
|
||||
|
||||
var watered: bool = false: set = set_watered
|
||||
|
||||
func set_watered(_watered):
|
||||
watered = _watered
|
||||
|
||||
@@ -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"
|
||||
8
entities/interactables/scripts/actions/get_seed.gd
Normal file
8
entities/interactables/scripts/actions/get_seed.gd
Normal 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")
|
||||
1
entities/interactables/scripts/actions/get_seed.gd.uid
Normal file
1
entities/interactables/scripts/actions/get_seed.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://j5xvcabrspyb
|
||||
@@ -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")
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user