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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# 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 TileFactory
extends Object
class TileName:
var name# : String
var variant #: String?
func _init(raw_name: String):
var c = Array(raw_name.split(":"))
name = c[0]; variant = c[1] if c.size() >= 2 else null # TODO Array.get throws errors
class TileCC:
var tile_name: TileName
var position: Vector2i
var neighbors: Array
var floor_meshers: Dictionary[String, FloorMesher]
var floor_meshers: Dictionary[String, FloorMesher] = {
"floor": FloorMesher.new(Floor.floor_mesh()),
"path": FloorMesher.new(Path.floor_mesh()),
"grass": GrassMesher.new(Grass.floor_mesh()),
"street": FloorMesher.new(Street.floor_mesh())
}
func produce(raw_name: String, position: Vector2i, neighbors: Array) -> Tile:
var tile_name = TileName.new(raw_name)
var ctx := TileCC.new()
ctx.tile_name = tile_name
ctx.position = position
ctx.neighbors = neighbors.map(func(n): return null if n == null else TileName.new(n).name)
ctx.floor_meshers = floor_meshers
match tile_name.name:
"black-hole-counter": return ItemPortal.new(ctx, false)
"black-hole": return PlayerPortal.new(ctx, false)
"book": return Book.new(ctx)
"ceiling-lamp": return CeilingLamp.new(ctx)
"chair": return Chair.new(ctx)
"chandelier": return Chandelier.new(ctx)
"conveyor": return Conveyor.new(ctx)
"counter-window": return CounterWindow.new(ctx)
"counter": return CounterBase.new(ctx)
"cutting-board": return CuttingBoard.new(ctx)
"door": return Door.new(ctx)
"fence": return Fence.new(ctx)
"floor": return Floor.new(ctx)
"freezer": return Freezer.new(ctx)
"grass": return Grass.new(ctx)
"lamp": return Lamp.new(ctx)
"oven": return Oven.new(ctx)
"path": return Path.new(ctx)
"rolling-board": return RollingBoard.new(ctx)
"deep-fryer": return DeepFryer.new(ctx)
"sink": return Sink.new(ctx)
"stove": return Stove.new(ctx)
"street": return Street.new(ctx)
"table": return Table.new(ctx)
"trash": return Trash.new(ctx)
"tree": return ExteriorTree.new(ctx)
"wall-window": return WallWindow.new(ctx)
"wall": return Wall.new(ctx)
"white-hole-counter": return ItemPortal.new(ctx, true)
"white-hole": return PlayerPortal.new(ctx, true)
"house-balcony": return HouseBalcony.new(ctx)
"house-door": return HouseDoor.new(ctx)
"house-oriel": return HouseOriel.new(ctx)
"house-wall": return HouseWall.new(ctx)
"house-side": return HouseSide.new(ctx)
"house-roof": return HouseRoof.new(ctx)
"house-roof-chimney": return HouseRoofChimney.new(ctx)
"bun-crate": return BunCrate.new(ctx)
"cheese-crate": return CheeseCrate.new(ctx)
"coconut-crate": return CoconutCrate.new(ctx)
"fish-crate": return FishCrate.new(ctx)
"flour-crate": return FlourCrate.new(ctx)
"leek-crate": return LeekCrate.new(ctx)
"lettuce-crate": return LettuceCrate.new(ctx)
"steak-crate": return SteakCrate.new(ctx)
"rice-crate": return RiceCrate.new(ctx)
"strawberry-crate": return StrawberryCrate.new(ctx)
"tomato-crate": return TomatoCrate.new(ctx)
"potato-crate": return PotatoCrate.new(ctx)
var t:
push_warning("tile %s unknown" % t)
return UnknownTile.new(ctx)
|