aboutsummaryrefslogtreecommitdiff
path: root/client/map/item_factory.gd
blob: 200de874e769fb00e35e82b4c9371bef0cc5c433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Hurry Curry! - a game about cooking
# Copyright (C) 2025 Hurry Curry! contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# 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 ItemFactory
extends Object

class ItemName:
	var raw: String
	var name: String
	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 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(item: ItemName, owned_by: Node3D) -> Item:
	match item.name:
		"bun": return Bun.new(owned_by)
		"cheese": return Cheese.new(owned_by)
		"cooked-noodles": return GenericItem.new(owned_by, preload("res://map/items/cooked_noodles.tscn"))
		"dirt": return GenericItem.new(owned_by, preload("res://map/items/dirt.tscn"))
		"sliced-bun": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun.tscn"))
		"sliced-bun-top": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun_top.tscn"))
		"sliced-bun-bottom": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun_bottom.tscn"))
		"burned": return Burned.new(owned_by)
		"coconut": return GenericItem.new(owned_by, preload("res://map/items/coconut.tscn"))
		"dough": return GenericItem.new(owned_by, preload("res://map/items/dough.tscn"))
		"fish": return GenericItem.new(owned_by, preload("res://map/items/fish.tscn"))
		"flour": return GenericItem.new(owned_by, preload("res://map/items/flour.tscn"))
		"leek": return GenericItem.new(owned_by, preload("res://map/items/leek.tscn"))
		"mushroom": return GenericItem.new(owned_by, preload("res://map/items/mushroom.tscn"))
		"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 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"))
		"seared-patty": return GenericItem.new(owned_by, preload("res://map/items/seared_patty.tscn"))
		"rice": return GenericItem.new(owned_by, preload("res://map/items/rice.tscn"))
		"sliced-fish": return GenericItem.new(owned_by, preload("res://map/items/sliced_fish.tscn"))
		"strawberry": return Strawberry.new(owned_by)
		"lettuce": return GenericItem.new(owned_by, preload("res://map/items/lettuce.tscn"))
		"tomato": return Tomato.new(owned_by) # TODO: move into choppable class / move code into cutting_board
		"sliced-leek": return GenericItem.new(owned_by, preload("res://map/items/sliced_leek/sliced_leek.tscn"), 0.05)
		"sliced-lettuce": return GenericItem.new(owned_by, preload("res://map/items/sliced_lettuce.tscn"), 0.05)
		"sliced-cheese": return GenericItem.new(owned_by, preload("res://map/items/sliced_cheese.tscn"), 0.05)
		"sliced-tomato": return GenericItem.new(owned_by, preload("res://map/items/sliced_tomato.tscn"), 0.05)
		"potato": return Potato.new(owned_by)
		"sliced-potato": return GenericItem.new(owned_by, preload("res://map/items/sliced_potato.tscn"))
		"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)
		"glass": return Glass.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, item.raw)