From 522f0beed8a8afb97822fbf74d167f53c968d057 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 21 Apr 2024 23:13:02 +0200 Subject: [PATCH] Turn `Collectable` into `Collectible`, a marker class --- behaviours/collectable.gd | 18 ------------------ behaviours/collectable.tscn | 9 --------- behaviours/collectible.gd | 13 +++++++++++++ .../{collectable.svg => collectible.svg} | 8 ++++---- ...table.svg.import => collectible.svg.import} | 6 +++--- behaviours/collectible.tscn | 6 ++++++ 6 files changed, 26 insertions(+), 34 deletions(-) delete mode 100644 behaviours/collectable.gd delete mode 100644 behaviours/collectable.tscn create mode 100644 behaviours/collectible.gd rename behaviours/{collectable.svg => collectible.svg} (92%) rename behaviours/{collectable.svg.import => collectible.svg.import} (74%) create mode 100644 behaviours/collectible.tscn diff --git a/behaviours/collectable.gd b/behaviours/collectable.gd deleted file mode 100644 index 42cd58b..0000000 --- a/behaviours/collectable.gd +++ /dev/null @@ -1,18 +0,0 @@ -@icon("res://behaviours/collectable.svg") -extends Area2D -class_name Collectable - -## Emits [signal collected] when the mouse enters the given [CollisionShape2D]. - - -signal collected - -@export var qty: int = 1 -@export var tag: StringName = &"" - - -func _on_mouse_entered() -> void: - collected.emit(tag) - -func _on_collected() -> void: - Log.p(self, "Collected: %sx %s" % [qty, tag]) diff --git a/behaviours/collectable.tscn b/behaviours/collectable.tscn deleted file mode 100644 index 775501a..0000000 --- a/behaviours/collectable.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dj72yshd25ucx"] - -[ext_resource type="Script" path="res://behaviours/collectable.gd" id="1_p0pc3"] - -[node name="Collectable" type="Area2D"] -script = ExtResource("1_p0pc3") - -[connection signal="collected" from="." to="." method="_on_collected"] -[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] diff --git a/behaviours/collectible.gd b/behaviours/collectible.gd new file mode 100644 index 0000000..2ed6967 --- /dev/null +++ b/behaviours/collectible.gd @@ -0,0 +1,13 @@ +@icon("res://behaviours/collectible.svg") +extends Node +class_name Collectible + + +## Marker class that stores the value of a collectible item. + + +## How many of that item this [Collectible] represents. +@export var quantity: int = 1 + +## What kind of item this [Collectible] represents. +@export var kind: StringName = &"" \ No newline at end of file diff --git a/behaviours/collectable.svg b/behaviours/collectible.svg similarity index 92% rename from behaviours/collectable.svg rename to behaviours/collectible.svg index 1625126..699f33f 100644 --- a/behaviours/collectable.svg +++ b/behaviours/collectible.svg @@ -3,7 +3,7 @@ viewBox="0 0 512 512" version="1.1" id="svg1" - sodipodi:docname="hand.svg" + sodipodi:docname="collectable.svg" width="16" height="16" inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" @@ -23,8 +23,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="1.1642403" - inkscape:cx="350.01366" - inkscape:cy="213.44391" + inkscape:cx="350.01365" + inkscape:cy="-130.12778" inkscape:window-width="1920" inkscape:window-height="1020" inkscape:window-x="1280" @@ -35,5 +35,5 @@ + style="fill:#e0e0e0;fill-opacity:1" /> diff --git a/behaviours/collectable.svg.import b/behaviours/collectible.svg.import similarity index 74% rename from behaviours/collectable.svg.import rename to behaviours/collectible.svg.import index 70b9a6e..f6b10da 100644 --- a/behaviours/collectable.svg.import +++ b/behaviours/collectible.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://ds6w6y6v8ywg2" -path="res://.godot/imported/collectable.svg-5b05e2ea83b32a2349a97b4d9981d066.ctex" +path="res://.godot/imported/collectible.svg-c540ac452c425e9fd16afd6982ebfbf2.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/collectable.svg" -dest_files=["res://.godot/imported/collectable.svg-5b05e2ea83b32a2349a97b4d9981d066.ctex"] +source_file="res://behaviours/collectible.svg" +dest_files=["res://.godot/imported/collectible.svg-c540ac452c425e9fd16afd6982ebfbf2.ctex"] [params] diff --git a/behaviours/collectible.tscn b/behaviours/collectible.tscn new file mode 100644 index 0000000..906e7e5 --- /dev/null +++ b/behaviours/collectible.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dj72yshd25ucx"] + +[ext_resource type="Script" path="res://behaviours/collectible.gd" id="1_5ipmg"] + +[node name="Collectible" type="Node"] +script = ExtResource("1_5ipmg")