aboutsummaryrefslogtreecommitdiff
path: root/client/scripts/map
diff options
context:
space:
mode:
Diffstat (limited to 'client/scripts/map')
-rw-r--r--client/scripts/map/chair.gd13
-rw-r--r--client/scripts/map/counter.gd61
-rw-r--r--client/scripts/map/counter_base.gd13
-rw-r--r--client/scripts/map/cutting_board.gd1
-rw-r--r--client/scripts/map/floor.gd24
-rw-r--r--client/scripts/map/full_tile.gd13
-rw-r--r--client/scripts/map/table.gd6
-rw-r--r--client/scripts/map/trash.gd6
-rw-r--r--client/scripts/map/wall.gd6
-rw-r--r--client/scripts/map/wall_tile.gd10
10 files changed, 153 insertions, 0 deletions
diff --git a/client/scripts/map/chair.gd b/client/scripts/map/chair.gd
new file mode 100644
index 00000000..e51d7864
--- /dev/null
+++ b/client/scripts/map/chair.gd
@@ -0,0 +1,13 @@
+class_name Chair
+extends Floor
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ var chair = load("res://models/prefabs/map/chair_A.tscn").instantiate()
+ var facing = 0;
+ for i in range(4):
+ if tile_name(neighbors[i]) == "table":
+ facing = i
+ break
+ base.add_child(chair)
+ turn_facing(facing)
diff --git a/client/scripts/map/counter.gd b/client/scripts/map/counter.gd
new file mode 100644
index 00000000..686369cf
--- /dev/null
+++ b/client/scripts/map/counter.gd
@@ -0,0 +1,61 @@
+class_name Counter
+extends FullTile
+
+var counters = [
+ "counter",
+ "pan",
+ "sink",
+ "oven",
+]
+
+enum CounterKind {
+ OUTER_CORNER,
+ STRAIGHT,
+ STRAIGHT_BACKSPLASH
+}
+
+var facing: int = 0
+var kind: CounterKind = CounterKind.STRAIGHT
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ var edges = neighbors.duplicate()
+ for i in range(4):
+ var i_name = tile_name(edges[i])
+ if is_counter(i_name):
+ edges[i] = "counter"
+ else:
+ edges[i] = tile_name(edges[i])
+
+ var series: int = 0
+ var last_series: int = 0
+ var adj: Array = []
+
+ for i in range(4):
+ if edges[i] == "floor":
+ last_series += 1
+ adj.append(i)
+ if last_series > series:
+ series = last_series
+ else:
+ last_series = 0
+
+ var count = 4 - adj.size()
+
+ # we can neither find out whether it is an inner corner nor an outer corner
+ # backsplash
+ if series == 1&&count == 3:
+ facing = adj[0] % 4
+
+ if edges[(adj[0] + 2) % 4] == "wall":
+ kind = CounterKind.STRAIGHT_BACKSPLASH
+ else:
+ kind = CounterKind.STRAIGHT
+ elif series == 2&&count == 2:
+ facing = (adj[0] + 1) % 4
+ kind = CounterKind.OUTER_CORNER
+
+func is_counter(tile_name_t) -> bool:
+ if tile_name_t == null:
+ return false
+ return name.ends_with("crate")||counters.has(name)
diff --git a/client/scripts/map/counter_base.gd b/client/scripts/map/counter_base.gd
new file mode 100644
index 00000000..32f5cc06
--- /dev/null
+++ b/client/scripts/map/counter_base.gd
@@ -0,0 +1,13 @@
+extends Counter
+class_name CounterBase
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ match kind:
+ CounterKind.OUTER_CORNER:
+ base.add_child(load("res://models/prefabs/map/kitchencounter_outercorner.tscn").instantiate())
+ CounterKind.STRAIGHT:
+ base.add_child(load("res://models/prefabs/map/kitchencounter_straight_A.tscn").instantiate())
+ CounterKind.STRAIGHT_BACKSPLASH:
+ base.add_child(load("res://models/prefabs/map/kitchencounter_straight_A_backsplash.tscn").instantiate())
+ turn_facing(facing)
diff --git a/client/scripts/map/cutting_board.gd b/client/scripts/map/cutting_board.gd
new file mode 100644
index 00000000..4be394d0
--- /dev/null
+++ b/client/scripts/map/cutting_board.gd
@@ -0,0 +1 @@
+extends CounterBase
diff --git a/client/scripts/map/floor.gd b/client/scripts/map/floor.gd
new file mode 100644
index 00000000..d4e61c2d
--- /dev/null
+++ b/client/scripts/map/floor.gd
@@ -0,0 +1,24 @@
+class_name Floor
+extends Node3D
+
+var base = Node3D.new()
+
+enum Facing {
+ NEG_Y = 0,
+ NEG_X = 1,
+ Y = 2,
+ X = 3,
+}
+
+func setup(rename: String, _neighbors: Array):
+ add_child(load("res://models/prefabs/map/floor_kitchen_small.tscn").instantiate())
+ add_child(base)
+ self.name = rename
+
+func turn_facing(facing: Facing):
+ base.rotate_y(facing * 0.5 * PI + PI)
+
+func tile_name(idx):
+ if idx == null:
+ return null
+ return Multiplayer.tile_names[idx]
diff --git a/client/scripts/map/full_tile.gd b/client/scripts/map/full_tile.gd
new file mode 100644
index 00000000..c05e0457
--- /dev/null
+++ b/client/scripts/map/full_tile.gd
@@ -0,0 +1,13 @@
+class_name FullTile
+extends Floor
+
+var static_body = StaticBody3D.new()
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ var shape = CollisionShape3D.new()
+ var box = BoxShape3D.new()
+ shape.position.y += .5
+ shape.shape = box
+ static_body.add_child(shape)
+ base.add_child(static_body)
diff --git a/client/scripts/map/table.gd b/client/scripts/map/table.gd
new file mode 100644
index 00000000..937ef097
--- /dev/null
+++ b/client/scripts/map/table.gd
@@ -0,0 +1,6 @@
+class_name Table
+extends FullTile
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ base.add_child(load("res://models/prefabs/map/table_round_A_small.tscn").instantiate())
diff --git a/client/scripts/map/trash.gd b/client/scripts/map/trash.gd
new file mode 100644
index 00000000..1ec05e49
--- /dev/null
+++ b/client/scripts/map/trash.gd
@@ -0,0 +1,6 @@
+class_name Trash
+extends FullTile
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ base.add_child(load("res://models/prefabs/map/crate_trash.tscn").instantiate())
diff --git a/client/scripts/map/wall.gd b/client/scripts/map/wall.gd
new file mode 100644
index 00000000..dd6d3495
--- /dev/null
+++ b/client/scripts/map/wall.gd
@@ -0,0 +1,6 @@
+class_name Wall
+extends WallTile
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ base.add_child(load("res://models/prefabs/map/wall.tscn").instantiate())
diff --git a/client/scripts/map/wall_tile.gd b/client/scripts/map/wall_tile.gd
new file mode 100644
index 00000000..d107d73e
--- /dev/null
+++ b/client/scripts/map/wall_tile.gd
@@ -0,0 +1,10 @@
+class_name WallTile
+extends FullTile
+
+func setup(rename: String, neighbors: Array):
+ super.setup(rename, neighbors)
+ var facing = 0
+ for i in range(4):
+ if neighbors[i] != null&&tile_name(neighbors[i]) != "wall":
+ facing = i
+ turn_facing(facing)