mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 15:44:23 +00:00
Turn Collectable
into Collectible
, a marker class
This commit is contained in:
parent
d16126b48a
commit
522f0beed8
6 changed files with 26 additions and 34 deletions
|
@ -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])
|
|
@ -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"]
|
13
behaviours/collectible.gd
Normal file
13
behaviours/collectible.gd
Normal file
|
@ -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 = &""
|
|
@ -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 @@
|
|||
<path
|
||||
d="M 288,32 C 288,14.3 273.7,0 256,0 238.3,0 224,14.3 224,32 v 208 c 0,8.8 -7.2,16 -16,16 -8.8,0 -16,-7.2 -16,-16 V 64 c 0,-17.7 -14.3,-32 -32,-32 -17.7,0 -32,14.3 -32,32 v 272 c 0,1.5 0,3.1 0.1,4.6 L 67.6,283 c -16,-15.2 -41.3,-14.6 -56.6,1.4 -15.3,16 -14.6,41.3 1.4,56.6 l 112.4,107 c 43.1,41.1 100.4,64 160,64 H 304 c 97.2,0 176,-78.8 176,-176 V 128 c 0,-17.7 -14.3,-32 -32,-32 -17.7,0 -32,14.3 -32,32 v 112 c 0,8.8 -7.2,16 -16,16 -8.8,0 -16,-7.2 -16,-16 V 64 c 0,-17.7 -14.3,-32 -32,-32 -17.7,0 -32,14.3 -32,32 v 176 c 0,8.8 -7.2,16 -16,16 -8.8,0 -16,-7.2 -16,-16 z"
|
||||
id="path1"
|
||||
style="fill:#8da5f3;fill-opacity:1" />
|
||||
style="fill:#e0e0e0;fill-opacity:1" />
|
||||
</svg>
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -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]
|
||||
|
6
behaviours/collectible.tscn
Normal file
6
behaviours/collectible.tscn
Normal file
|
@ -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")
|
Loading…
Reference in a new issue