From f2da104ee3fc6ac62b78556a179eea909f0a704b Mon Sep 17 00:00:00 2001 From: nokoe Date: Sun, 7 Jul 2024 16:14:14 +0200 Subject: add path --- client/map/items/grass.gd | 36 ------------------------------------ client/map/tile_factory.gd | 2 ++ client/map/tiles/grass.gd | 36 ++++++++++++++++++++++++++++++++++++ client/map/tiles/grass.tscn | 2 +- client/map/tiles/grass_side.tscn | 2 +- client/map/tiles/path.gd | 23 +++++++++++++++++++++++ client/map/tiles/path.res | Bin 0 -> 1907 bytes client/map/tiles/path.tscn | 10 ++++++++++ 8 files changed, 73 insertions(+), 38 deletions(-) delete mode 100644 client/map/items/grass.gd create mode 100644 client/map/tiles/grass.gd create mode 100644 client/map/tiles/path.gd create mode 100644 client/map/tiles/path.res create mode 100644 client/map/tiles/path.tscn (limited to 'client') diff --git a/client/map/items/grass.gd b/client/map/items/grass.gd deleted file mode 100644 index 15ee7603..00000000 --- a/client/map/items/grass.gd +++ /dev/null @@ -1,36 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 nokoe -# 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 Grass -extends Tile - -const GRASS_SIDE: PackedScene = preload("res://map/tiles/grass_side.tscn") -const GRASS_COUNT: int = 16 - -func _init(rename: String, _neighbors: Array): - super(rename, _neighbors) - var grass_tile = preload("res://map/tiles/grass.tscn").instantiate() - grass_tile.position += Vector3(0.5, 0, 0.5) - add_child(grass_tile) - - var random = RandomNumberGenerator.new() - random.seed = rename.hash() - - for _i in Global.get_setting("grass_amount"): - var g: Node3D = GRASS_SIDE.instantiate() - grass_tile.add_child(g) - g.position = Vector3(random.randf_range(-.5, .5), 0, random.randf_range(-.5, .5)) - g.rotation = Vector3(0, random.randf_range(0, PI), 0) diff --git a/client/map/tile_factory.gd b/client/map/tile_factory.gd index 3ff59640..be2b3c49 100644 --- a/client/map/tile_factory.gd +++ b/client/map/tile_factory.gd @@ -58,6 +58,8 @@ static func produce(tile_name: String, node_name: String, neighbors: Array) -> T return ExteriorTree.new(node_name, neighbors) "grass": return Grass.new(node_name, neighbors) + "path": + return Path.new(node_name, neighbors) var t: push_warning("tile %s unknown" % t) return GenericTile.new(node_name, neighbors, t) diff --git a/client/map/tiles/grass.gd b/client/map/tiles/grass.gd new file mode 100644 index 00000000..15ee7603 --- /dev/null +++ b/client/map/tiles/grass.gd @@ -0,0 +1,36 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# 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 Grass +extends Tile + +const GRASS_SIDE: PackedScene = preload("res://map/tiles/grass_side.tscn") +const GRASS_COUNT: int = 16 + +func _init(rename: String, _neighbors: Array): + super(rename, _neighbors) + var grass_tile = preload("res://map/tiles/grass.tscn").instantiate() + grass_tile.position += Vector3(0.5, 0, 0.5) + add_child(grass_tile) + + var random = RandomNumberGenerator.new() + random.seed = rename.hash() + + for _i in Global.get_setting("grass_amount"): + var g: Node3D = GRASS_SIDE.instantiate() + grass_tile.add_child(g) + g.position = Vector3(random.randf_range(-.5, .5), 0, random.randf_range(-.5, .5)) + g.rotation = Vector3(0, random.randf_range(0, PI), 0) diff --git a/client/map/tiles/grass.tscn b/client/map/tiles/grass.tscn index 31ff6a69..649cc6c1 100644 --- a/client/map/tiles/grass.tscn +++ b/client/map/tiles/grass.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://bi6o7lbvhunj1"] -[ext_resource type="ArrayMesh" path="res://map/tiles/grass.res" id="1_pjjrj"] +[ext_resource type="ArrayMesh" uid="uid://dyu8iuolwqr5l" path="res://map/tiles/grass.res" id="1_pjjrj"] [node name="Grass" type="Node3D"] diff --git a/client/map/tiles/grass_side.tscn b/client/map/tiles/grass_side.tscn index c49ea4ca..08e04505 100644 --- a/client/map/tiles/grass_side.tscn +++ b/client/map/tiles/grass_side.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dbp0ts6tfycev"] -[ext_resource type="ArrayMesh" path="res://map/tiles/grass_side.tres" id="1_u044x"] +[ext_resource type="ArrayMesh" uid="uid://l2by4gv4wpd1" path="res://map/tiles/grass_side.tres" id="1_u044x"] [node name="GrassSide" type="Node3D"] diff --git a/client/map/tiles/path.gd b/client/map/tiles/path.gd new file mode 100644 index 00000000..76c49b64 --- /dev/null +++ b/client/map/tiles/path.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 Path +extends Tile + +func _init(rename: String, _neighbors: Array): + super(rename, _neighbors) + var path_tile = preload("res://map/tiles/path.tscn").instantiate() + path_tile.position += Vector3(0.5, 0, 0.5) + add_child(path_tile) diff --git a/client/map/tiles/path.res b/client/map/tiles/path.res new file mode 100644 index 00000000..e775b24e Binary files /dev/null and b/client/map/tiles/path.res differ diff --git a/client/map/tiles/path.tscn b/client/map/tiles/path.tscn new file mode 100644 index 00000000..1951680b --- /dev/null +++ b/client/map/tiles/path.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://beo16fa7lo12g"] + +[ext_resource type="ArrayMesh" uid="uid://1jelocokc0vu" path="res://map/tiles/path.res" id="1_6fqu5"] + +[node name="Path" type="Node3D"] + +[node name="Mesh" type="MeshInstance3D" parent="."] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.3, 0) +mesh = ExtResource("1_6fqu5") +skeleton = NodePath("") -- cgit v1.2.3-70-g09d2