diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-23 20:05:28 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 20:05:28 +0200 |
commit | 3885cbfae528608350804f704dba9c82fdbfd027 (patch) | |
tree | 384a37820cf43d1868493600a8e0566c78b9ab4a /client/map/tiles | |
parent | 93221433e704e1c98cc84c55caefddb85c2d5717 (diff) | |
download | hurrycurry-3885cbfae528608350804f704dba9c82fdbfd027.tar hurrycurry-3885cbfae528608350804f704dba9c82fdbfd027.tar.bz2 hurrycurry-3885cbfae528608350804f704dba9c82fdbfd027.tar.zst |
move files around
Diffstat (limited to 'client/map/tiles')
-rw-r--r-- | client/map/tiles/chair.gd | 28 | ||||
-rw-r--r-- | client/map/tiles/counter.gd | 81 | ||||
-rw-r--r-- | client/map/tiles/counter_base.gd | 27 | ||||
-rw-r--r-- | client/map/tiles/crate.gd | 23 | ||||
-rw-r--r-- | client/map/tiles/cutting_board.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/door.gd | 27 | ||||
-rw-r--r-- | client/map/tiles/floor.gd | 85 | ||||
-rw-r--r-- | client/map/tiles/flour_counter.gd | 26 | ||||
-rw-r--r-- | client/map/tiles/full_tile.gd | 49 | ||||
-rw-r--r-- | client/map/tiles/generic_tile.gd | 33 | ||||
-rw-r--r-- | client/map/tiles/oven.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/raw_steak_crate.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/sink.gd | 27 | ||||
-rw-r--r-- | client/map/tiles/stove.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/table.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/tomato_crate.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/trash.gd | 21 | ||||
-rw-r--r-- | client/map/tiles/wall.gd | 29 | ||||
-rw-r--r-- | client/map/tiles/wall_tile.gd | 74 | ||||
-rw-r--r-- | client/map/tiles/window.gd | 29 |
20 files changed, 685 insertions, 0 deletions
diff --git a/client/map/tiles/chair.gd b/client/map/tiles/chair.gd new file mode 100644 index 00000000..34735fda --- /dev/null +++ b/client/map/tiles/chair.gd @@ -0,0 +1,28 @@ +# Undercooked - 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 Chair +extends Floor + +func _init(rename: String, neighbors: Array): + super(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/map/tiles/counter.gd b/client/map/tiles/counter.gd new file mode 100644 index 00000000..c3032e4f --- /dev/null +++ b/client/map/tiles/counter.gd @@ -0,0 +1,81 @@ +# Undercooked - 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 + +var counters = [ + "counter", + "pan", + "sink", + "oven", +] + +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(rename: String, neighbors: Array): + super(rename, neighbors) + var facing = 0 + var edges = neighbors.duplicate() + for i in range(4): + var i_name = tile_name(edges[i]) + if Counter.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 + + 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")||counters.has(tile_name_t) diff --git a/client/map/tiles/counter_base.gd b/client/map/tiles/counter_base.gd new file mode 100644 index 00000000..ebeebb3b --- /dev/null +++ b/client/map/tiles/counter_base.gd @@ -0,0 +1,27 @@ +# Undercooked - 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 CounterBase +extends Counter + +func _init(rename: String, neighbors: Array): + super(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()) diff --git a/client/map/tiles/crate.gd b/client/map/tiles/crate.gd new file mode 100644 index 00000000..21fae60b --- /dev/null +++ b/client/map/tiles/crate.gd @@ -0,0 +1,23 @@ +# Undercooked - 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 Crate +extends Counter + +static func interact_target() -> Vector3: + return Vector3(0, 0.25, 0) + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) diff --git a/client/map/tiles/cutting_board.gd b/client/map/tiles/cutting_board.gd new file mode 100644 index 00000000..944a7a9f --- /dev/null +++ b/client/map/tiles/cutting_board.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 CuttingBoard +extends CounterBase + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/cuttingboard.tscn").instantiate()) diff --git a/client/map/tiles/door.gd b/client/map/tiles/door.gd new file mode 100644 index 00000000..cfba08b7 --- /dev/null +++ b/client/map/tiles/door.gd @@ -0,0 +1,27 @@ +# Undercooked - 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 Door +extends Floor + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + + var facing = 0 + for i in range(4): + if tile_name(neighbors[i]) == "door": + facing = i % 4 + base.add_child(load("res://models/prefabs/map/door.tscn").instantiate()) + turn_facing(facing) diff --git a/client/map/tiles/floor.gd b/client/map/tiles/floor.gd new file mode 100644 index 00000000..fec68cbd --- /dev/null +++ b/client/map/tiles/floor.gd @@ -0,0 +1,85 @@ +# Undercooked - 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 Floor +extends Node3D + +var base = Node3D.new() +var item: Item = null +var item_base: Node3D + +enum Facing { + NEG_Y = 0, + NEG_X = 1, + Y = 2, + X = 3, +} + +func _init(rename: String, _neighbors: Array): + var floor_tile = load("res://models/prefabs/map/floor_kitchen_small.tscn").instantiate() + floor_tile.position += Vector3(0.5, 0, 0.5) + add_child(floor_tile) + base.name = "Base" + base.position += Vector3(0.5, 0, 0.5) + add_child(base) + self.name = rename + var item_base_ = Node3D.new() + # this method is supposed to be overriden + @warning_ignore("static_called_on_instance") + item_base_.position = interact_target() + item_base_.name = "ItemBase" + base.add_child(item_base_) + item_base = item_base_ + +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] + + +# defines where items go when interacting +static func interact_target() -> Vector3: + return Vector3(0, 0, 0) + +# actions when interacting, e.g. animations +func interact(): + pass + +func progress(p: float, warn: bool): + if item != null: + item.progress(p, warn) + +func finish(warn: bool): + if item != null: + item.finish(warn) + +func put_item(i: Item): + if item != null: + push_error("already holding an item") + set_item(i) + +func set_item(i: Item): + if item != null: + item.queue_free() + item = i + i.owned_by = item_base + +func take_item() -> Item: + var i = item + item = null + return i diff --git a/client/map/tiles/flour_counter.gd b/client/map/tiles/flour_counter.gd new file mode 100644 index 00000000..4bf2b1f3 --- /dev/null +++ b/client/map/tiles/flour_counter.gd @@ -0,0 +1,26 @@ +# Undercooked - 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 FlourCounter +extends CounterBase + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + var bag = load("res://models/prefabs/map/bag.tscn").instantiate() + # this is supposed to be overridden + @warning_ignore("static_called_on_instance") + bag.position = interact_target() + bag.rotation_degrees.y = 45 + base.add_child(bag) diff --git a/client/map/tiles/full_tile.gd b/client/map/tiles/full_tile.gd new file mode 100644 index 00000000..2da54237 --- /dev/null +++ b/client/map/tiles/full_tile.gd @@ -0,0 +1,49 @@ +# Undercooked - 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 FullTile +extends Floor + +var static_body = StaticBody3D.new() +var item: Node3D = null + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + var shape = CollisionShape3D.new() + var box = BoxShape3D.new() + shape.position.y += .5 + shape.shape = box + shape.name = "Box" + static_body.add_child(shape) + static_body.name = "Body" + base.add_child(static_body) + +# defines where items go when interacting +static func interact_target() -> Vector3: + return Vector3(0, 0, 0) + +# actions when interacting, e.g. animations +func interact(): + pass + +func put_item(i: Node3D): + if item != null: + push_error("already holding an item") + item = i + +func take_item() -> Node3D: + var i = item + item = null + return i diff --git a/client/map/tiles/generic_tile.gd b/client/map/tiles/generic_tile.gd new file mode 100644 index 00000000..f7d1b4a7 --- /dev/null +++ b/client/map/tiles/generic_tile.gd @@ -0,0 +1,33 @@ +# Undercooked - 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 GenericTile +extends Floor + +func _init(rename: String, neighbors: Array, kind: String): + super(rename, neighbors) + var mesh = MeshInstance3D.new() + var text = TextMesh.new() + var mat = StandardMaterial3D.new() + text.text = kind + text.font = SystemFont.new() + text.depth = 0 + mesh.mesh = text + mesh.position.y = 1 + mesh.scale = Vector3(3, 3, 3) + mat.billboard_mode = mat.BILLBOARD_ENABLED + mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED + text.material = mat + item_base.add_child(mesh) diff --git a/client/map/tiles/oven.gd b/client/map/tiles/oven.gd new file mode 100644 index 00000000..88da3adb --- /dev/null +++ b/client/map/tiles/oven.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 Oven +extends Counter + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/oven.tscn").instantiate()) diff --git a/client/map/tiles/raw_steak_crate.gd b/client/map/tiles/raw_steak_crate.gd new file mode 100644 index 00000000..8ff93d6b --- /dev/null +++ b/client/map/tiles/raw_steak_crate.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 RawSteakCrate +extends Crate + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/crate_steak.tscn").instantiate()) diff --git a/client/map/tiles/sink.gd b/client/map/tiles/sink.gd new file mode 100644 index 00000000..e4eaff60 --- /dev/null +++ b/client/map/tiles/sink.gd @@ -0,0 +1,27 @@ +# Undercooked - 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 Sink +extends Counter + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + match kind: + CounterKind.STRAIGHT: + base.add_child(load("res://models/prefabs/map/kitchencounter_sink.tscn").instantiate()) + CounterKind.STRAIGHT_BACKSPLASH: + base.add_child(load("res://models/prefabs/map/kitchencounter_sink_backsplash.tscn").instantiate()) + _: + base.add_child(load("res://models/prefabs/map/kitchencounter_sink.tscn").instantiate()) diff --git a/client/map/tiles/stove.gd b/client/map/tiles/stove.gd new file mode 100644 index 00000000..93fad5a3 --- /dev/null +++ b/client/map/tiles/stove.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 Stove +extends Counter + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/stove_single.tscn").instantiate()) diff --git a/client/map/tiles/table.gd b/client/map/tiles/table.gd new file mode 100644 index 00000000..533223a4 --- /dev/null +++ b/client/map/tiles/table.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 Table +extends FullTile + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/table_round_A_small.tscn").instantiate()) diff --git a/client/map/tiles/tomato_crate.gd b/client/map/tiles/tomato_crate.gd new file mode 100644 index 00000000..078d0ba2 --- /dev/null +++ b/client/map/tiles/tomato_crate.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 TomatoCrate +extends Crate + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/crate_tomatoes.tscn").instantiate()) diff --git a/client/map/tiles/trash.gd b/client/map/tiles/trash.gd new file mode 100644 index 00000000..fed1a502 --- /dev/null +++ b/client/map/tiles/trash.gd @@ -0,0 +1,21 @@ +# Undercooked - 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 Trash +extends Crate + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/crate_trash.tscn").instantiate()) diff --git a/client/map/tiles/wall.gd b/client/map/tiles/wall.gd new file mode 100644 index 00000000..0201d4d6 --- /dev/null +++ b/client/map/tiles/wall.gd @@ -0,0 +1,29 @@ +# Undercooked - 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 Wall +extends WallTile + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + match kind: + WallKind.STRAIGHT: + base.add_child(load("res://models/prefabs/map/wall_straight.tscn").instantiate()) + WallKind.OUTER_CORNER: + base.add_child(load("res://models/prefabs/map/wall_corner.tscn").instantiate()) + WallKind.T: + base.add_child(load("res://models/prefabs/map/wall_t.tscn").instantiate()) + WallKind.CROSS: + base.add_child(load("res://models/prefabs/map/wall_cross.tscn").instantiate()) diff --git a/client/map/tiles/wall_tile.gd b/client/map/tiles/wall_tile.gd new file mode 100644 index 00000000..7c9d4305 --- /dev/null +++ b/client/map/tiles/wall_tile.gd @@ -0,0 +1,74 @@ +# Undercooked - 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 WallTile +extends FullTile + +const WALLS: Array = [ + "wall", + "window", + "door" +] + +enum WallKind { + STRAIGHT, + OUTER_CORNER, + T, + CROSS, +} + +var kind: WallKind = WallKind.STRAIGHT +var facing: int = 0 + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + + var edges = neighbors.duplicate() + + var series: int = 0 + var last_series: int = 0 + var adj: Array = [] + + for i in range(4): + var i_name = tile_name(edges[i]) + if is_wall(i_name): + edges[i] = "wall" + else: + edges[i] = tile_name(edges[i]) + + for i in range(4): + if edges[i] != "wall": + last_series += 1 + adj.append(i) + if last_series > series: + series = last_series + else: + last_series = 0 + + var count = 4 - adj.size() + + if series == 1&&count == 2: + facing = adj[0] + kind = WallKind.STRAIGHT + elif series == 2&&count == 2: + facing = adj[0] + kind = WallKind.OUTER_CORNER + elif series == 1&&count == 3: + facing = adj[0] + kind = WallKind.T + elif series == 0&&count == 4: + facing = adj[0] + kind = WallKind.CROSS + turn_facing(facing) diff --git a/client/map/tiles/window.gd b/client/map/tiles/window.gd new file mode 100644 index 00000000..b2926080 --- /dev/null +++ b/client/map/tiles/window.gd @@ -0,0 +1,29 @@ +# Undercooked - 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 WallWindow +extends WallTile + +static func interact_target() -> Vector3: + return Vector3(0, 0.625, 0) + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + match kind: + WallKind.STRAIGHT: + base.add_child(load("res://models/prefabs/map/window.tscn").instantiate()) + WallKind.OUTER_CORNER: + push_warning("There is no corner window!") + base.add_child(load("res://models/prefabs/map/window.tscn").instantiate()) |