diff options
-rw-r--r-- | client/map/item_factory.gd | 24 | ||||
-rw-r--r-- | client/map/items/food_processor.gd | 7 | ||||
-rw-r--r-- | client/map/items/item.gd | 6 | ||||
-rw-r--r-- | client/map/items/nigiri.gd.uid | 1 | ||||
-rw-r--r-- | client/map/items/plate.gd | 5 | ||||
-rw-r--r-- | client/rolled_dough.gd (renamed from client/map/items/nigiri.gd) | 12 | ||||
-rw-r--r-- | client/rolled_dough.gd.uid | 1 |
7 files changed, 37 insertions, 19 deletions
diff --git a/client/map/item_factory.gd b/client/map/item_factory.gd index e38ca108..66b43cb2 100644 --- a/client/map/item_factory.gd +++ b/client/map/item_factory.gd @@ -17,21 +17,24 @@ class_name ItemFactory extends Object class ItemName: + var raw: String var name: String - var contents: Array + var contents: PackedStringArray func _init(raw_name: String): + raw = raw_name var c = Array(raw_name.split(":")) name = c[0] contents = c[1].split(",") if c.size() > 1 else [] static func produce(raw_name: String, owned_by: Node3D) -> Item: - var item: Item = produce_inner(raw_name, owned_by) + var name = ItemName.new(raw_name) + var item: Item = produce_inner(name, owned_by) + item.add_contents(name.contents) item.item_name = raw_name return item -static func produce_inner(raw_name: String, owned_by: Node3D) -> Item: - var item = ItemName.new(raw_name) +static func produce_inner(item: ItemName, owned_by: Node3D) -> Item: match item.name: "bun": return Bun.new(owned_by) "cheese": return Cheese.new(owned_by) @@ -52,7 +55,7 @@ static func produce_inner(raw_name: String, owned_by: Node3D) -> Item: "noodles": return GenericItem.new(owned_by, preload("res://map/items/noodles.tscn")) "rolled-dough": return GenericItem.new(owned_by, preload("res://map/items/rolled_dough.tscn")) "strawberry-mochi": return Mochi.new(owned_by, Color(.98, .70, .75)) - "nigiri": return Nigiri.new(owned_by) + "nigiri": return GenericItem.new(owned_by, preload("res://map/items/nigiri.tscn")) "steak": return GenericItem.new(owned_by, preload("res://map/items/steak.tscn")) "seared-steak": return GenericItem.new(owned_by, preload("res://map/items/seared_steak.tscn")) "patty": return GenericItem.new(owned_by, preload("res://map/items/patty.tscn")) @@ -66,15 +69,18 @@ static func produce_inner(raw_name: String, owned_by: Node3D) -> Item: "sliced-lettuce": return SlicedLettuce.new(owned_by) "potato": return Potato.new(owned_by) "sliced-potato": return GenericItem.new(owned_by, preload("res://map/items/sliced_potato.tscn")) - "dirty-plate": return Plate.new(owned_by, ["dirt"]) + "dirty-plate": + var plate = Plate.new(owned_by) + plate.add_contents(["dirt"]) + return plate "pot": return Pot.new(owned_by, item.contents) "basket": return Basket.new(owned_by, item.contents) "pan": return Pan.new(owned_by, item.contents) - "foodprocessor": return FoodProcessor.new(owned_by, item.contents) + "foodprocessor": return FoodProcessor.new(owned_by) "glass": return Glass.new(owned_by, item.contents) - "plate": return Plate.new(owned_by, item.contents) + "plate": return Plate.new(owned_by) "unknown-order": return GenericItem.new(owned_by, preload("res://map/items/unknown_order.tscn")) - _: return UnknownItem.new(owned_by, raw_name) + _: return UnknownItem.new(owned_by, item.raw) diff --git a/client/map/items/food_processor.gd b/client/map/items/food_processor.gd index 4932b791..f3ae0b9e 100644 --- a/client/map/items/food_processor.gd +++ b/client/map/items/food_processor.gd @@ -19,11 +19,12 @@ extends Item var time := 0. var processing: CPUParticles3D = load("res://map/items/processing.tscn").instantiate() -func _init(owned_by_: Node3D, contents: Array): +func _init(owned_by_: Node3D): super(owned_by_) add_child(load("res://map/items/food_processor.tscn").instantiate()) add_child(processing) - + +func add_contents(contents: Array[String]): for i in contents: match i: "milk": @@ -55,7 +56,7 @@ func _init(owned_by_: Node3D, contents: Array): base.add_child(load("res://map/items/tomato.tscn").instantiate()) "tomato-juice": add_child(FoodProcessorFill.new(self, Color(1., .0, .0))) - _: push_error("Food processor fill not implemented: %s" % contents) + _: super([i]) func _process(delta: float): super(delta) diff --git a/client/map/items/item.gd b/client/map/items/item.gd index 5a43af2d..44482c9b 100644 --- a/client/map/items/item.gd +++ b/client/map/items/item.gd @@ -57,6 +57,12 @@ func _init(owned_by_: Node3D): add_child(base) owned_by = owned_by_ +func add_contents(contents: Array[String]): + for i in contents: + match i: + _: + base.add_child(ItemFactory.produce(i, self)) + func animate_spawn(): creation_timer = 0.0 scale = Vector3.ONE * 0.001 # setting to zero breaks assertions somewhere in the engine diff --git a/client/map/items/nigiri.gd.uid b/client/map/items/nigiri.gd.uid deleted file mode 100644 index c3e9866f..00000000 --- a/client/map/items/nigiri.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bedfy3i7dip8b diff --git a/client/map/items/plate.gd b/client/map/items/plate.gd index d6df1c46..b4ae8baf 100644 --- a/client/map/items/plate.gd +++ b/client/map/items/plate.gd @@ -16,10 +16,11 @@ class_name Plate extends Item -func _init(owned_by_: Node3D, contents: Array): +func _init(owned_by_: Node3D): super(owned_by_) add_child(load("res://map/items/plate.tscn").instantiate()) - + +func add_contents(contents: Array[String]): # Custom logic for handling burgers with buns on bottom and top if contents.has("sliced-bun") and contents.size() > 1: contents.erase("sliced-bun") diff --git a/client/map/items/nigiri.gd b/client/rolled_dough.gd index af18c564..0581fc8c 100644 --- a/client/map/items/nigiri.gd +++ b/client/rolled_dough.gd @@ -13,9 +13,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # -class_name Nigiri +class_name RolledDough extends Item -func _init(owned_by_: Node3D): - super(owned_by_) - base.add_child(load("res://map/items/nigiri.tscn").instantiate()) + +func _init(owned_by_: Node3D, contents: Array): + super(owned_by_, contents) + add_child(load("res://map/items/rolled_dough.tscn").instantiate()) + +func add_contents(contents: Array[String]): + super(contents) diff --git a/client/rolled_dough.gd.uid b/client/rolled_dough.gd.uid new file mode 100644 index 00000000..d42bfec1 --- /dev/null +++ b/client/rolled_dough.gd.uid @@ -0,0 +1 @@ +uid://dfxkpo2hhts4d |