blob: 173a9355e98e954b5a2291fc2fee06b55cabfd37 (
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
|
# 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 WallTile
extends Floor
const WALLS: Array = [
"wall",
"wall-window",
"counter-window",
"door",
"fence"
]
var walls: Array = WALLS
var env: Array = []
enum WallKind {
STRAIGHT,
OUTER_CORNER,
T,
CROSS,
}
var kind: WallKind = WallKind.STRAIGHT
var facing: int = 0
func _init(ctx: TileFactory.TileCC):
super(ctx)
var max_series: int = 0
var max_idx: int = 0
for start in range(4):
var series = 0
for i in range(4):
var i_name = ctx.neighbors[(start + i) % 4]
if is_wall(i_name):
series += 1
else:
break
if series > max_series:
max_series = series
max_idx = start
if max_series == 1:
facing = max_idx
kind = WallKind.STRAIGHT
if not env.is_empty() and env.has(ctx.neighbors[(facing + 1) % 4]) or ctx.neighbors[(facing + 1) % 4] == null:
facing = (facing + 2) % 4
elif max_series == 2:
facing = max_idx
kind = WallKind.OUTER_CORNER
elif max_series == 3:
facing = max_idx
kind = WallKind.T
elif max_series == 4:
facing = max_idx
kind = WallKind.CROSS
turn_facing(facing)
func is_wall(tile_name_t) -> bool:
return walls.has(tile_name_t)
|