From e659c39776829a134a2514cf76347f69b53a38e8 Mon Sep 17 00:00:00 2001 From: tpart Date: Sun, 8 Sep 2024 14:25:39 +0200 Subject: Implement item stacking system --- client/map/items/plate.gd | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'client/map/items/plate.gd') 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")]) -- cgit v1.2.3-70-g09d2