diff options
Diffstat (limited to 'client/map')
-rw-r--r-- | client/map/item.gd | 56 | ||||
-rw-r--r-- | client/map/map.gd | 77 | ||||
-rw-r--r-- | client/map/progress.gd | 22 | ||||
-rw-r--r-- | client/map/progress.gdshader | 28 | ||||
-rw-r--r-- | client/map/progress.tscn | 18 | ||||
-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 |
25 files changed, 886 insertions, 0 deletions
diff --git a/client/map/item.gd b/client/map/item.gd new file mode 100644 index 00000000..74e08c48 --- /dev/null +++ b/client/map/item.gd @@ -0,0 +1,56 @@ +# 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 Item +extends Node3D + +var owned_by: Node3D + +var progress_instance: ProgressBar3D = preload("res://scenes/progress.tscn").instantiate() + +func _init(idx: int, owned_by_: Node3D): + progress_instance.position.y = 2. + add_child(progress_instance) + progress_instance.visible = false + match Multiplayer.item_names[idx]: + var t: + add_child(load("res://models/prefabs/map/bag.tscn").instantiate()) + var mesh = MeshInstance3D.new() + var text = TextMesh.new() + var mat = StandardMaterial3D.new() + text.text = t + text.font = SystemFont.new() + text.depth = 0 + mesh.mesh = text + mesh.position.y = 0.5 + mesh.scale = Vector3(3, 3, 3) + mat.billboard_mode = mat.BILLBOARD_ENABLED + mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED + text.material = mat + add_child(mesh) + owned_by = owned_by_ + +func _ready(): + position = owned_by.global_position + +func _process(delta): + position = lerp(position, owned_by.global_position, delta * 30.0) + +func progress(p: float, warn: bool): + progress_instance.visible = true + progress_instance.set_progress(p, warn) + +func finish(_warn: bool): + progress_instance.visible = false diff --git a/client/map/map.gd b/client/map/map.gd new file mode 100644 index 00000000..b5e519a6 --- /dev/null +++ b/client/map/map.gd @@ -0,0 +1,77 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# Copyright 2024 tpart +# Copyright 2024 metamuffin +# +# 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/>. +# +@tool +class_name Map +extends Node3D + +var tile_by_pos: Dictionary = {} + +func _ready(): + Multiplayer.connect("update_map", update) + +func update(pos, tile_name, neighbors): + var instance: Floor + var node_name = str(pos) + + if has_node(node_name): + queue_free_rename(get_node(node_name)) + + match tile_name: + "trash": + instance = Trash.new(node_name, neighbors) + "tomato-crate": + instance = TomatoCrate.new(node_name, neighbors) + "cuttingboard": + instance = CuttingBoard.new(node_name, neighbors) + "counter": + instance = CounterBase.new(node_name, neighbors) + "flour-crate": + instance = FlourCounter.new(node_name, neighbors) + "oven": + instance = Oven.new(node_name, neighbors) + "raw-steak-crate": + instance = RawSteakCrate.new(node_name, neighbors) + "stove": + instance = Stove.new(node_name, neighbors) + "sink": + instance = Sink.new(node_name, neighbors) + "dirty-plate-crate": + instance = CounterBase.new(node_name, neighbors) + "wall": + instance = Wall.new(node_name, neighbors) + "chair": + instance = Chair.new(node_name, neighbors) + "table": + instance = Table.new(node_name, neighbors) + "floor": + instance = Floor.new(node_name, neighbors) + "window": + instance = WallWindow.new(node_name, neighbors) + "door": + instance = Door.new(node_name, neighbors) + var t: + push_warning("tile tile %s unknown" % t) + instance = GenericTile.new(node_name, neighbors, t) + + instance.position = Vector3(pos[0], 0, pos[1]) + tile_by_pos[str(Vector2i(pos[0],pos[1]))] = instance + add_child(instance) + +func queue_free_rename(node: Node) -> void: + node.name += "_queued_free" + node.queue_free() diff --git a/client/map/progress.gd b/client/map/progress.gd new file mode 100644 index 00000000..4d6494f6 --- /dev/null +++ b/client/map/progress.gd @@ -0,0 +1,22 @@ +# 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 ProgressBar3D +extends MeshInstance3D + +func set_progress(progress: float, bad: bool): + var mat: ShaderMaterial = self.get_active_material(0) + mat.set_shader_parameter("progress", progress) + mat.set_shader_parameter("bad", bad) diff --git a/client/map/progress.gdshader b/client/map/progress.gdshader new file mode 100644 index 00000000..0bf3e04a --- /dev/null +++ b/client/map/progress.gdshader @@ -0,0 +1,28 @@ +shader_type spatial; + +uniform float progress = 0.; +uniform bool bad = false; + +void fragment() { + vec3 color = vec3(0., 1., 0.); + float alpha_fac = 1.; + if (bad) { + color = vec3(1., 0., 0.); + alpha_fac = sin(TIME * 15.) * .5 + 1.; + } + if (UV.x > progress) { + ALPHA = 0.1; + } + ALPHA *= alpha_fac; + ALBEDO = color; +} + +void vertex() { + mat4 modified_model_view = VIEW_MATRIX * mat4( + INV_VIEW_MATRIX[0], + INV_VIEW_MATRIX[1], + INV_VIEW_MATRIX[2], + MODEL_MATRIX[3] + ); + MODELVIEW_MATRIX = modified_model_view; +} diff --git a/client/map/progress.tscn b/client/map/progress.tscn new file mode 100644 index 00000000..273beb74 --- /dev/null +++ b/client/map/progress.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=5 format=3 uid="uid://4ewufm6tqhpb"] + +[ext_resource type="Shader" path="res://textures/progress.gdshader" id="1_6f2a0"] +[ext_resource type="Script" path="res://scripts/progress.gd" id="2_bb3u3"] + +[sub_resource type="QuadMesh" id="QuadMesh_m0itj"] +size = Vector2(0.75, 0.1) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_4k6cy"] +render_priority = 0 +shader = ExtResource("1_6f2a0") +shader_parameter/progress = 0.0 +shader_parameter/bad = false + +[node name="Progress" type="MeshInstance3D"] +mesh = SubResource("QuadMesh_m0itj") +surface_material_override/0 = SubResource("ShaderMaterial_4k6cy") +script = ExtResource("2_bb3u3") 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()) |