summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortpart <tpart120@proton.me>2024-09-08 14:25:39 +0200
committertpart <tpart120@proton.me>2024-09-08 14:25:39 +0200
commite659c39776829a134a2514cf76347f69b53a38e8 (patch)
treed6149aeb456e43bd9ff0b393069e42c50c13ce7b
parent8fdf05cb714e0e8ce852405bdeb98752127e3e94 (diff)
downloadhurrycurry-e659c39776829a134a2514cf76347f69b53a38e8.tar
hurrycurry-e659c39776829a134a2514cf76347f69b53a38e8.tar.bz2
hurrycurry-e659c39776829a134a2514cf76347f69b53a38e8.tar.zst
Implement item stacking system
-rw-r--r--client/map/items/item.gd3
-rw-r--r--client/map/items/plate.gd10
-rw-r--r--client/map/items/plate_fill.gd2
-rw-r--r--client/map/items/plate_fill.tscn2
4 files changed, 13 insertions, 4 deletions
diff --git a/client/map/items/item.gd b/client/map/items/item.gd
index 59789d94..c7c06b05 100644
--- a/client/map/items/item.gd
+++ b/client/map/items/item.gd
@@ -77,3 +77,6 @@ func put():
static func base_position() -> Vector3:
return Vector3(0., 0., 0.)
+
+static func height() -> float:
+ return 0.1
diff --git a/client/map/items/plate.gd b/client/map/items/plate.gd
index 3d5aa7a6..7019bcf8 100644
--- a/client/map/items/plate.gd
+++ b/client/map/items/plate.gd
@@ -20,10 +20,16 @@ extends Item
func _init(owned_by_: Node3D, contents: Array[String]):
super(owned_by_)
add_child(load("res://map/items/plate.tscn").instantiate())
+
+ var height_sum := 0.
for c in contents:
+ var item: Item
match c:
- "tomato-soup": add_child(PlateFill.new(self, Color(1., .3, .2)))
- _: base.add_child(ItemFactory.produce(c, base))
+ "tomato-soup": item = PlateFill.new(self, Color(1., .3, .2))
+ _: item = ItemFactory.produce(c, base)
+ base.add_child(item)
+ item.position.y = height_sum
+ height_sum += item.height()
func setup_sounds():
take_sound.setup([preload("res://map/items/sounds/plate_take.ogg")])
diff --git a/client/map/items/plate_fill.gd b/client/map/items/plate_fill.gd
index 1ac8aa87..c56de565 100644
--- a/client/map/items/plate_fill.gd
+++ b/client/map/items/plate_fill.gd
@@ -16,7 +16,7 @@
class_name PlateFill
extends Item
-var fill: MeshInstance3D = load("res://map/items/plate_fill.tscn").instantiate()
+var fill: Node3D = load("res://map/items/plate_fill.tscn").instantiate()
func _init(owned_by_: Node3D, c: Color):
super(owned_by_)
diff --git a/client/map/items/plate_fill.tscn b/client/map/items/plate_fill.tscn
index 1ba34231..290e8994 100644
--- a/client/map/items/plate_fill.tscn
+++ b/client/map/items/plate_fill.tscn
@@ -6,7 +6,7 @@
resource_local_to_scene = true
[node name="PlateFill" type="MeshInstance3D"]
-transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
+transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.04, 0)
mesh = ExtResource("1_dgygv")
skeleton = NodePath("")
surface_material_override/0 = SubResource("StandardMaterial3D_q0leg")