From 3885cbfae528608350804f704dba9c82fdbfd027 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 23 Jun 2024 20:05:28 +0200 Subject: move files around --- client/game.gd | 110 +++++++++++++++++ client/game.tscn | 40 ++++++ client/map/item.gd | 56 +++++++++ client/map/map.gd | 77 ++++++++++++ client/map/progress.gd | 22 ++++ client/map/progress.gdshader | 28 +++++ client/map/progress.tscn | 18 +++ client/map/tiles/chair.gd | 28 +++++ client/map/tiles/counter.gd | 81 ++++++++++++ client/map/tiles/counter_base.gd | 27 ++++ client/map/tiles/crate.gd | 23 ++++ client/map/tiles/cutting_board.gd | 21 ++++ client/map/tiles/door.gd | 27 ++++ client/map/tiles/floor.gd | 85 +++++++++++++ client/map/tiles/flour_counter.gd | 26 ++++ client/map/tiles/full_tile.gd | 49 ++++++++ client/map/tiles/generic_tile.gd | 33 +++++ client/map/tiles/oven.gd | 21 ++++ client/map/tiles/raw_steak_crate.gd | 21 ++++ client/map/tiles/sink.gd | 27 ++++ client/map/tiles/stove.gd | 21 ++++ client/map/tiles/table.gd | 21 ++++ client/map/tiles/tomato_crate.gd | 21 ++++ client/map/tiles/trash.gd | 21 ++++ client/map/tiles/wall.gd | 29 +++++ client/map/tiles/wall_tile.gd | 74 +++++++++++ client/map/tiles/window.gd | 29 +++++ client/menu/credits_menu.gd | 19 +++ client/menu/credits_menu.tscn | 83 +++++++++++++ client/menu/main_menu.gd | 49 ++++++++ client/menu/main_menu.tscn | 89 ++++++++++++++ client/menu/menu_background.gd | 35 ++++++ client/menu/scene_transition.gd | 28 +++++ client/menu/scene_transition.tscn | 71 +++++++++++ client/multiplayer.gd | 205 +++++++++++++++++++++++++++++++ client/player/character.gd | 28 +++++ client/player/controllable_player.gd | 110 +++++++++++++++++ client/player/follow_camera.gd | 65 ++++++++++ client/player/follow_camera.tscn | 7 ++ client/player/interact_marker.gdshader | 27 ++++ client/player/marker.gd | 23 ++++ client/player/marker.tscn | 53 ++++++++ client/player/mirror.gd | 31 +++++ client/player/player.gd | 81 ++++++++++++ client/player/player.tscn | 15 +++ client/scenes/credits_menu.tscn | 83 ------------- client/scenes/follow_camera.tscn | 7 -- client/scenes/game.tscn | 40 ------ client/scenes/main_menu.tscn | 89 -------------- client/scenes/marker.tscn | 53 -------- client/scenes/player.tscn | 15 --- client/scenes/progress.tscn | 18 --- client/scenes/scene_transition.tscn | 71 ----------- client/scripts/character.gd | 28 ----- client/scripts/controllable_player.gd | 110 ----------------- client/scripts/credits_menu.gd | 19 --- client/scripts/follow_camera.gd | 65 ---------- client/scripts/game.gd | 110 ----------------- client/scripts/item.gd | 56 --------- client/scripts/main_menu.gd | 49 -------- client/scripts/map.gd | 77 ------------ client/scripts/marker.gd | 23 ---- client/scripts/menu_background.gd | 35 ------ client/scripts/mirror.gd | 31 ----- client/scripts/multiplayer.gd | 205 ------------------------------- client/scripts/player.gd | 81 ------------ client/scripts/progress.gd | 22 ---- client/scripts/scene_transition.gd | 28 ----- client/scripts/socket_test.gd | 22 ---- client/scripts/tiles/chair.gd | 28 ----- client/scripts/tiles/counter.gd | 81 ------------ client/scripts/tiles/counter_base.gd | 27 ---- client/scripts/tiles/crate.gd | 23 ---- client/scripts/tiles/cutting_board.gd | 21 ---- client/scripts/tiles/door.gd | 27 ---- client/scripts/tiles/floor.gd | 85 ------------- client/scripts/tiles/flour_counter.gd | 26 ---- client/scripts/tiles/full_tile.gd | 49 -------- client/scripts/tiles/generic_tile.gd | 33 ----- client/scripts/tiles/oven.gd | 21 ---- client/scripts/tiles/raw_steak_crate.gd | 21 ---- client/scripts/tiles/sink.gd | 27 ---- client/scripts/tiles/stove.gd | 21 ---- client/scripts/tiles/table.gd | 21 ---- client/scripts/tiles/tomato_crate.gd | 21 ---- client/scripts/tiles/trash.gd | 21 ---- client/scripts/tiles/wall.gd | 29 ----- client/scripts/tiles/wall_tile.gd | 74 ----------- client/scripts/tiles/window.gd | 29 ----- client/textures/interact_marker.gdshader | 27 ---- client/textures/progress.gdshader | 28 ----- client/themes/styles/focus.tres | 13 -- 92 files changed, 2055 insertions(+), 2090 deletions(-) create mode 100644 client/game.gd create mode 100644 client/game.tscn create mode 100644 client/map/item.gd create mode 100644 client/map/map.gd create mode 100644 client/map/progress.gd create mode 100644 client/map/progress.gdshader create mode 100644 client/map/progress.tscn create mode 100644 client/map/tiles/chair.gd create mode 100644 client/map/tiles/counter.gd create mode 100644 client/map/tiles/counter_base.gd create mode 100644 client/map/tiles/crate.gd create mode 100644 client/map/tiles/cutting_board.gd create mode 100644 client/map/tiles/door.gd create mode 100644 client/map/tiles/floor.gd create mode 100644 client/map/tiles/flour_counter.gd create mode 100644 client/map/tiles/full_tile.gd create mode 100644 client/map/tiles/generic_tile.gd create mode 100644 client/map/tiles/oven.gd create mode 100644 client/map/tiles/raw_steak_crate.gd create mode 100644 client/map/tiles/sink.gd create mode 100644 client/map/tiles/stove.gd create mode 100644 client/map/tiles/table.gd create mode 100644 client/map/tiles/tomato_crate.gd create mode 100644 client/map/tiles/trash.gd create mode 100644 client/map/tiles/wall.gd create mode 100644 client/map/tiles/wall_tile.gd create mode 100644 client/map/tiles/window.gd create mode 100644 client/menu/credits_menu.gd create mode 100644 client/menu/credits_menu.tscn create mode 100644 client/menu/main_menu.gd create mode 100644 client/menu/main_menu.tscn create mode 100644 client/menu/menu_background.gd create mode 100644 client/menu/scene_transition.gd create mode 100644 client/menu/scene_transition.tscn create mode 100644 client/multiplayer.gd create mode 100644 client/player/character.gd create mode 100644 client/player/controllable_player.gd create mode 100644 client/player/follow_camera.gd create mode 100644 client/player/follow_camera.tscn create mode 100644 client/player/interact_marker.gdshader create mode 100644 client/player/marker.gd create mode 100644 client/player/marker.tscn create mode 100644 client/player/mirror.gd create mode 100644 client/player/player.gd create mode 100644 client/player/player.tscn delete mode 100644 client/scenes/credits_menu.tscn delete mode 100644 client/scenes/follow_camera.tscn delete mode 100644 client/scenes/game.tscn delete mode 100644 client/scenes/main_menu.tscn delete mode 100644 client/scenes/marker.tscn delete mode 100644 client/scenes/player.tscn delete mode 100644 client/scenes/progress.tscn delete mode 100644 client/scenes/scene_transition.tscn delete mode 100644 client/scripts/character.gd delete mode 100644 client/scripts/controllable_player.gd delete mode 100644 client/scripts/credits_menu.gd delete mode 100644 client/scripts/follow_camera.gd delete mode 100644 client/scripts/game.gd delete mode 100644 client/scripts/item.gd delete mode 100644 client/scripts/main_menu.gd delete mode 100644 client/scripts/map.gd delete mode 100644 client/scripts/marker.gd delete mode 100644 client/scripts/menu_background.gd delete mode 100644 client/scripts/mirror.gd delete mode 100644 client/scripts/multiplayer.gd delete mode 100644 client/scripts/player.gd delete mode 100644 client/scripts/progress.gd delete mode 100644 client/scripts/scene_transition.gd delete mode 100644 client/scripts/socket_test.gd delete mode 100644 client/scripts/tiles/chair.gd delete mode 100644 client/scripts/tiles/counter.gd delete mode 100644 client/scripts/tiles/counter_base.gd delete mode 100644 client/scripts/tiles/crate.gd delete mode 100644 client/scripts/tiles/cutting_board.gd delete mode 100644 client/scripts/tiles/door.gd delete mode 100644 client/scripts/tiles/floor.gd delete mode 100644 client/scripts/tiles/flour_counter.gd delete mode 100644 client/scripts/tiles/full_tile.gd delete mode 100644 client/scripts/tiles/generic_tile.gd delete mode 100644 client/scripts/tiles/oven.gd delete mode 100644 client/scripts/tiles/raw_steak_crate.gd delete mode 100644 client/scripts/tiles/sink.gd delete mode 100644 client/scripts/tiles/stove.gd delete mode 100644 client/scripts/tiles/table.gd delete mode 100644 client/scripts/tiles/tomato_crate.gd delete mode 100644 client/scripts/tiles/trash.gd delete mode 100644 client/scripts/tiles/wall.gd delete mode 100644 client/scripts/tiles/wall_tile.gd delete mode 100644 client/scripts/tiles/window.gd delete mode 100644 client/textures/interact_marker.gdshader delete mode 100644 client/textures/progress.gdshader delete mode 100644 client/themes/styles/focus.tres (limited to 'client') diff --git a/client/game.gd b/client/game.gd new file mode 100644 index 00000000..eb338eaa --- /dev/null +++ b/client/game.gd @@ -0,0 +1,110 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# 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 . +# +class_name Game +extends Node3D + +@onready var camera: FollowCamera = $FollowCamera +@onready var map: Map = $Map +@onready var marker: Marker = $Marker +var marker_target = Vector3(0,0,0) + +var players := {} +# Called when the node enters the scene tree for the first time. +func _ready(): + await Multiplayer.init + if Multiplayer.player_id == -1: + push_error("multiplayer has not been initialized") + Multiplayer.connect("add_player", + func(player: int, player_name: String, pos: Vector2, character: int): + var player_instance: Player + if player == Multiplayer.player_id: + player_instance = ControllablePlayer.new(player, player_name, pos, character, self) + camera.target = player_instance + else: + player_instance = Player.new(player, player_name, pos, character, self) + players[player] = player_instance + add_child(player_instance) + ) + + Multiplayer.connect("position", + func(player: int, pos: Vector2, rot: float): + var player_instance: Player = players[player] + player_instance.update_position(pos, rot) + ) + + Multiplayer.connect("remove_player", func(id: int): + var player: Player = players.get(id) + if player != null: + if player.hand != null: + player.hand.queue_free() + players.erase(id) + player.queue_free() + ) + + Multiplayer.connect("set_tile_item", func(tile: Vector2i, item: int): + var t: Floor = map.tile_by_pos[str(tile)] + var i = Item.new(item, t.item_base) + add_child(i) + i.name = Multiplayer.item_names[item] + t.set_item(i) + ) + + Multiplayer.connect("remove_tile_item", func(tile: Vector2i): + var t: Floor = map.tile_by_pos[str(tile)] + t.take_item().queue_free() + ) + + Multiplayer.connect("set_player_item", func(player: int, item: int): + var p: Player = players[player] + var i = Item.new(item, p.hand_base) + add_child(i) + i.name = Multiplayer.item_names[item] + p.set_item(i) + ) + + Multiplayer.connect("remove_player_item", func(player: int): + var p: Player = players[player] + p.remove_item().queue_free() + ) + + Multiplayer.connect("take_item", func(tile: Vector2i, player: int): + var t: Floor = map.tile_by_pos[str(tile)] + var p: Player = players[player] + p.take_item(t) + ) + + Multiplayer.connect("put_item", func(tile: Vector2i, player: int): + var t: FullTile = map.tile_by_pos[str(tile)] + var p: Player = players[player] + p.put_item(t) + ) + + Multiplayer.connect("set_progress", func(tile: Vector2i, progress: float, warn: bool): + var t: FullTile = map.tile_by_pos[str(tile)] + t.progress(progress, warn) + ) + + Multiplayer.connect("set_finished", func(tile: Vector2i, warn: bool): + var t: FullTile = map.tile_by_pos[str(tile)] + t.finish(warn) + ) + + Multiplayer.send_join("Blub", 1) + + +func _process(delta): + marker.position = lerp(marker.position, marker_target, delta * 40.0) diff --git a/client/game.tscn b/client/game.tscn new file mode 100644 index 00000000..f5c3c0c4 --- /dev/null +++ b/client/game.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=6 format=3 uid="uid://clsylbmw7jc0s"] +[gd_scene load_steps=7 format=3 uid="uid://clsylbmw7jc0s"] + +[ext_resource type="Script" path="res://scripts/game.gd" id="1_qnslj"] +[ext_resource type="PackedScene" uid="uid://bnqujofthaa4h" path="res://scenes/map.tscn" id="1_qt88a"] +[ext_resource type="PackedScene" uid="uid://b31mlnao6ybt8" path="res://scenes/follow_camera.tscn" id="3_6ot70"] +[ext_resource type="PackedScene" uid="uid://c0euiv7duqfp4" path="res://scenes/marker.tscn" id="5_idjm3"] + +[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_ko0bu"] + +[sub_resource type="Sky" id="Sky_bqb2d"] +sky_material = SubResource("PhysicalSkyMaterial_ko0bu") + +[sub_resource type="Environment" id="Environment_h880f"] +background_mode = 2 +background_energy_multiplier = 2.0 +sky = SubResource("Sky_bqb2d") +tonemap_mode = 2 +ssao_enabled = true +sdfgi_enabled = true +glow_enabled = true + +[node name="Game" type="Node3D"] +script = ExtResource("1_qnslj") + +[node name="Map" parent="." instance=ExtResource("1_qt88a")] + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.951635, -0.266538, 0.152804, -0.154443, 0.0149305, 0.987889, -0.265591, -0.963709, -0.0269565, 0, 0, 0) +shadow_enabled = true + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_h880f") + +[node name="FollowCamera" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_6ot70")] +transform = Transform3D(0.894934, 0.084374, -0.438148, 0, 0.981959, 0.189095, 0.446198, -0.169228, 0.878789, 0, 3.65756, 11.0189) +target = NodePath("../Map") + +[node name="Marker" parent="." instance=ExtResource("5_idjm3")] +visible = false 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 . +# +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 . +# +@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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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 . +# +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()) diff --git a/client/menu/credits_menu.gd b/client/menu/credits_menu.gd new file mode 100644 index 00000000..a48d5461 --- /dev/null +++ b/client/menu/credits_menu.gd @@ -0,0 +1,19 @@ +# Undercooked - a game about cooking +# 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 . +# +extends Control + +func _on_back_pressed(): + $SceneTransition.transition_to("res://scenes/main_menu.tscn") diff --git a/client/menu/credits_menu.tscn b/client/menu/credits_menu.tscn new file mode 100644 index 00000000..65035329 --- /dev/null +++ b/client/menu/credits_menu.tscn @@ -0,0 +1,83 @@ +[gd_scene load_steps=6 format=3 uid="uid://7mqbxa054bjv"] + +[ext_resource type="PackedScene" uid="uid://bgt88u55bndd3" path="res://scenes/menu_background.tscn" id="1_5ay7o"] +[ext_resource type="Script" path="res://scripts/credits_menu.gd" id="1_igs63"] +[ext_resource type="PackedScene" uid="uid://ds1njrptrpdco" path="res://scenes/menu_background_scene.tscn" id="2_k0853"] +[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://scenes/scene_transition.tscn" id="4_fbbdb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p2qmw"] +bg_color = Color(0, 0, 0, 0.576471) + +[node name="CreditsMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_igs63") + +[node name="MenuBackground" parent="." instance=ExtResource("1_5ay7o")] +layout_mode = 1 +script = null + +[node name="background_view2" type="SubViewport" parent="MenuBackground"] +handle_input_locally = false +size = Vector2i(1152, 648) +render_target_update_mode = 4 + +[node name="scene" parent="MenuBackground/background_view2" instance=ExtResource("2_k0853")] + +[node name="Panel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_p2qmw") + +[node name="RichTextLabel" type="RichTextLabel" parent="Panel"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -222.0 +offset_top = -112.0 +offset_right = 222.0 +offset_bottom = 125.0 +grow_horizontal = 2 +grow_vertical = 2 +bbcode_enabled = true +text = "[center][b]undercooked - a game about cooking[/b] + +by + +[b]tpart, nokoe, metamuffin[/b] + +using assets from kenney.nl + +[/center]" + +[node name="back" type="Button" parent="Panel"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -79.0 +offset_top = -65.0 +offset_right = 81.0 +offset_bottom = -34.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Back" + +[node name="SceneTransition" parent="." instance=ExtResource("4_fbbdb")] +layout_mode = 1 +color = Color(0, 0, 0, 1) + +[connection signal="pressed" from="Panel/back" to="." method="_on_back_pressed"] diff --git a/client/menu/main_menu.gd b/client/menu/main_menu.gd new file mode 100644 index 00000000..df09cf7f --- /dev/null +++ b/client/menu/main_menu.gd @@ -0,0 +1,49 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# Copyright 2024 tpart +# +# 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 . +# +extends Control + +@onready var quick_connect = $side/margin/options/quick_connect +@onready var quit_button = $side/margin/options/quit + +func _ready(): + quick_connect.grab_focus() + if OS.has_feature("web"): + quit_button.hide() + +func _on_quit_pressed(): + get_tree().quit() + +func _on_credits_pressed(): + $SceneTransition.transition_to("res://scenes/credits_menu.tscn") + +func _on_connect_pressed(): + connect_to($side/options/connect/uri.text) + +func _on_quick_connect_pressed(): + if OS.has_feature("JavaScript"): + connect_to(JavaScriptBridge.eval(""" + window.location.protocol.endsWith("s:") + ? `wss://${window.location.host}/` + : `ws://${window.location.hostname}:27032/` + """)) + else: + connect_to("wss://undercooked.metamuffin.org/") + +func connect_to(url): + print("Connecting to %s" % url) + Multiplayer.url = url + $SceneTransition.transition_to("res://scenes/game.tscn") diff --git a/client/menu/main_menu.tscn b/client/menu/main_menu.tscn new file mode 100644 index 00000000..ea9b31fb --- /dev/null +++ b/client/menu/main_menu.tscn @@ -0,0 +1,89 @@ +[gd_scene load_steps=7 format=3 uid="uid://dbj8508whxgwv"] + +[ext_resource type="Theme" uid="uid://cnhhreuc4shxv" path="res://scenes/theme.tres" id="1_rmwly"] +[ext_resource type="Script" path="res://scripts/main_menu.gd" id="2_qot2j"] +[ext_resource type="PackedScene" uid="uid://bgt88u55bndd3" path="res://scenes/menu_background.tscn" id="3_f3j3x"] +[ext_resource type="PackedScene" uid="uid://ds1njrptrpdco" path="res://scenes/menu_background_scene.tscn" id="4_ydj5p"] +[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://scenes/scene_transition.tscn" id="5_651nk"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d8o0f"] +bg_color = Color(0, 0, 0, 0.329412) + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_rmwly") +script = ExtResource("2_qot2j") + +[node name="MenuBackground" parent="." instance=ExtResource("3_f3j3x")] +layout_mode = 1 +script = null + +[node name="background_view2" type="SubViewport" parent="MenuBackground"] +handle_input_locally = false +size = Vector2i(1152, 648) +render_target_update_mode = 4 + +[node name="scene" parent="MenuBackground/background_view2" instance=ExtResource("4_ydj5p")] + +[node name="side" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 9 +anchor_bottom = 1.0 +offset_right = 340.0 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_d8o0f") + +[node name="options" type="VBoxContainer" parent="side"] +layout_mode = 2 + +[node name="quick_connect" type="Button" parent="side/options"] +layout_mode = 2 +text = "Quick Connect" +alignment = 0 + +[node name="connect" type="HBoxContainer" parent="side/options"] +layout_mode = 2 + +[node name="uri" type="LineEdit" parent="side/options/connect"] +layout_mode = 2 +size_flags_horizontal = 3 +placeholder_text = "wss://example.org" + +[node name="connect" type="Button" parent="side/options/connect"] +layout_mode = 2 +text = "Connect" + +[node name="change_character" type="Button" parent="side/options"] +layout_mode = 2 +text = "Select Character (todo)" +alignment = 0 + +[node name="settings" type="Button" parent="side/options"] +layout_mode = 2 +text = "Settings (todo)" +alignment = 0 + +[node name="credits" type="Button" parent="side/options"] +layout_mode = 2 +text = "Credits" +alignment = 0 + +[node name="quit" type="Button" parent="side/options"] +layout_mode = 2 +text = "Quit" +alignment = 0 + +[node name="SceneTransition" parent="." instance=ExtResource("5_651nk")] +layout_mode = 1 + +[connection signal="pressed" from="side/options/quick_connect" to="." method="_on_quick_connect_pressed"] +[connection signal="pressed" from="side/options/connect/connect" to="." method="_on_connect_pressed"] +[connection signal="pressed" from="side/options/change_character" to="." method="_on_credits_pressed"] +[connection signal="pressed" from="side/options/settings" to="." method="_on_credits_pressed"] +[connection signal="pressed" from="side/options/credits" to="." method="_on_credits_pressed"] +[connection signal="pressed" from="side/options/quit" to="." method="_on_quit_pressed"] diff --git a/client/menu/menu_background.gd b/client/menu/menu_background.gd new file mode 100644 index 00000000..e5b8ac31 --- /dev/null +++ b/client/menu/menu_background.gd @@ -0,0 +1,35 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# Copyright 2024 tpart +# +# 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 . +# +@tool +extends Node3D + +@onready var map = $map +@onready var voxel_gi: VoxelGI = $VoxelGI + +const NULLS = [null,null,null,null] +const BUCKETS = [[], ["floor","floor","floor","floor","tomato-crate", "raw-steak-crate"], ["table", "chair", "counter"], ["sink", "stove"]] + +func _ready(): + for x in range(-10,11): + for y in range(-10,11): + var w = exp(-sqrt(x*x+y*y) * 0.15) + var k = randf() * w + var bucket = BUCKETS[int(floor(k * BUCKETS.size())) % BUCKETS.size()] + if bucket.size() == 0: continue + var tile = bucket[randi() % bucket.size()] + map.update([x,y], tile, NULLS) + voxel_gi.bake() diff --git a/client/menu/scene_transition.gd b/client/menu/scene_transition.gd new file mode 100644 index 00000000..b5c89579 --- /dev/null +++ b/client/menu/scene_transition.gd @@ -0,0 +1,28 @@ +# Undercooked - a game about cooking +# 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 . +# +class_name SceneTransition +extends ColorRect + + +@onready var anim = $animation + +func _ready(): + anim.play("fade_in") + +func transition_to(path: String): + anim.play("fade_out") + await anim.animation_finished + get_tree().change_scene_to_file(path) diff --git a/client/menu/scene_transition.tscn b/client/menu/scene_transition.tscn new file mode 100644 index 00000000..0865dddf --- /dev/null +++ b/client/menu/scene_transition.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=6 format=3 uid="uid://bg2d78ycorcqk"] + +[ext_resource type="Script" path="res://scripts/scene_transition.gd" id="1_c2vxm"] + +[sub_resource type="Animation" id="Animation_xgn2a"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0, 0, 0, 1)] +} + +[sub_resource type="Animation" id="Animation_tglmc"] +resource_name = "fade_in" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.9), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_egop8"] +resource_name = "fade_out" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.9), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_pea72"] +_data = { +"RESET": SubResource("Animation_xgn2a"), +"fade_in": SubResource("Animation_tglmc"), +"fade_out": SubResource("Animation_egop8") +} + +[node name="SceneTransition" type="ColorRect"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +color = Color(0, 0, 0, 1) +script = ExtResource("1_c2vxm") + +[node name="animation" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_pea72") +} +speed_scale = 4.0 diff --git a/client/multiplayer.gd b/client/multiplayer.gd new file mode 100644 index 00000000..534ef663 --- /dev/null +++ b/client/multiplayer.gd @@ -0,0 +1,205 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# Copyright 2024 metamuffin +# Copyright 2024 tpart +# +# 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 . +# +extends Node + +signal init(player_id: int) +signal update_map(tile: int, pos: Array, neighbors: Array) +signal clear_message(player: int) +signal text_message(player: int, text: String) +signal item_message(player: int, item: int) +signal add_player(player: int, name: String, pos: Vector2, character: int) +signal remove_player(player: int) +signal position(player: int, position: Vector2, rotation: float) +signal take_item(tile: Vector2i, player: int) +signal put_item(tile: Vector2i, player: int) +signal set_tile_item(tile: Vector2i, item: int) +signal remove_tile_item(tile: Vector2i) +signal set_progress(tile: Vector2i, progress: float, warn: bool) +signal set_finished(tile: Vector2i, warn: bool) + +var connected := false +var socket := WebSocketPeer.new() + +var item_names = [] +var tile_names = [] +var tile_collide = [] +var tile_interact = [] +var item_idx_from_name: Dictionary = {} +var player_id = -1 + +var tileid_by_pos: Dictionary = {} + +func connectClient(url: String): + socket.connect_to_url(url) + connected = true + +func _process(_delta): + if connected: + socket.poll() + var state = socket.get_ready_state() + if state == WebSocketPeer.STATE_OPEN: + while socket.get_available_packet_count(): + handle_packet(socket.get_packet()) + elif state == WebSocketPeer.STATE_CONNECTING: + print("connecting") + elif state == WebSocketPeer.STATE_CLOSING: + # Keep polling to achieve proper close. + print("closing") + pass + elif state == WebSocketPeer.STATE_CLOSED: + var code = socket.get_close_code() + var reason = socket.get_close_reason() + print("WebSocket closed with code: %d, reason %s. Clean: %s" % [code, reason, code != - 1]) + +func handle_packet(bytes: PackedByteArray): + var decoded = decode_packet(bytes) + + if decoded == null: + return + + var packet_type: String = decoded["type"] + match packet_type: + "init": + player_id = decoded["id"] + item_names = decoded["data"]["item_names"] + tile_names = decoded["data"]["tile_names"] + tile_collide = decoded["data"]["tile_collide"] + tile_interact = decoded["data"]["tile_interact"] + for i in range(item_names.size()): + item_idx_from_name[item_names[i]] = i + emit_signal("init", player_id) + "add_player": + var id = decoded["id"] + var player_name = decoded["name"] + var pos = decoded["position"] + var character = decoded["character"] + emit_signal("add_player", id, player_name, pos_to_vec2(pos), character) + "remove_player": + var id = decoded["id"] + emit_signal("remove_player", id) + "position": + var player = decoded["player"] + var pos = decoded["pos"] + var rot = decoded["rot"] + emit_signal("position", player, pos_to_vec2(pos), rot) + "take_item": + var tile = pos_to_vec2i(decoded["tile"]) + var player = decoded["player"] + emit_signal("take_item", tile, player) + "put_item": + var tile = pos_to_vec2i(decoded["tile"]) + var player_id = decoded["player"] + emit_signal("take_item", tile, player_id) + "set_active": + var tile = pos_to_vec2i(decoded["tile"]) + var warn = decoded["warn"] + var progress = decoded.get("progress") + if progress != null: + emit_signal("set_progress", tile, decoded["progress"], warn) + else: + emit_signal("set_finished", tile, warn) + "set_tile_item": + var tile = pos_to_vec2i(decoded["tile"]) + var item = decoded.get("item") + if item != null: + emit_signal("set_tile_item", tile, item) + else: + emit_signal("remove_tile_item", tile) + "set_player_item": + var player = decoded["player"] + var item = decoded.get("item") + if item != null: + emit_signal("set_player_item", player, decoded["item"]) + else: + emit_signal("remove_player_item", player) + "update_map": + var tile: int = decoded["tile"] + var pos: Array = decoded["pos"] + var neighbors: Array = decoded["neighbors"] + tileid_by_pos[str(Vector2i(pos[0],pos[1]))] = tile + emit_signal("update_map", pos, tile_names[tile], neighbors) + "communicate": + var player = decoded["player"] + var message = decoded.get("message") + if message != null: + var item = message.get("item") + var text = message.get("text") + if item != null: + emit_signal("item_message", player, item) + elif text != null: + emit_signal("text_message", player, text) + else: + push_error("neither text nor item provided") + else: + emit_signal("clear_message", player) + "error": + var message = decoded["message"] + push_warning("server error: %s" % message) + _: + push_error("Unrecognized packet type: %s" % packet_type) + +func send_join(player_name: String, character: int): + send_packet({ + "type": "join", + "name": player_name, + "character": character + }) + +func send_position(pos: Vector2, rotation: float): + send_packet({ + "type": "position", + "pos": [pos.x, pos.y], + "rot": rotation + }) + +func send_interact(pos: Vector2i, edge: bool): + send_packet({ + "type": "interact", + "pos": [pos.x, pos.y], + "edge": edge + }) + +func send_packet(packet): + var json = JSON.stringify(packet) + socket.send_text(json) + +func decode_packet(bytes: PackedByteArray): + var json = JSON.new() + var in_str = bytes.get_string_from_utf8() + var error = json.parse(in_str) + if error == OK: + return json.data + else: + print("Decode of packet failed: %s in %s" % [json.get_error_message(), in_str]) + return null + +func pos_to_vec2(pos: Array) -> Vector2: + return Vector2(pos[0], pos[1]) + +func pos_to_vec2i(pos: Array) -> Vector2i: + return Vector2i(pos[0], pos[1]) + +func get_tile_collision(pos: Vector2i) -> bool: + var t = tileid_by_pos.get(str(pos)) + if t == null: return false + else: return tile_collide[t] + +func get_tile_interactive(pos: Vector2i) -> bool: + var t = tileid_by_pos.get(str(pos)) + if t == null: return false + else: return tile_interact[t] diff --git a/client/player/character.gd b/client/player/character.gd new file mode 100644 index 00000000..847bd7b6 --- /dev/null +++ b/client/player/character.gd @@ -0,0 +1,28 @@ +# Undercooked - a game about cooking +# Copyright 2024 tpart +# +# 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 . +# +extends Node3D +class_name Character + +@onready var hand_animations = $HandAnimations + +func _ready(): + play_animation("idle") + +func play_animation(name_: String): + hand_animations.play(name_) + +func _on_hand_animations_animation_finished(name_): + hand_animations.play(name_) diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd new file mode 100644 index 00000000..4c157349 --- /dev/null +++ b/client/player/controllable_player.gd @@ -0,0 +1,110 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# 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 . +# +class_name ControllablePlayer +extends Player + + +const PLAYER_SPEED: float = 25.; + +var facing = Vector2(1, 0) +var velocity_ = Vector2(0, 0) + +var target: Vector2i = Vector2i(0, 0) + +func _ready(): + var timer = Timer.new() + timer.one_shot = false + timer.wait_time = 1. / 25. + add_child(timer) + timer.start() + timer.connect("timeout", func(): + Multiplayer.send_position(Vector2(position.x, position.z), rotation.y) + ) + +func _process(delta): + var input = Vector2(Input.get_axis("left", "right"), Input.get_axis("forward", "backwards")).normalized() + input = input.rotated(-game.camera.angle_target) + position_anim = position_ + rotation_anim = rotation_ + if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"): + input *= 0 + else: + target = Vector2i( + int(floor(position.x + sin(rotation.y))), + int(floor(position.z + cos(rotation.y))) + ) + interact() + update(delta, input) + super(delta) + +func update(dt: float, input: Vector2): + var direction = input.limit_length(1.); + rotation.y = atan2(self.facing.x, self.facing.y); + if direction.length() > 0.1: + self.facing = direction + (self.facing - direction) * exp(-dt * 10.); + self.velocity_ += direction * dt * PLAYER_SPEED; + self.position_ += self.velocity_ * dt; + self.velocity_ = self.velocity_ * exp(-dt * 5.); + collide(dt); + +func collide(dt: float): + for xo in range(-1,2): + for yo in range(-1,2): + var tile = Vector2i(xo, yo) + Vector2i(self.position_); + if !Multiplayer.get_tile_collision(tile): continue + tile = Vector2(tile) + var d = aabb_point_distance(tile, tile + Vector2.ONE, self.position_); + if d > PLAYER_SIZE: continue + var h = 0.01; + var d_sample_x = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(h, 0)); + var d_sample_y = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(0, h)); + var grad = (Vector2(d_sample_x - d, d_sample_y - d)) / h; + + self.position_ += (PLAYER_SIZE - d) * grad; + self.velocity_ -= grad * grad.dot(self.velocity_) + + for player: Player in game.players.values(): + var diff = self.position_ - player.position_ + var d = diff.length() + if d < 0.01: continue + if d >= PLAYER_SIZE * 2: continue + var norm = diff.normalized(); + var f = 100 / (1 + d) + self.velocity_.x += norm.x * f * dt + self.velocity_.y += norm.y * f * dt + +func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float: + return (p - p.clamp(mi, ma)).length() + +func update_position(new_position: Vector2, _new_rotation: float): + if (new_position - position_).length() > 3.: + position_ = new_position + +func interact(): + var tile_idx = str(target) + var t: Floor = game.map.tile_by_pos.get(tile_idx) + if t != null: + game.marker.set_interactive(Multiplayer.get_tile_interactive(target)) + game.marker.visible = true + game.marker_target = t.item_base.global_position + if Input.is_action_just_pressed("interact"): + Multiplayer.send_interact(target, true) + t.interact() + elif Input.is_action_just_released("interact"): + Multiplayer.send_interact(target, false) + else: + game.marker.visible = false diff --git a/client/player/follow_camera.gd b/client/player/follow_camera.gd new file mode 100644 index 00000000..74355688 --- /dev/null +++ b/client/player/follow_camera.gd @@ -0,0 +1,65 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# 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 . +# +class_name FollowCamera +extends Camera3D + +const ROTATE_SPEED: float = 1.5 +const ROTATE_WEIGHT: float = 8.0 +const ROTATE_UP_SPEED: float = 0.7 +const ROTATE_UP_WEIGHT: float = 4.0 +const ANGLE_UP_MIN: float = 0.5 +const ANGLE_UP_MAX: float = 1.2 +const LOOK_WEIGHT: float = 8.0 +const MOVE_WEIGHT: float = 2.0 +const CAMERA_DISTANCE: float = 10 + +@export var target: Node3D + +var angle_target: float = 0 +var angle: float = 0 +var angle_up_target: float = 1 +var angle_up: float = 1 +var ground: Vector3 + +func _ready(): + if target == null: + push_warning("target is not set") + else: + ground = target.position + +func _process(delta): + if target != null: + follow(delta) + +func follow(delta): + var new_transform = transform.looking_at(target.position) + + transform.basis = Basis.from_euler(Vector3( + lerp_angle(transform.basis.get_euler().x, new_transform.basis.get_euler().x, delta * LOOK_WEIGHT), + lerp_angle(transform.basis.get_euler().y, new_transform.basis.get_euler().y, delta * LOOK_WEIGHT), + lerp_angle(transform.basis.get_euler().z, new_transform.basis.get_euler().z, delta * LOOK_WEIGHT) + )) + + angle_target += Input.get_axis("rotate_left", "rotate_right") * ROTATE_SPEED * delta + angle = lerp_angle(angle, angle_target, delta * ROTATE_WEIGHT) + + angle_up_target += Input.get_axis("rotate_down", "rotate_up") * ROTATE_UP_SPEED * delta + angle_up_target = clamp(angle_up_target, ANGLE_UP_MIN, ANGLE_UP_MAX) + angle_up = lerp_angle(angle_up, angle_up_target, delta * ROTATE_UP_WEIGHT) + + ground = ground.lerp(target.position, delta * MOVE_WEIGHT) + position = ground + Vector3(0, sin(angle_up) * CAMERA_DISTANCE, cos(angle_up) * CAMERA_DISTANCE).rotated(Vector3.UP, angle) diff --git a/client/player/follow_camera.tscn b/client/player/follow_camera.tscn new file mode 100644 index 00000000..816563ba --- /dev/null +++ b/client/player/follow_camera.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://b31mlnao6ybt8"] + +[ext_resource type="Script" path="res://scripts/follow_camera.gd" id="1_qipju"] + +[node name="FollowCamera" type="Camera3D"] +fov = 45.0 +script = ExtResource("1_qipju") diff --git a/client/player/interact_marker.gdshader b/client/player/interact_marker.gdshader new file mode 100644 index 00000000..94b7323d --- /dev/null +++ b/client/player/interact_marker.gdshader @@ -0,0 +1,27 @@ +shader_type spatial; + +uniform float max_width = .1; +uniform float marker_length = .5; +uniform float pulse_speed = 4.; +uniform bool interactive = false; + +void fragment() { + if (interactive) { + ALBEDO = vec3(15., 0., 0.); + } else { + ALBEDO = vec3(.1, .1, .1); + } + vec2 uv = abs(2. * UV.xy - 1.); + float m_length = marker_length / max_width; + float anim; + if (interactive) { + anim = sin(TIME * pulse_speed) * .5 + 1.; + } else { + anim = .5; + } + float alpha = step( + 1. - max_width * anim, max(uv.x, uv.y)) + * step(1. - max_width * m_length, min(uv.x, uv.y) + ); + ALPHA = alpha; +} diff --git a/client/player/marker.gd b/client/player/marker.gd new file mode 100644 index 00000000..6e3e6ffa --- /dev/null +++ b/client/player/marker.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 . +# +class_name Marker +extends Node3D + +@onready var _cube: MeshInstance3D = $Cube + +func set_interactive(val: bool): + var mat: ShaderMaterial = _cube.get_active_material(0) + mat.set_shader_parameter("interactive", val) diff --git a/client/player/marker.tscn b/client/player/marker.tscn new file mode 100644 index 00000000..7f21e199 --- /dev/null +++ b/client/player/marker.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=7 format=3 uid="uid://c0euiv7duqfp4"] + +[ext_resource type="Script" path="res://scripts/marker.gd" id="1_3njdu"] +[ext_resource type="Shader" path="res://textures/interact_marker.gdshader" id="2_dejwy"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_o4v68"] + +[sub_resource type="ArrayMesh" id="ArrayMesh_2tdb0"] +_surfaces = [{ +"aabb": AABB(-1, -1, -1, 2, 2, 2.00001), +"format": 34896613377, +"index_count": 36, +"index_data": PackedByteArray(0, 0, 3, 0, 1, 0, 0, 0, 2, 0, 3, 0, 2, 0, 7, 0, 3, 0, 2, 0, 6, 0, 7, 0, 6, 0, 5, 0, 7, 0, 6, 0, 4, 0, 5, 0, 4, 0, 1, 0, 5, 0, 4, 0, 0, 0, 1, 0, 2, 0, 4, 0, 6, 0, 2, 0, 0, 0, 4, 0, 7, 0, 1, 0, 3, 0, 7, 0, 5, 0, 1, 0), +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 8, +"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 255, 255, 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 254, 255, 0, 0, 255, 255, 255, 255, 254, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0) +}] +blend_shape_mode = 0 + +[sub_resource type="ArrayMesh" id="ArrayMesh_2ie13"] +resource_name = "marker_Cube_001" +_surfaces = [{ +"aabb": AABB(-1, -1, -1, 2, 2, 2.00001), +"attribute_data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255), +"format": 34896613399, +"index_count": 36, +"index_data": PackedByteArray(2, 0, 11, 0, 5, 0, 2, 0, 8, 0, 11, 0, 6, 0, 21, 0, 9, 0, 6, 0, 18, 0, 21, 0, 20, 0, 17, 0, 23, 0, 20, 0, 14, 0, 17, 0, 12, 0, 3, 0, 15, 0, 12, 0, 0, 0, 3, 0, 7, 0, 13, 0, 19, 0, 7, 0, 1, 0, 13, 0, 22, 0, 4, 0, 10, 0, 22, 0, 16, 0, 4, 0), +"material": SubResource("StandardMaterial3D_o4v68"), +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 24, +"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 255, 191, 0, 0, 0, 0, 254, 255, 255, 191, 0, 0, 0, 0, 254, 255, 84, 213, 0, 0, 255, 255, 254, 255, 255, 191, 0, 0, 255, 255, 254, 255, 255, 255, 0, 0, 255, 255, 254, 255, 84, 213, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 191, 0, 0, 0, 0, 0, 0, 84, 213, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 84, 213, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 84, 213, 255, 255, 255, 255, 254, 255, 255, 191, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 254, 255, 84, 213, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 191, 255, 255, 0, 0, 0, 0, 84, 213, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 84, 213, 255, 255, 255, 255, 0, 0, 255, 127, 84, 213, 84, 213, 255, 255, 255, 255, 255, 127, 255, 191, 84, 213, 84, 213, 255, 191, 255, 191, 0, 0, 255, 127, 84, 213, 84, 213, 255, 191, 255, 191, 255, 127, 255, 191, 84, 213, 84, 213, 255, 255, 255, 255, 0, 0, 255, 127, 170, 42, 170, 42, 255, 255, 255, 255, 255, 127, 255, 191, 170, 42, 170, 42, 255, 191, 255, 191, 0, 0, 255, 127, 170, 42, 170, 42, 255, 191, 255, 191, 255, 127, 255, 191, 170, 42, 170, 42) +}] +blend_shape_mode = 0 +shadow_mesh = SubResource("ArrayMesh_2tdb0") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_wuj1v"] +render_priority = 0 +shader = ExtResource("2_dejwy") +shader_parameter/max_width = 0.1 +shader_parameter/marker_length = 0.5 +shader_parameter/pulse_speed = 4.0 +shader_parameter/interactive = false + +[node name="Marker" type="Node3D"] +script = ExtResource("1_3njdu") + +[node name="Cube" type="MeshInstance3D" parent="."] +transform = Transform3D(0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0.25, 0) +mesh = SubResource("ArrayMesh_2ie13") +skeleton = NodePath("") +surface_material_override/0 = SubResource("ShaderMaterial_wuj1v") diff --git a/client/player/mirror.gd b/client/player/mirror.gd new file mode 100644 index 00000000..ccec0e65 --- /dev/null +++ b/client/player/mirror.gd @@ -0,0 +1,31 @@ +# Undercooked - a game about cooking +# Copyright 2024 tpart +# +# 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 . +# +@tool + +# Hand mirror helper script, useful for animating characters + +extends Node3D + +@export var enabled := true + +@onready var hand_right = $Main/HandRight +@onready var hand_left = $Main/HandLeft + + +func _process(delta): + if enabled: + hand_right.position = hand_left.position * Vector3(-1,1,1) + hand_right.rotation = hand_left.rotation * Vector3(1, -1, -1) - Vector3(0.2 * PI, 0, 0) diff --git a/client/player/player.gd b/client/player/player.gd new file mode 100644 index 00000000..423855e9 --- /dev/null +++ b/client/player/player.gd @@ -0,0 +1,81 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# Copyright 2024 metamuffin +# Copyright 2024 tpart +# +# 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 . +# +class_name Player +extends Node3D + +const PLAYER_SIZE: float = 0.4 +const SPEED: float = 25. + +var game: Game +var position_ = Vector2(0, 0) + +var mesh = preload("res://scenes/player.tscn").instantiate() + +var hand: Node3D = null + +var _anim_angle: float = 0.0 + +const HAND_BASE_POSITION: Vector3 = Vector3(0, .25, .4) + +@onready var character: Character = $Player/Character + +func _init(_id: int, new_name: String, pos: Vector2, _character: int, new_game: Game): + add_child(mesh) + position_ = pos + name = new_name + game = new_game + +func update_position(new_position: Vector2, new_rotation: float): + position_ = new_position + rotation_ = new_rotation + +func set_item(i: Item): + i.owned_by = hand_base + if i == null: + push_error("tile is null") + hand = i + character.play_animation("hold") + +func remove_item() -> Item: + var i = hand + if i == null: + push_error("holding nothing") + hand = null + character.play_animation("idle") + return i + +func take_item(tile: Floor): + if hand != null: + push_error("already holding an item") + var i = tile.take_item() + if i == null: + push_error("tile is null") + hand = i + +func put_item(tile: Floor): + var i = remove_item() + tile.put_item(i) + +func _process(delta): + _anim_angle = fmod(_anim_angle + delta, TAU) + hand_base.position.y = HAND_BASE_POSITION.y + 0.05 * sin(_anim_angle * 3) + position_anim = lerp(position_anim, position_, delta * 10) + rotation_anim = lerp_angle(rotation_anim, rotation_, delta * 10) + position.x = position_anim.x + position.z = position_anim.y + rotation.y = rotation_anim diff --git a/client/player/player.tscn b/client/player/player.tscn new file mode 100644 index 00000000..9c633575 --- /dev/null +++ b/client/player/player.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://d30bj2cp1m7gd"] + +[ext_resource type="PackedScene" uid="uid://b3hhir2fvnunu" path="res://models/prefabs/characters/guy.tscn" id="1_g5ma4"] + +[sub_resource type="CapsuleMesh" id="CapsuleMesh_4w71x"] + +[node name="Player" type="Node3D"] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.5, 0) +visible = false +mesh = SubResource("CapsuleMesh_4w71x") + +[node name="Character" parent="." instance=ExtResource("1_g5ma4")] +transform = Transform3D(0.33, 0, 0, 0, 0.33, 0, 0, 0, 0.33, 0, 0, 0) diff --git a/client/scenes/credits_menu.tscn b/client/scenes/credits_menu.tscn deleted file mode 100644 index 65035329..00000000 --- a/client/scenes/credits_menu.tscn +++ /dev/null @@ -1,83 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://7mqbxa054bjv"] - -[ext_resource type="PackedScene" uid="uid://bgt88u55bndd3" path="res://scenes/menu_background.tscn" id="1_5ay7o"] -[ext_resource type="Script" path="res://scripts/credits_menu.gd" id="1_igs63"] -[ext_resource type="PackedScene" uid="uid://ds1njrptrpdco" path="res://scenes/menu_background_scene.tscn" id="2_k0853"] -[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://scenes/scene_transition.tscn" id="4_fbbdb"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p2qmw"] -bg_color = Color(0, 0, 0, 0.576471) - -[node name="CreditsMenu" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_igs63") - -[node name="MenuBackground" parent="." instance=ExtResource("1_5ay7o")] -layout_mode = 1 -script = null - -[node name="background_view2" type="SubViewport" parent="MenuBackground"] -handle_input_locally = false -size = Vector2i(1152, 648) -render_target_update_mode = 4 - -[node name="scene" parent="MenuBackground/background_view2" instance=ExtResource("2_k0853")] - -[node name="Panel" type="Panel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_p2qmw") - -[node name="RichTextLabel" type="RichTextLabel" parent="Panel"] -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -222.0 -offset_top = -112.0 -offset_right = 222.0 -offset_bottom = 125.0 -grow_horizontal = 2 -grow_vertical = 2 -bbcode_enabled = true -text = "[center][b]undercooked - a game about cooking[/b] - -by - -[b]tpart, nokoe, metamuffin[/b] - -using assets from kenney.nl - -[/center]" - -[node name="back" type="Button" parent="Panel"] -layout_mode = 1 -anchors_preset = 7 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -79.0 -offset_top = -65.0 -offset_right = 81.0 -offset_bottom = -34.0 -grow_horizontal = 2 -grow_vertical = 0 -text = "Back" - -[node name="SceneTransition" parent="." instance=ExtResource("4_fbbdb")] -layout_mode = 1 -color = Color(0, 0, 0, 1) - -[connection signal="pressed" from="Panel/back" to="." method="_on_back_pressed"] diff --git a/client/scenes/follow_camera.tscn b/client/scenes/follow_camera.tscn deleted file mode 100644 index 816563ba..00000000 --- a/client/scenes/follow_camera.tscn +++ /dev/null @@ -1,7 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://b31mlnao6ybt8"] - -[ext_resource type="Script" path="res://scripts/follow_camera.gd" id="1_qipju"] - -[node name="FollowCamera" type="Camera3D"] -fov = 45.0 -script = ExtResource("1_qipju") diff --git a/client/scenes/game.tscn b/client/scenes/game.tscn deleted file mode 100644 index f5c3c0c4..00000000 --- a/client/scenes/game.tscn +++ /dev/null @@ -1,40 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://clsylbmw7jc0s"] -[gd_scene load_steps=7 format=3 uid="uid://clsylbmw7jc0s"] - -[ext_resource type="Script" path="res://scripts/game.gd" id="1_qnslj"] -[ext_resource type="PackedScene" uid="uid://bnqujofthaa4h" path="res://scenes/map.tscn" id="1_qt88a"] -[ext_resource type="PackedScene" uid="uid://b31mlnao6ybt8" path="res://scenes/follow_camera.tscn" id="3_6ot70"] -[ext_resource type="PackedScene" uid="uid://c0euiv7duqfp4" path="res://scenes/marker.tscn" id="5_idjm3"] - -[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_ko0bu"] - -[sub_resource type="Sky" id="Sky_bqb2d"] -sky_material = SubResource("PhysicalSkyMaterial_ko0bu") - -[sub_resource type="Environment" id="Environment_h880f"] -background_mode = 2 -background_energy_multiplier = 2.0 -sky = SubResource("Sky_bqb2d") -tonemap_mode = 2 -ssao_enabled = true -sdfgi_enabled = true -glow_enabled = true - -[node name="Game" type="Node3D"] -script = ExtResource("1_qnslj") - -[node name="Map" parent="." instance=ExtResource("1_qt88a")] - -[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(0.951635, -0.266538, 0.152804, -0.154443, 0.0149305, 0.987889, -0.265591, -0.963709, -0.0269565, 0, 0, 0) -shadow_enabled = true - -[node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_h880f") - -[node name="FollowCamera" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_6ot70")] -transform = Transform3D(0.894934, 0.084374, -0.438148, 0, 0.981959, 0.189095, 0.446198, -0.169228, 0.878789, 0, 3.65756, 11.0189) -target = NodePath("../Map") - -[node name="Marker" parent="." instance=ExtResource("5_idjm3")] -visible = false diff --git a/client/scenes/main_menu.tscn b/client/scenes/main_menu.tscn deleted file mode 100644 index ea9b31fb..00000000 --- a/client/scenes/main_menu.tscn +++ /dev/null @@ -1,89 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://dbj8508whxgwv"] - -[ext_resource type="Theme" uid="uid://cnhhreuc4shxv" path="res://scenes/theme.tres" id="1_rmwly"] -[ext_resource type="Script" path="res://scripts/main_menu.gd" id="2_qot2j"] -[ext_resource type="PackedScene" uid="uid://bgt88u55bndd3" path="res://scenes/menu_background.tscn" id="3_f3j3x"] -[ext_resource type="PackedScene" uid="uid://ds1njrptrpdco" path="res://scenes/menu_background_scene.tscn" id="4_ydj5p"] -[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://scenes/scene_transition.tscn" id="5_651nk"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d8o0f"] -bg_color = Color(0, 0, 0, 0.329412) - -[node name="MainMenu" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("1_rmwly") -script = ExtResource("2_qot2j") - -[node name="MenuBackground" parent="." instance=ExtResource("3_f3j3x")] -layout_mode = 1 -script = null - -[node name="background_view2" type="SubViewport" parent="MenuBackground"] -handle_input_locally = false -size = Vector2i(1152, 648) -render_target_update_mode = 4 - -[node name="scene" parent="MenuBackground/background_view2" instance=ExtResource("4_ydj5p")] - -[node name="side" type="PanelContainer" parent="."] -layout_mode = 1 -anchors_preset = 9 -anchor_bottom = 1.0 -offset_right = 340.0 -grow_vertical = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_d8o0f") - -[node name="options" type="VBoxContainer" parent="side"] -layout_mode = 2 - -[node name="quick_connect" type="Button" parent="side/options"] -layout_mode = 2 -text = "Quick Connect" -alignment = 0 - -[node name="connect" type="HBoxContainer" parent="side/options"] -layout_mode = 2 - -[node name="uri" type="LineEdit" parent="side/options/connect"] -layout_mode = 2 -size_flags_horizontal = 3 -placeholder_text = "wss://example.org" - -[node name="connect" type="Button" parent="side/options/connect"] -layout_mode = 2 -text = "Connect" - -[node name="change_character" type="Button" parent="side/options"] -layout_mode = 2 -text = "Select Character (todo)" -alignment = 0 - -[node name="settings" type="Button" parent="side/options"] -layout_mode = 2 -text = "Settings (todo)" -alignment = 0 - -[node name="credits" type="Button" parent="side/options"] -layout_mode = 2 -text = "Credits" -alignment = 0 - -[node name="quit" type="Button" parent="side/options"] -layout_mode = 2 -text = "Quit" -alignment = 0 - -[node name="SceneTransition" parent="." instance=ExtResource("5_651nk")] -layout_mode = 1 - -[connection signal="pressed" from="side/options/quick_connect" to="." method="_on_quick_connect_pressed"] -[connection signal="pressed" from="side/options/connect/connect" to="." method="_on_connect_pressed"] -[connection signal="pressed" from="side/options/change_character" to="." method="_on_credits_pressed"] -[connection signal="pressed" from="side/options/settings" to="." method="_on_credits_pressed"] -[connection signal="pressed" from="side/options/credits" to="." method="_on_credits_pressed"] -[connection signal="pressed" from="side/options/quit" to="." method="_on_quit_pressed"] diff --git a/client/scenes/marker.tscn b/client/scenes/marker.tscn deleted file mode 100644 index 7f21e199..00000000 --- a/client/scenes/marker.tscn +++ /dev/null @@ -1,53 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://c0euiv7duqfp4"] - -[ext_resource type="Script" path="res://scripts/marker.gd" id="1_3njdu"] -[ext_resource type="Shader" path="res://textures/interact_marker.gdshader" id="2_dejwy"] - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_o4v68"] - -[sub_resource type="ArrayMesh" id="ArrayMesh_2tdb0"] -_surfaces = [{ -"aabb": AABB(-1, -1, -1, 2, 2, 2.00001), -"format": 34896613377, -"index_count": 36, -"index_data": PackedByteArray(0, 0, 3, 0, 1, 0, 0, 0, 2, 0, 3, 0, 2, 0, 7, 0, 3, 0, 2, 0, 6, 0, 7, 0, 6, 0, 5, 0, 7, 0, 6, 0, 4, 0, 5, 0, 4, 0, 1, 0, 5, 0, 4, 0, 0, 0, 1, 0, 2, 0, 4, 0, 6, 0, 2, 0, 0, 0, 4, 0, 7, 0, 1, 0, 3, 0, 7, 0, 5, 0, 1, 0), -"primitive": 3, -"uv_scale": Vector4(0, 0, 0, 0), -"vertex_count": 8, -"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 255, 255, 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 254, 255, 0, 0, 255, 255, 255, 255, 254, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0) -}] -blend_shape_mode = 0 - -[sub_resource type="ArrayMesh" id="ArrayMesh_2ie13"] -resource_name = "marker_Cube_001" -_surfaces = [{ -"aabb": AABB(-1, -1, -1, 2, 2, 2.00001), -"attribute_data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255), -"format": 34896613399, -"index_count": 36, -"index_data": PackedByteArray(2, 0, 11, 0, 5, 0, 2, 0, 8, 0, 11, 0, 6, 0, 21, 0, 9, 0, 6, 0, 18, 0, 21, 0, 20, 0, 17, 0, 23, 0, 20, 0, 14, 0, 17, 0, 12, 0, 3, 0, 15, 0, 12, 0, 0, 0, 3, 0, 7, 0, 13, 0, 19, 0, 7, 0, 1, 0, 13, 0, 22, 0, 4, 0, 10, 0, 22, 0, 16, 0, 4, 0), -"material": SubResource("StandardMaterial3D_o4v68"), -"primitive": 3, -"uv_scale": Vector4(0, 0, 0, 0), -"vertex_count": 24, -"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 255, 191, 0, 0, 0, 0, 254, 255, 255, 191, 0, 0, 0, 0, 254, 255, 84, 213, 0, 0, 255, 255, 254, 255, 255, 191, 0, 0, 255, 255, 254, 255, 255, 255, 0, 0, 255, 255, 254, 255, 84, 213, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 191, 0, 0, 0, 0, 0, 0, 84, 213, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 84, 213, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 84, 213, 255, 255, 255, 255, 254, 255, 255, 191, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 254, 255, 84, 213, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 191, 255, 255, 0, 0, 0, 0, 84, 213, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 84, 213, 255, 255, 255, 255, 0, 0, 255, 127, 84, 213, 84, 213, 255, 255, 255, 255, 255, 127, 255, 191, 84, 213, 84, 213, 255, 191, 255, 191, 0, 0, 255, 127, 84, 213, 84, 213, 255, 191, 255, 191, 255, 127, 255, 191, 84, 213, 84, 213, 255, 255, 255, 255, 0, 0, 255, 127, 170, 42, 170, 42, 255, 255, 255, 255, 255, 127, 255, 191, 170, 42, 170, 42, 255, 191, 255, 191, 0, 0, 255, 127, 170, 42, 170, 42, 255, 191, 255, 191, 255, 127, 255, 191, 170, 42, 170, 42) -}] -blend_shape_mode = 0 -shadow_mesh = SubResource("ArrayMesh_2tdb0") - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_wuj1v"] -render_priority = 0 -shader = ExtResource("2_dejwy") -shader_parameter/max_width = 0.1 -shader_parameter/marker_length = 0.5 -shader_parameter/pulse_speed = 4.0 -shader_parameter/interactive = false - -[node name="Marker" type="Node3D"] -script = ExtResource("1_3njdu") - -[node name="Cube" type="MeshInstance3D" parent="."] -transform = Transform3D(0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0.25, 0) -mesh = SubResource("ArrayMesh_2ie13") -skeleton = NodePath("") -surface_material_override/0 = SubResource("ShaderMaterial_wuj1v") diff --git a/client/scenes/player.tscn b/client/scenes/player.tscn deleted file mode 100644 index 9c633575..00000000 --- a/client/scenes/player.tscn +++ /dev/null @@ -1,15 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://d30bj2cp1m7gd"] - -[ext_resource type="PackedScene" uid="uid://b3hhir2fvnunu" path="res://models/prefabs/characters/guy.tscn" id="1_g5ma4"] - -[sub_resource type="CapsuleMesh" id="CapsuleMesh_4w71x"] - -[node name="Player" type="Node3D"] - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.5, 0) -visible = false -mesh = SubResource("CapsuleMesh_4w71x") - -[node name="Character" parent="." instance=ExtResource("1_g5ma4")] -transform = Transform3D(0.33, 0, 0, 0, 0.33, 0, 0, 0, 0.33, 0, 0, 0) diff --git a/client/scenes/progress.tscn b/client/scenes/progress.tscn deleted file mode 100644 index 273beb74..00000000 --- a/client/scenes/progress.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[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/scenes/scene_transition.tscn b/client/scenes/scene_transition.tscn deleted file mode 100644 index 0865dddf..00000000 --- a/client/scenes/scene_transition.tscn +++ /dev/null @@ -1,71 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://bg2d78ycorcqk"] - -[ext_resource type="Script" path="res://scripts/scene_transition.gd" id="1_c2vxm"] - -[sub_resource type="Animation" id="Animation_xgn2a"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(0, 0, 0, 1)] -} - -[sub_resource type="Animation" id="Animation_tglmc"] -resource_name = "fade_in" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.9), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] -} - -[sub_resource type="Animation" id="Animation_egop8"] -resource_name = "fade_out" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.9), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_pea72"] -_data = { -"RESET": SubResource("Animation_xgn2a"), -"fade_in": SubResource("Animation_tglmc"), -"fade_out": SubResource("Animation_egop8") -} - -[node name="SceneTransition" type="ColorRect"] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -color = Color(0, 0, 0, 1) -script = ExtResource("1_c2vxm") - -[node name="animation" type="AnimationPlayer" parent="."] -libraries = { -"": SubResource("AnimationLibrary_pea72") -} -speed_scale = 4.0 diff --git a/client/scripts/character.gd b/client/scripts/character.gd deleted file mode 100644 index 847bd7b6..00000000 --- a/client/scripts/character.gd +++ /dev/null @@ -1,28 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 tpart -# -# 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 . -# -extends Node3D -class_name Character - -@onready var hand_animations = $HandAnimations - -func _ready(): - play_animation("idle") - -func play_animation(name_: String): - hand_animations.play(name_) - -func _on_hand_animations_animation_finished(name_): - hand_animations.play(name_) diff --git a/client/scripts/controllable_player.gd b/client/scripts/controllable_player.gd deleted file mode 100644 index 4c157349..00000000 --- a/client/scripts/controllable_player.gd +++ /dev/null @@ -1,110 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# 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 . -# -class_name ControllablePlayer -extends Player - - -const PLAYER_SPEED: float = 25.; - -var facing = Vector2(1, 0) -var velocity_ = Vector2(0, 0) - -var target: Vector2i = Vector2i(0, 0) - -func _ready(): - var timer = Timer.new() - timer.one_shot = false - timer.wait_time = 1. / 25. - add_child(timer) - timer.start() - timer.connect("timeout", func(): - Multiplayer.send_position(Vector2(position.x, position.z), rotation.y) - ) - -func _process(delta): - var input = Vector2(Input.get_axis("left", "right"), Input.get_axis("forward", "backwards")).normalized() - input = input.rotated(-game.camera.angle_target) - position_anim = position_ - rotation_anim = rotation_ - if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"): - input *= 0 - else: - target = Vector2i( - int(floor(position.x + sin(rotation.y))), - int(floor(position.z + cos(rotation.y))) - ) - interact() - update(delta, input) - super(delta) - -func update(dt: float, input: Vector2): - var direction = input.limit_length(1.); - rotation.y = atan2(self.facing.x, self.facing.y); - if direction.length() > 0.1: - self.facing = direction + (self.facing - direction) * exp(-dt * 10.); - self.velocity_ += direction * dt * PLAYER_SPEED; - self.position_ += self.velocity_ * dt; - self.velocity_ = self.velocity_ * exp(-dt * 5.); - collide(dt); - -func collide(dt: float): - for xo in range(-1,2): - for yo in range(-1,2): - var tile = Vector2i(xo, yo) + Vector2i(self.position_); - if !Multiplayer.get_tile_collision(tile): continue - tile = Vector2(tile) - var d = aabb_point_distance(tile, tile + Vector2.ONE, self.position_); - if d > PLAYER_SIZE: continue - var h = 0.01; - var d_sample_x = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(h, 0)); - var d_sample_y = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(0, h)); - var grad = (Vector2(d_sample_x - d, d_sample_y - d)) / h; - - self.position_ += (PLAYER_SIZE - d) * grad; - self.velocity_ -= grad * grad.dot(self.velocity_) - - for player: Player in game.players.values(): - var diff = self.position_ - player.position_ - var d = diff.length() - if d < 0.01: continue - if d >= PLAYER_SIZE * 2: continue - var norm = diff.normalized(); - var f = 100 / (1 + d) - self.velocity_.x += norm.x * f * dt - self.velocity_.y += norm.y * f * dt - -func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float: - return (p - p.clamp(mi, ma)).length() - -func update_position(new_position: Vector2, _new_rotation: float): - if (new_position - position_).length() > 3.: - position_ = new_position - -func interact(): - var tile_idx = str(target) - var t: Floor = game.map.tile_by_pos.get(tile_idx) - if t != null: - game.marker.set_interactive(Multiplayer.get_tile_interactive(target)) - game.marker.visible = true - game.marker_target = t.item_base.global_position - if Input.is_action_just_pressed("interact"): - Multiplayer.send_interact(target, true) - t.interact() - elif Input.is_action_just_released("interact"): - Multiplayer.send_interact(target, false) - else: - game.marker.visible = false diff --git a/client/scripts/credits_menu.gd b/client/scripts/credits_menu.gd deleted file mode 100644 index a48d5461..00000000 --- a/client/scripts/credits_menu.gd +++ /dev/null @@ -1,19 +0,0 @@ -# Undercooked - a game about cooking -# 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 . -# -extends Control - -func _on_back_pressed(): - $SceneTransition.transition_to("res://scenes/main_menu.tscn") diff --git a/client/scripts/follow_camera.gd b/client/scripts/follow_camera.gd deleted file mode 100644 index 74355688..00000000 --- a/client/scripts/follow_camera.gd +++ /dev/null @@ -1,65 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# 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 . -# -class_name FollowCamera -extends Camera3D - -const ROTATE_SPEED: float = 1.5 -const ROTATE_WEIGHT: float = 8.0 -const ROTATE_UP_SPEED: float = 0.7 -const ROTATE_UP_WEIGHT: float = 4.0 -const ANGLE_UP_MIN: float = 0.5 -const ANGLE_UP_MAX: float = 1.2 -const LOOK_WEIGHT: float = 8.0 -const MOVE_WEIGHT: float = 2.0 -const CAMERA_DISTANCE: float = 10 - -@export var target: Node3D - -var angle_target: float = 0 -var angle: float = 0 -var angle_up_target: float = 1 -var angle_up: float = 1 -var ground: Vector3 - -func _ready(): - if target == null: - push_warning("target is not set") - else: - ground = target.position - -func _process(delta): - if target != null: - follow(delta) - -func follow(delta): - var new_transform = transform.looking_at(target.position) - - transform.basis = Basis.from_euler(Vector3( - lerp_angle(transform.basis.get_euler().x, new_transform.basis.get_euler().x, delta * LOOK_WEIGHT), - lerp_angle(transform.basis.get_euler().y, new_transform.basis.get_euler().y, delta * LOOK_WEIGHT), - lerp_angle(transform.basis.get_euler().z, new_transform.basis.get_euler().z, delta * LOOK_WEIGHT) - )) - - angle_target += Input.get_axis("rotate_left", "rotate_right") * ROTATE_SPEED * delta - angle = lerp_angle(angle, angle_target, delta * ROTATE_WEIGHT) - - angle_up_target += Input.get_axis("rotate_down", "rotate_up") * ROTATE_UP_SPEED * delta - angle_up_target = clamp(angle_up_target, ANGLE_UP_MIN, ANGLE_UP_MAX) - angle_up = lerp_angle(angle_up, angle_up_target, delta * ROTATE_UP_WEIGHT) - - ground = ground.lerp(target.position, delta * MOVE_WEIGHT) - position = ground + Vector3(0, sin(angle_up) * CAMERA_DISTANCE, cos(angle_up) * CAMERA_DISTANCE).rotated(Vector3.UP, angle) diff --git a/client/scripts/game.gd b/client/scripts/game.gd deleted file mode 100644 index eb338eaa..00000000 --- a/client/scripts/game.gd +++ /dev/null @@ -1,110 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# 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 . -# -class_name Game -extends Node3D - -@onready var camera: FollowCamera = $FollowCamera -@onready var map: Map = $Map -@onready var marker: Marker = $Marker -var marker_target = Vector3(0,0,0) - -var players := {} -# Called when the node enters the scene tree for the first time. -func _ready(): - await Multiplayer.init - if Multiplayer.player_id == -1: - push_error("multiplayer has not been initialized") - Multiplayer.connect("add_player", - func(player: int, player_name: String, pos: Vector2, character: int): - var player_instance: Player - if player == Multiplayer.player_id: - player_instance = ControllablePlayer.new(player, player_name, pos, character, self) - camera.target = player_instance - else: - player_instance = Player.new(player, player_name, pos, character, self) - players[player] = player_instance - add_child(player_instance) - ) - - Multiplayer.connect("position", - func(player: int, pos: Vector2, rot: float): - var player_instance: Player = players[player] - player_instance.update_position(pos, rot) - ) - - Multiplayer.connect("remove_player", func(id: int): - var player: Player = players.get(id) - if player != null: - if player.hand != null: - player.hand.queue_free() - players.erase(id) - player.queue_free() - ) - - Multiplayer.connect("set_tile_item", func(tile: Vector2i, item: int): - var t: Floor = map.tile_by_pos[str(tile)] - var i = Item.new(item, t.item_base) - add_child(i) - i.name = Multiplayer.item_names[item] - t.set_item(i) - ) - - Multiplayer.connect("remove_tile_item", func(tile: Vector2i): - var t: Floor = map.tile_by_pos[str(tile)] - t.take_item().queue_free() - ) - - Multiplayer.connect("set_player_item", func(player: int, item: int): - var p: Player = players[player] - var i = Item.new(item, p.hand_base) - add_child(i) - i.name = Multiplayer.item_names[item] - p.set_item(i) - ) - - Multiplayer.connect("remove_player_item", func(player: int): - var p: Player = players[player] - p.remove_item().queue_free() - ) - - Multiplayer.connect("take_item", func(tile: Vector2i, player: int): - var t: Floor = map.tile_by_pos[str(tile)] - var p: Player = players[player] - p.take_item(t) - ) - - Multiplayer.connect("put_item", func(tile: Vector2i, player: int): - var t: FullTile = map.tile_by_pos[str(tile)] - var p: Player = players[player] - p.put_item(t) - ) - - Multiplayer.connect("set_progress", func(tile: Vector2i, progress: float, warn: bool): - var t: FullTile = map.tile_by_pos[str(tile)] - t.progress(progress, warn) - ) - - Multiplayer.connect("set_finished", func(tile: Vector2i, warn: bool): - var t: FullTile = map.tile_by_pos[str(tile)] - t.finish(warn) - ) - - Multiplayer.send_join("Blub", 1) - - -func _process(delta): - marker.position = lerp(marker.position, marker_target, delta * 40.0) diff --git a/client/scripts/item.gd b/client/scripts/item.gd deleted file mode 100644 index 74e08c48..00000000 --- a/client/scripts/item.gd +++ /dev/null @@ -1,56 +0,0 @@ -# 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 . -# -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/scripts/main_menu.gd b/client/scripts/main_menu.gd deleted file mode 100644 index df09cf7f..00000000 --- a/client/scripts/main_menu.gd +++ /dev/null @@ -1,49 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 metamuffin -# Copyright 2024 tpart -# -# 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 . -# -extends Control - -@onready var quick_connect = $side/margin/options/quick_connect -@onready var quit_button = $side/margin/options/quit - -func _ready(): - quick_connect.grab_focus() - if OS.has_feature("web"): - quit_button.hide() - -func _on_quit_pressed(): - get_tree().quit() - -func _on_credits_pressed(): - $SceneTransition.transition_to("res://scenes/credits_menu.tscn") - -func _on_connect_pressed(): - connect_to($side/options/connect/uri.text) - -func _on_quick_connect_pressed(): - if OS.has_feature("JavaScript"): - connect_to(JavaScriptBridge.eval(""" - window.location.protocol.endsWith("s:") - ? `wss://${window.location.host}/` - : `ws://${window.location.hostname}:27032/` - """)) - else: - connect_to("wss://undercooked.metamuffin.org/") - -func connect_to(url): - print("Connecting to %s" % url) - Multiplayer.url = url - $SceneTransition.transition_to("res://scenes/game.tscn") diff --git a/client/scripts/map.gd b/client/scripts/map.gd deleted file mode 100644 index b5e519a6..00000000 --- a/client/scripts/map.gd +++ /dev/null @@ -1,77 +0,0 @@ -# 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 . -# -@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/scripts/marker.gd b/client/scripts/marker.gd deleted file mode 100644 index 6e3e6ffa..00000000 --- a/client/scripts/marker.gd +++ /dev/null @@ -1,23 +0,0 @@ -# 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 . -# -class_name Marker -extends Node3D - -@onready var _cube: MeshInstance3D = $Cube - -func set_interactive(val: bool): - var mat: ShaderMaterial = _cube.get_active_material(0) - mat.set_shader_parameter("interactive", val) diff --git a/client/scripts/menu_background.gd b/client/scripts/menu_background.gd deleted file mode 100644 index e5b8ac31..00000000 --- a/client/scripts/menu_background.gd +++ /dev/null @@ -1,35 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 metamuffin -# Copyright 2024 tpart -# -# 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 . -# -@tool -extends Node3D - -@onready var map = $map -@onready var voxel_gi: VoxelGI = $VoxelGI - -const NULLS = [null,null,null,null] -const BUCKETS = [[], ["floor","floor","floor","floor","tomato-crate", "raw-steak-crate"], ["table", "chair", "counter"], ["sink", "stove"]] - -func _ready(): - for x in range(-10,11): - for y in range(-10,11): - var w = exp(-sqrt(x*x+y*y) * 0.15) - var k = randf() * w - var bucket = BUCKETS[int(floor(k * BUCKETS.size())) % BUCKETS.size()] - if bucket.size() == 0: continue - var tile = bucket[randi() % bucket.size()] - map.update([x,y], tile, NULLS) - voxel_gi.bake() diff --git a/client/scripts/mirror.gd b/client/scripts/mirror.gd deleted file mode 100644 index ccec0e65..00000000 --- a/client/scripts/mirror.gd +++ /dev/null @@ -1,31 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 tpart -# -# 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 . -# -@tool - -# Hand mirror helper script, useful for animating characters - -extends Node3D - -@export var enabled := true - -@onready var hand_right = $Main/HandRight -@onready var hand_left = $Main/HandLeft - - -func _process(delta): - if enabled: - hand_right.position = hand_left.position * Vector3(-1,1,1) - hand_right.rotation = hand_left.rotation * Vector3(1, -1, -1) - Vector3(0.2 * PI, 0, 0) diff --git a/client/scripts/multiplayer.gd b/client/scripts/multiplayer.gd deleted file mode 100644 index 534ef663..00000000 --- a/client/scripts/multiplayer.gd +++ /dev/null @@ -1,205 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# Copyright 2024 metamuffin -# Copyright 2024 tpart -# -# 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 . -# -extends Node - -signal init(player_id: int) -signal update_map(tile: int, pos: Array, neighbors: Array) -signal clear_message(player: int) -signal text_message(player: int, text: String) -signal item_message(player: int, item: int) -signal add_player(player: int, name: String, pos: Vector2, character: int) -signal remove_player(player: int) -signal position(player: int, position: Vector2, rotation: float) -signal take_item(tile: Vector2i, player: int) -signal put_item(tile: Vector2i, player: int) -signal set_tile_item(tile: Vector2i, item: int) -signal remove_tile_item(tile: Vector2i) -signal set_progress(tile: Vector2i, progress: float, warn: bool) -signal set_finished(tile: Vector2i, warn: bool) - -var connected := false -var socket := WebSocketPeer.new() - -var item_names = [] -var tile_names = [] -var tile_collide = [] -var tile_interact = [] -var item_idx_from_name: Dictionary = {} -var player_id = -1 - -var tileid_by_pos: Dictionary = {} - -func connectClient(url: String): - socket.connect_to_url(url) - connected = true - -func _process(_delta): - if connected: - socket.poll() - var state = socket.get_ready_state() - if state == WebSocketPeer.STATE_OPEN: - while socket.get_available_packet_count(): - handle_packet(socket.get_packet()) - elif state == WebSocketPeer.STATE_CONNECTING: - print("connecting") - elif state == WebSocketPeer.STATE_CLOSING: - # Keep polling to achieve proper close. - print("closing") - pass - elif state == WebSocketPeer.STATE_CLOSED: - var code = socket.get_close_code() - var reason = socket.get_close_reason() - print("WebSocket closed with code: %d, reason %s. Clean: %s" % [code, reason, code != - 1]) - -func handle_packet(bytes: PackedByteArray): - var decoded = decode_packet(bytes) - - if decoded == null: - return - - var packet_type: String = decoded["type"] - match packet_type: - "init": - player_id = decoded["id"] - item_names = decoded["data"]["item_names"] - tile_names = decoded["data"]["tile_names"] - tile_collide = decoded["data"]["tile_collide"] - tile_interact = decoded["data"]["tile_interact"] - for i in range(item_names.size()): - item_idx_from_name[item_names[i]] = i - emit_signal("init", player_id) - "add_player": - var id = decoded["id"] - var player_name = decoded["name"] - var pos = decoded["position"] - var character = decoded["character"] - emit_signal("add_player", id, player_name, pos_to_vec2(pos), character) - "remove_player": - var id = decoded["id"] - emit_signal("remove_player", id) - "position": - var player = decoded["player"] - var pos = decoded["pos"] - var rot = decoded["rot"] - emit_signal("position", player, pos_to_vec2(pos), rot) - "take_item": - var tile = pos_to_vec2i(decoded["tile"]) - var player = decoded["player"] - emit_signal("take_item", tile, player) - "put_item": - var tile = pos_to_vec2i(decoded["tile"]) - var player_id = decoded["player"] - emit_signal("take_item", tile, player_id) - "set_active": - var tile = pos_to_vec2i(decoded["tile"]) - var warn = decoded["warn"] - var progress = decoded.get("progress") - if progress != null: - emit_signal("set_progress", tile, decoded["progress"], warn) - else: - emit_signal("set_finished", tile, warn) - "set_tile_item": - var tile = pos_to_vec2i(decoded["tile"]) - var item = decoded.get("item") - if item != null: - emit_signal("set_tile_item", tile, item) - else: - emit_signal("remove_tile_item", tile) - "set_player_item": - var player = decoded["player"] - var item = decoded.get("item") - if item != null: - emit_signal("set_player_item", player, decoded["item"]) - else: - emit_signal("remove_player_item", player) - "update_map": - var tile: int = decoded["tile"] - var pos: Array = decoded["pos"] - var neighbors: Array = decoded["neighbors"] - tileid_by_pos[str(Vector2i(pos[0],pos[1]))] = tile - emit_signal("update_map", pos, tile_names[tile], neighbors) - "communicate": - var player = decoded["player"] - var message = decoded.get("message") - if message != null: - var item = message.get("item") - var text = message.get("text") - if item != null: - emit_signal("item_message", player, item) - elif text != null: - emit_signal("text_message", player, text) - else: - push_error("neither text nor item provided") - else: - emit_signal("clear_message", player) - "error": - var message = decoded["message"] - push_warning("server error: %s" % message) - _: - push_error("Unrecognized packet type: %s" % packet_type) - -func send_join(player_name: String, character: int): - send_packet({ - "type": "join", - "name": player_name, - "character": character - }) - -func send_position(pos: Vector2, rotation: float): - send_packet({ - "type": "position", - "pos": [pos.x, pos.y], - "rot": rotation - }) - -func send_interact(pos: Vector2i, edge: bool): - send_packet({ - "type": "interact", - "pos": [pos.x, pos.y], - "edge": edge - }) - -func send_packet(packet): - var json = JSON.stringify(packet) - socket.send_text(json) - -func decode_packet(bytes: PackedByteArray): - var json = JSON.new() - var in_str = bytes.get_string_from_utf8() - var error = json.parse(in_str) - if error == OK: - return json.data - else: - print("Decode of packet failed: %s in %s" % [json.get_error_message(), in_str]) - return null - -func pos_to_vec2(pos: Array) -> Vector2: - return Vector2(pos[0], pos[1]) - -func pos_to_vec2i(pos: Array) -> Vector2i: - return Vector2i(pos[0], pos[1]) - -func get_tile_collision(pos: Vector2i) -> bool: - var t = tileid_by_pos.get(str(pos)) - if t == null: return false - else: return tile_collide[t] - -func get_tile_interactive(pos: Vector2i) -> bool: - var t = tileid_by_pos.get(str(pos)) - if t == null: return false - else: return tile_interact[t] diff --git a/client/scripts/player.gd b/client/scripts/player.gd deleted file mode 100644 index 423855e9..00000000 --- a/client/scripts/player.gd +++ /dev/null @@ -1,81 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# Copyright 2024 metamuffin -# Copyright 2024 tpart -# -# 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 . -# -class_name Player -extends Node3D - -const PLAYER_SIZE: float = 0.4 -const SPEED: float = 25. - -var game: Game -var position_ = Vector2(0, 0) - -var mesh = preload("res://scenes/player.tscn").instantiate() - -var hand: Node3D = null - -var _anim_angle: float = 0.0 - -const HAND_BASE_POSITION: Vector3 = Vector3(0, .25, .4) - -@onready var character: Character = $Player/Character - -func _init(_id: int, new_name: String, pos: Vector2, _character: int, new_game: Game): - add_child(mesh) - position_ = pos - name = new_name - game = new_game - -func update_position(new_position: Vector2, new_rotation: float): - position_ = new_position - rotation_ = new_rotation - -func set_item(i: Item): - i.owned_by = hand_base - if i == null: - push_error("tile is null") - hand = i - character.play_animation("hold") - -func remove_item() -> Item: - var i = hand - if i == null: - push_error("holding nothing") - hand = null - character.play_animation("idle") - return i - -func take_item(tile: Floor): - if hand != null: - push_error("already holding an item") - var i = tile.take_item() - if i == null: - push_error("tile is null") - hand = i - -func put_item(tile: Floor): - var i = remove_item() - tile.put_item(i) - -func _process(delta): - _anim_angle = fmod(_anim_angle + delta, TAU) - hand_base.position.y = HAND_BASE_POSITION.y + 0.05 * sin(_anim_angle * 3) - position_anim = lerp(position_anim, position_, delta * 10) - rotation_anim = lerp_angle(rotation_anim, rotation_, delta * 10) - position.x = position_anim.x - position.z = position_anim.y - rotation.y = rotation_anim diff --git a/client/scripts/progress.gd b/client/scripts/progress.gd deleted file mode 100644 index 4d6494f6..00000000 --- a/client/scripts/progress.gd +++ /dev/null @@ -1,22 +0,0 @@ -# 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 . -# -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/scripts/scene_transition.gd b/client/scripts/scene_transition.gd deleted file mode 100644 index b5c89579..00000000 --- a/client/scripts/scene_transition.gd +++ /dev/null @@ -1,28 +0,0 @@ -# Undercooked - a game about cooking -# 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 . -# -class_name SceneTransition -extends ColorRect - - -@onready var anim = $animation - -func _ready(): - anim.play("fade_in") - -func transition_to(path: String): - anim.play("fade_out") - await anim.animation_finished - get_tree().change_scene_to_file(path) diff --git a/client/scripts/socket_test.gd b/client/scripts/socket_test.gd deleted file mode 100644 index 853dd981..00000000 --- a/client/scripts/socket_test.gd +++ /dev/null @@ -1,22 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 tpart -# -# 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 . -# -extends Control - -@onready var address = $VBoxContainer/LineEdit - -func _on_button_pressed(): - Multiplayer.connectClient(address.text) - get_tree().change_scene_to_file("res://scenes/game.tscn") diff --git a/client/scripts/tiles/chair.gd b/client/scripts/tiles/chair.gd deleted file mode 100644 index 34735fda..00000000 --- a/client/scripts/tiles/chair.gd +++ /dev/null @@ -1,28 +0,0 @@ -# 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 . -# -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/scripts/tiles/counter.gd b/client/scripts/tiles/counter.gd deleted file mode 100644 index c3032e4f..00000000 --- a/client/scripts/tiles/counter.gd +++ /dev/null @@ -1,81 +0,0 @@ -# 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 . -# -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/scripts/tiles/counter_base.gd b/client/scripts/tiles/counter_base.gd deleted file mode 100644 index ebeebb3b..00000000 --- a/client/scripts/tiles/counter_base.gd +++ /dev/null @@ -1,27 +0,0 @@ -# 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 . -# -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/scripts/tiles/crate.gd b/client/scripts/tiles/crate.gd deleted file mode 100644 index 21fae60b..00000000 --- a/client/scripts/tiles/crate.gd +++ /dev/null @@ -1,23 +0,0 @@ -# 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 . -# -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/scripts/tiles/cutting_board.gd b/client/scripts/tiles/cutting_board.gd deleted file mode 100644 index 944a7a9f..00000000 --- a/client/scripts/tiles/cutting_board.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/door.gd b/client/scripts/tiles/door.gd deleted file mode 100644 index cfba08b7..00000000 --- a/client/scripts/tiles/door.gd +++ /dev/null @@ -1,27 +0,0 @@ -# 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 . -# -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/scripts/tiles/floor.gd b/client/scripts/tiles/floor.gd deleted file mode 100644 index fec68cbd..00000000 --- a/client/scripts/tiles/floor.gd +++ /dev/null @@ -1,85 +0,0 @@ -# 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 . -# -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/scripts/tiles/flour_counter.gd b/client/scripts/tiles/flour_counter.gd deleted file mode 100644 index 4bf2b1f3..00000000 --- a/client/scripts/tiles/flour_counter.gd +++ /dev/null @@ -1,26 +0,0 @@ -# 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 . -# -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/scripts/tiles/full_tile.gd b/client/scripts/tiles/full_tile.gd deleted file mode 100644 index 2da54237..00000000 --- a/client/scripts/tiles/full_tile.gd +++ /dev/null @@ -1,49 +0,0 @@ -# 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 . -# -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/scripts/tiles/generic_tile.gd b/client/scripts/tiles/generic_tile.gd deleted file mode 100644 index f7d1b4a7..00000000 --- a/client/scripts/tiles/generic_tile.gd +++ /dev/null @@ -1,33 +0,0 @@ -# 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 . -# -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/scripts/tiles/oven.gd b/client/scripts/tiles/oven.gd deleted file mode 100644 index 88da3adb..00000000 --- a/client/scripts/tiles/oven.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/raw_steak_crate.gd b/client/scripts/tiles/raw_steak_crate.gd deleted file mode 100644 index 8ff93d6b..00000000 --- a/client/scripts/tiles/raw_steak_crate.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/sink.gd b/client/scripts/tiles/sink.gd deleted file mode 100644 index e4eaff60..00000000 --- a/client/scripts/tiles/sink.gd +++ /dev/null @@ -1,27 +0,0 @@ -# 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 . -# -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/scripts/tiles/stove.gd b/client/scripts/tiles/stove.gd deleted file mode 100644 index 93fad5a3..00000000 --- a/client/scripts/tiles/stove.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/table.gd b/client/scripts/tiles/table.gd deleted file mode 100644 index 533223a4..00000000 --- a/client/scripts/tiles/table.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/tomato_crate.gd b/client/scripts/tiles/tomato_crate.gd deleted file mode 100644 index 078d0ba2..00000000 --- a/client/scripts/tiles/tomato_crate.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/trash.gd b/client/scripts/tiles/trash.gd deleted file mode 100644 index fed1a502..00000000 --- a/client/scripts/tiles/trash.gd +++ /dev/null @@ -1,21 +0,0 @@ -# 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 . -# -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/scripts/tiles/wall.gd b/client/scripts/tiles/wall.gd deleted file mode 100644 index 0201d4d6..00000000 --- a/client/scripts/tiles/wall.gd +++ /dev/null @@ -1,29 +0,0 @@ -# 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 . -# -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/scripts/tiles/wall_tile.gd b/client/scripts/tiles/wall_tile.gd deleted file mode 100644 index 7c9d4305..00000000 --- a/client/scripts/tiles/wall_tile.gd +++ /dev/null @@ -1,74 +0,0 @@ -# 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 . -# -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/scripts/tiles/window.gd b/client/scripts/tiles/window.gd deleted file mode 100644 index b2926080..00000000 --- a/client/scripts/tiles/window.gd +++ /dev/null @@ -1,29 +0,0 @@ -# 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 . -# -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()) diff --git a/client/textures/interact_marker.gdshader b/client/textures/interact_marker.gdshader deleted file mode 100644 index 94b7323d..00000000 --- a/client/textures/interact_marker.gdshader +++ /dev/null @@ -1,27 +0,0 @@ -shader_type spatial; - -uniform float max_width = .1; -uniform float marker_length = .5; -uniform float pulse_speed = 4.; -uniform bool interactive = false; - -void fragment() { - if (interactive) { - ALBEDO = vec3(15., 0., 0.); - } else { - ALBEDO = vec3(.1, .1, .1); - } - vec2 uv = abs(2. * UV.xy - 1.); - float m_length = marker_length / max_width; - float anim; - if (interactive) { - anim = sin(TIME * pulse_speed) * .5 + 1.; - } else { - anim = .5; - } - float alpha = step( - 1. - max_width * anim, max(uv.x, uv.y)) - * step(1. - max_width * m_length, min(uv.x, uv.y) - ); - ALPHA = alpha; -} diff --git a/client/textures/progress.gdshader b/client/textures/progress.gdshader deleted file mode 100644 index 0bf3e04a..00000000 --- a/client/textures/progress.gdshader +++ /dev/null @@ -1,28 +0,0 @@ -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/themes/styles/focus.tres b/client/themes/styles/focus.tres deleted file mode 100644 index 4c8385ea..00000000 --- a/client/themes/styles/focus.tres +++ /dev/null @@ -1,13 +0,0 @@ -[gd_resource type="StyleBoxFlat" format=3 uid="uid://cakf4liofcocu"] - -[resource] -bg_color = Color(0.47451, 0.580392, 0.917647, 0) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(0.513726, 0.611765, 0.929412, 1) -corner_radius_top_left = 10 -corner_radius_top_right = 10 -corner_radius_bottom_right = 10 -corner_radius_bottom_left = 10 -- cgit v1.2.3-70-g09d2