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
|
# Hurry Curry! - a game about cooking
# Copyright 2024 nokoe
#
# 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 Counter
extends FullTile
const COUNTERS: Array = [
"counter",
"pan",
"sink",
"oven",
]
const FLOORS: Array = [
"floor",
"chandelier",
"ceiling-lamp",
"grass",
"table",
"chair"
]
enum CounterKind {
OUTER_CORNER,
STRAIGHT,
STRAIGHT_BACKSPLASH
}
var kind: CounterKind = CounterKind.STRAIGHT
static func interact_target() -> Vector3:
return Vector3(0, 0.5, 0)
func _init(ctx: TileFactory.TileCC):
super(ctx)
var facing: int = 0
var max_series: int = 0
var max_idx: int = 0
for start in range(4):
var series = 0
for i in range(4):
if Counter.is_floor(ctx.neighbors[(start + i) % 4]):
series += 1
else:
break
if series > max_series:
max_series = series
max_idx = start
# we can neither find out whether it is an inner corner nor an outer corner
# backsplash
facing = max_idx
if max_series == 1:
if WallTile.WALLS.has(ctx.neighbors[(max_idx + 2) % 4]):
kind = CounterKind.STRAIGHT_BACKSPLASH
else:
kind = CounterKind.STRAIGHT
elif max_series == 2:
kind = CounterKind.OUTER_CORNER
turn_facing(facing)
static func is_counter(tile_name_t) -> bool:
if tile_name_t == null:
return false
return tile_name_t.ends_with("crate") or COUNTERS.has(tile_name_t)
static func is_floor(floor_name) -> bool:
return FLOORS.has(floor_name)
|