summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2024-09-26 19:38:58 +0200
committernokoe <nokoe@mailbox.org>2024-09-26 20:28:08 +0200
commit2031a8b9d2bf568f538cc9223713f50c77bac897 (patch)
tree82d9ed6f8502bcd1d949e28d4d61528b8478c437 /client
parent2a96dbb14fe268c90025d1d0af5e66dc9b00f214 (diff)
downloadhurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar
hurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar.bz2
hurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar.zst
floor as one mesh
Diffstat (limited to 'client')
-rw-r--r--client/game.gd2
-rw-r--r--client/map/items/lettuce_crate.gd4
-rw-r--r--client/map/map.gd14
-rw-r--r--client/map/map.tscn3
-rw-r--r--client/map/tile_factory.gd95
-rw-r--r--client/map/tiles/book.gd4
-rw-r--r--client/map/tiles/ceiling_lamp.gd4
-rw-r--r--client/map/tiles/chair.gd8
-rw-r--r--client/map/tiles/chandelier.gd4
-rw-r--r--client/map/tiles/cheese_crate.gd4
-rw-r--r--client/map/tiles/coconut_crate.gd4
-rw-r--r--client/map/tiles/conveyor.gd4
-rw-r--r--client/map/tiles/counter.gd8
-rw-r--r--client/map/tiles/counter_base.gd4
-rw-r--r--client/map/tiles/counter_window.gd4
-rw-r--r--client/map/tiles/crate.gd4
-rw-r--r--client/map/tiles/cutting_board.gd4
-rw-r--r--client/map/tiles/door.gd7
-rw-r--r--client/map/tiles/exterior_tree.gd6
-rw-r--r--client/map/tiles/fence.gd4
-rw-r--r--client/map/tiles/fish_crate.gd4
-rw-r--r--client/map/tiles/floor.gd4
-rw-r--r--client/map/tiles/floor.pngbin0 -> 79 bytes
-rw-r--r--client/map/tiles/floor.png.import36
-rw-r--r--client/map/tiles/floor.resbin2165 -> 2184 bytes
-rw-r--r--client/map/tiles/floor.tscn1
-rw-r--r--client/map/tiles/floor_material.tres7
-rw-r--r--client/map/tiles/floor_mesher.gd86
-rw-r--r--client/map/tiles/flour_crate.gd4
-rw-r--r--client/map/tiles/freezer.gd4
-rw-r--r--client/map/tiles/full_tile.gd4
-rw-r--r--client/map/tiles/generic_tile.gd6
-rw-r--r--client/map/tiles/grass.gd6
-rw-r--r--client/map/tiles/grass_side.tres4
-rw-r--r--client/map/tiles/item_portal.gd4
-rw-r--r--client/map/tiles/lamp.gd4
-rw-r--r--client/map/tiles/leek_crate.gd4
-rw-r--r--client/map/tiles/oven.gd4
-rw-r--r--client/map/tiles/player_portal.gd4
-rw-r--r--client/map/tiles/raw_steak_crate.gd4
-rw-r--r--client/map/tiles/rice_crate.gd4
-rw-r--r--client/map/tiles/sink.gd4
-rw-r--r--client/map/tiles/steak_crate.gd4
-rw-r--r--client/map/tiles/stove.gd4
-rw-r--r--client/map/tiles/strawberry_crate.gd4
-rw-r--r--client/map/tiles/table.gd4
-rw-r--r--client/map/tiles/tile.gd4
-rw-r--r--client/map/tiles/tomato_crate.gd4
-rw-r--r--client/map/tiles/trash.gd4
-rw-r--r--client/map/tiles/wall.gd4
-rw-r--r--client/map/tiles/wall_tile.gd6
-rw-r--r--client/map/tiles/window.gd4
-rw-r--r--client/multiplayer.gd2
53 files changed, 291 insertions, 142 deletions
diff --git a/client/game.gd b/client/game.gd
index 1eee4001..a296706d 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -183,6 +183,8 @@ func handle_packet(p):
if neighbors != null: neighbors = neighbors.map(func(x): return tile_names[x] if x != null else null)
map.set_tile(p.tile, tile_names[p.kind], neighbors)
else: map.clear_tile(p.tile)
+ "flush_map":
+ map.flush()
"communicate":
var timeout_initial: float = p.timeout.initial if p.timeout != null else 5.
var timeout_remaining: float = p.timeout.remaining if p.timeout != null else 5.
diff --git a/client/map/items/lettuce_crate.gd b/client/map/items/lettuce_crate.gd
index a3aead17..126c8829 100644
--- a/client/map/items/lettuce_crate.gd
+++ b/client/map/items/lettuce_crate.gd
@@ -16,6 +16,6 @@
class_name LettuceCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/lettuce_crate.tscn").instantiate())
diff --git a/client/map/map.gd b/client/map/map.gd
index ce3c6dfa..40451c57 100644
--- a/client/map/map.gd
+++ b/client/map/map.gd
@@ -21,6 +21,8 @@ extends Node3D
var tile_by_pos: Dictionary = {}
var autobake = false
var currently_baked = false
+var floor_mesher := FloorMesher.new()
+var floor_node := MeshInstance3D.new()
func get_tile_name(pos: Vector2i):
var e = tile_by_pos.get(str(pos))
@@ -32,11 +34,10 @@ func get_tile_instance(pos: Vector2i) -> Tile:
else: return null
func set_tile(pos: Vector2i, name_: String, neighbors: Array = [null,null,null,null]) -> Tile:
- var tile = TileFactory.produce(name_, str(pos), neighbors)
+ var tile = TileFactory.produce(name_, pos, neighbors, floor_mesher)
add_child(tile)
tile.position = Vector3(pos.x, 0, pos.y)
tile_by_pos[str(pos)] = [pos, name_, tile, neighbors]
- if autobake: voxelgi_timer.start(1)
return tile
func clear_tile(pos: Vector2i):
@@ -47,12 +48,16 @@ func clear_tile(pos: Vector2i):
tile.name += "_queued_free"
tile.queue_free()
-@onready var voxelgi_timer: Timer = $Timer
@onready var voxelgi: VoxelGI = $VoxelGI
func _ready():
- voxelgi_timer.connect("timeout", gi_bake)
Settings.hook_changed("graphics.gi", false, apply_gi_setting)
+ floor_node.material_override = preload("res://map/tiles/floor_material.tres")
+ add_child(floor_node)
+
+func flush() -> void:
+ floor_node.mesh = floor_mesher.flush()
+ gi_bake()
func apply_gi_setting(state):
if state == "voxelgi" and not currently_baked:
@@ -61,7 +66,6 @@ func apply_gi_setting(state):
currently_baked = false
voxelgi.data = null
-
func gi_bake():
if Global.get_setting("graphics.gi") != "voxelgi": return
print("Map: Rebaking VoxelGI")
diff --git a/client/map/map.tscn b/client/map/map.tscn
index cd08e416..55d88678 100644
--- a/client/map/map.tscn
+++ b/client/map/map.tscn
@@ -9,9 +9,6 @@
[node name="Map" type="Node3D"]
script = ExtResource("1_3en0a")
-[node name="Timer" type="Timer" parent="."]
-one_shot = true
-
[node name="VoxelGI" type="VoxelGI" parent="."]
camera_attributes = SubResource("CameraAttributesPractical_kwk4i")
data = SubResource("VoxelGIData_m5j5n")
diff --git a/client/map/tile_factory.gd b/client/map/tile_factory.gd
index 4f478eb6..8483c744 100644
--- a/client/map/tile_factory.gd
+++ b/client/map/tile_factory.gd
@@ -16,49 +16,62 @@
class_name TileFactory
extends Object
-static func produce(tile_name: String, node_name: String, neighbors: Array) -> Tile:
+class TileCC:
+ var tile_name: String
+ var position: Vector2i
+ var neighbors: Array
+ var floor_mesher: FloorMesher
+ var portal_type: bool
+
+
+static func produce(tile_name: String, position: Vector2i, neighbors: Array, floor_mesher: FloorMesher) -> Tile:
+ var ctx := TileCC.new()
+ ctx.tile_name = tile_name
+ ctx.position = position
+ ctx.neighbors = neighbors
+ ctx.floor_mesher = floor_mesher
match tile_name:
- "black-hole-counter": return ItemPortal.new(node_name, neighbors, false)
- "black-hole": return PlayerPortal.new(node_name, neighbors, false)
- "book": return Book.new(node_name, neighbors)
- "ceiling-lamp": return CeilingLamp.new(node_name, neighbors)
- "chair": return Chair.new(node_name, neighbors)
- "chandelier": return Chandelier.new(node_name, neighbors)
- "conveyor": return Conveyor.new(node_name, neighbors)
- "counter-window": return CounterWindow.new(node_name, neighbors)
- "counter": return CounterBase.new(node_name, neighbors)
- "cuttingboard": return CuttingBoard.new(node_name, neighbors)
- "door": return Door.new(node_name, neighbors)
- "fence": return Fence.new(node_name, neighbors)
- "floor": return Floor.new(node_name, neighbors)
- "freezer": return Freezer.new(node_name, neighbors)
- "grass": return Grass.new(node_name, neighbors)
- "lamp": return Lamp.new(node_name, neighbors)
- "oven": return Oven.new(node_name, neighbors)
- "path": return Path.new(node_name, neighbors)
- "sink": return Sink.new(node_name, neighbors)
- "stove": return Stove.new(node_name, neighbors)
- "street": return Street.new(node_name, neighbors)
- "table": return Table.new(node_name, neighbors)
- "trash": return Trash.new(node_name, neighbors)
- "tree": return ExteriorTree.new(node_name, neighbors)
- "wall-window": return WallWindow.new(node_name, neighbors)
- "wall": return Wall.new(node_name, neighbors)
- "white-hole-counter": return ItemPortal.new(node_name, neighbors, true)
- "white-hole": return PlayerPortal.new(node_name, neighbors, true)
+ "black-hole-counter": return ItemPortal.new(ctx, false)
+ "black-hole": return PlayerPortal.new(ctx, false)
+ "book": return Book.new(ctx)
+ "ceiling-lamp": return CeilingLamp.new(ctx)
+ "chair": return Chair.new(ctx)
+ "chandelier": return Chandelier.new(ctx)
+ "conveyor": return Conveyor.new(ctx)
+ "counter-window": return CounterWindow.new(ctx)
+ "counter": return CounterBase.new(ctx)
+ "cuttingboard": return CuttingBoard.new(ctx)
+ "door": return Door.new(ctx)
+ "fence": return Fence.new(ctx)
+ "floor": return Floor.new(ctx)
+ "freezer": return Freezer.new(ctx)
+ "grass": return Grass.new(ctx)
+ "lamp": return Lamp.new(ctx)
+ "oven": return Oven.new(ctx)
+ "path": return Path.new(ctx)
+ "sink": return Sink.new(ctx)
+ "stove": return Stove.new(ctx)
+ "street": return Street.new(ctx)
+ "table": return Table.new(ctx)
+ "trash": return Trash.new(ctx)
+ "tree": return ExteriorTree.new(ctx)
+ "wall-window": return WallWindow.new(ctx)
+ "wall": return Wall.new(ctx)
+ "white-hole-counter": return ItemPortal.new(ctx, true)
+ "white-hole": return PlayerPortal.new(ctx, true)
- "cheese-crate": return CheeseCrate.new(node_name, neighbors)
- "coconut-crate": return CoconutCrate.new(node_name, neighbors)
- "dirty-plate-crate": return CounterBase.new(node_name, neighbors)
- "fish-crate": return FishCrate.new(node_name, neighbors)
- "flour-crate": return FlourCrate.new(node_name, neighbors)
- "leek-crate": return LeekCrate.new(node_name, neighbors)
- "lettuce-crate": return LettuceCrate.new(node_name, neighbors)
- "steak-crate": return RawSteakCrate.new(node_name, neighbors)
- "rice-crate": return RiceCrate.new(node_name, neighbors)
- "strawberry-crate": return StrawberryCrate.new(node_name, neighbors)
- "tomato-crate": return TomatoCrate.new(node_name, neighbors)
+ "cheese-crate": return CheeseCrate.new(ctx)
+ "coconut-crate": return CoconutCrate.new(ctx)
+ "dirty-plate-crate": return CounterBase.new(ctx)
+ "fish-crate": return FishCrate.new(ctx)
+ "flour-crate": return FlourCrate.new(ctx)
+ "leek-crate": return LeekCrate.new(ctx)
+ "lettuce-crate": return LettuceCrate.new(ctx)
+ "steak-crate": return RawSteakCrate.new(ctx)
+ "rice-crate": return RiceCrate.new(ctx)
+ "strawberry-crate": return StrawberryCrate.new(ctx)
+ "tomato-crate": return TomatoCrate.new(ctx)
var t:
push_warning("tile %s unknown" % t)
- return GenericTile.new(node_name, neighbors, t)
+ return GenericTile.new(ctx)
diff --git a/client/map/tiles/book.gd b/client/map/tiles/book.gd
index bc87ba6b..28d9c75d 100644
--- a/client/map/tiles/book.gd
+++ b/client/map/tiles/book.gd
@@ -17,6 +17,6 @@
class_name Book
extends CounterBase
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/book.tscn").instantiate())
diff --git a/client/map/tiles/ceiling_lamp.gd b/client/map/tiles/ceiling_lamp.gd
index ada24c8b..9740427f 100644
--- a/client/map/tiles/ceiling_lamp.gd
+++ b/client/map/tiles/ceiling_lamp.gd
@@ -16,6 +16,6 @@
class_name CeilingLamp
extends Floor
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/ceiling_lamp.tscn").instantiate())
diff --git a/client/map/tiles/chair.gd b/client/map/tiles/chair.gd
index f45de00c..a56b1bc7 100644
--- a/client/map/tiles/chair.gd
+++ b/client/map/tiles/chair.gd
@@ -16,16 +16,16 @@
class_name Chair
extends Floor
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var chair = preload("res://map/tiles/chair.tscn").instantiate()
var facing = 0;
for i in range(4):
- if neighbors[i] == "conveyor":
+ if ctx.neighbors[i] == "conveyor":
facing = i
break
for i in range(4):
- if neighbors[i] == "table":
+ if ctx.neighbors[i] == "table":
facing = i
break
base.add_child(chair)
diff --git a/client/map/tiles/chandelier.gd b/client/map/tiles/chandelier.gd
index 7ed8bbb5..eb4e989e 100644
--- a/client/map/tiles/chandelier.gd
+++ b/client/map/tiles/chandelier.gd
@@ -16,6 +16,6 @@
class_name Chandelier
extends Floor
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/chandelier.tscn").instantiate())
diff --git a/client/map/tiles/cheese_crate.gd b/client/map/tiles/cheese_crate.gd
index 67591899..39b4f33f 100644
--- a/client/map/tiles/cheese_crate.gd
+++ b/client/map/tiles/cheese_crate.gd
@@ -16,6 +16,6 @@
class_name CheeseCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/cheese_crate.tscn").instantiate())
diff --git a/client/map/tiles/coconut_crate.gd b/client/map/tiles/coconut_crate.gd
index 55ef16d5..a892425a 100644
--- a/client/map/tiles/coconut_crate.gd
+++ b/client/map/tiles/coconut_crate.gd
@@ -16,6 +16,6 @@
class_name CoconutCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/coconut_crate.tscn").instantiate())
diff --git a/client/map/tiles/conveyor.gd b/client/map/tiles/conveyor.gd
index d920915c..30996691 100644
--- a/client/map/tiles/conveyor.gd
+++ b/client/map/tiles/conveyor.gd
@@ -18,8 +18,8 @@ extends Floor
var conveyor: ConveyorModel = preload("res://map/tiles/conveyor.tscn").instantiate()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(conveyor)
static func interact_target() -> Vector3:
diff --git a/client/map/tiles/counter.gd b/client/map/tiles/counter.gd
index 59a8296a..f819490c 100644
--- a/client/map/tiles/counter.gd
+++ b/client/map/tiles/counter.gd
@@ -41,8 +41,8 @@ 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)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var facing: int = 0
var max_series: int = 0
@@ -50,7 +50,7 @@ func _init(rename: String, neighbors: Array):
for start in range(4):
var series = 0
for i in range(4):
- if Counter.is_floor(neighbors[(start + i) % 4]):
+ if Counter.is_floor(ctx.neighbors[(start + i) % 4]):
series += 1
else:
break
@@ -62,7 +62,7 @@ func _init(rename: String, neighbors: Array):
# backsplash
facing = max_idx
if max_series == 1:
- if WallTile.is_wall(neighbors[(max_idx + 2) % 4]):
+ if WallTile.is_wall(ctx.neighbors[(max_idx + 2) % 4]):
kind = CounterKind.STRAIGHT_BACKSPLASH
else:
kind = CounterKind.STRAIGHT
diff --git a/client/map/tiles/counter_base.gd b/client/map/tiles/counter_base.gd
index 649347a3..7576a292 100644
--- a/client/map/tiles/counter_base.gd
+++ b/client/map/tiles/counter_base.gd
@@ -16,8 +16,8 @@
class_name CounterBase
extends Counter
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
match kind:
CounterKind.OUTER_CORNER:
base.add_child(load("res://map/tiles/counter_outer_corner.tscn").instantiate())
diff --git a/client/map/tiles/counter_window.gd b/client/map/tiles/counter_window.gd
index 5646b112..f7ba994d 100644
--- a/client/map/tiles/counter_window.gd
+++ b/client/map/tiles/counter_window.gd
@@ -19,8 +19,8 @@ extends WallTile
static func interact_target() -> Vector3:
return Vector3(0, 0.625, 0)
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
match kind:
WallKind.STRAIGHT:
base.add_child(load("res://map/tiles/counter_window.tscn").instantiate())
diff --git a/client/map/tiles/crate.gd b/client/map/tiles/crate.gd
index 7f6ccd3b..48109ef6 100644
--- a/client/map/tiles/crate.gd
+++ b/client/map/tiles/crate.gd
@@ -19,5 +19,5 @@ extends Counter
static func interact_target() -> Vector3:
return Vector3(0, 0.25, 0)
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
diff --git a/client/map/tiles/cutting_board.gd b/client/map/tiles/cutting_board.gd
index d59372de..9617a0ff 100644
--- a/client/map/tiles/cutting_board.gd
+++ b/client/map/tiles/cutting_board.gd
@@ -19,8 +19,8 @@ extends CounterBase
var board = load("res://map/tiles/cutting_board.tscn").instantiate()
var chopping: AudioStreamPlayer3D = AudioStreamPlayer3D.new()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
chopping.stream = preload("res://map/tiles/sounds/chop.ogg")
add_child(chopping)
base.add_child(board)
diff --git a/client/map/tiles/door.gd b/client/map/tiles/door.gd
index 086b0081..0f0453ba 100644
--- a/client/map/tiles/door.gd
+++ b/client/map/tiles/door.gd
@@ -16,13 +16,12 @@
class_name Door
extends WallTile
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var new_facing = 0
for i in range(4):
- if neighbors[i] == "door":
+ if ctx.neighbors[i] == "door":
new_facing = i
turn_facing(new_facing)
base.add_child(load("res://map/tiles/door.tscn").instantiate())
-
diff --git a/client/map/tiles/exterior_tree.gd b/client/map/tiles/exterior_tree.gd
index 9054cbaa..05f507fc 100644
--- a/client/map/tiles/exterior_tree.gd
+++ b/client/map/tiles/exterior_tree.gd
@@ -19,10 +19,10 @@ extends Grass
const SCALE: Vector3 = Vector3(100., 100., 100.)
const ROT: Vector3 = Vector3(1.5 * PI, 0., 0.)
-func _init(rename: String, _neighbors: Array):
- super(rename, _neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var random = RandomNumberGenerator.new()
- random.seed = rename.hash()
+ random.seed = str(ctx.position).hash()
var tree: int = random.randi_range(1,5)
var trunk: Mesh = load("res://map/tiles/tree/trunk_%d.res" % tree)
var leaves: Mesh = load("res://map/tiles/tree/leaves_%d_%s.res" % [
diff --git a/client/map/tiles/fence.gd b/client/map/tiles/fence.gd
index f74a992f..12dc2b2d 100644
--- a/client/map/tiles/fence.gd
+++ b/client/map/tiles/fence.gd
@@ -16,8 +16,8 @@
class_name Fence
extends WallTile
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
match kind:
WallKind.STRAIGHT:
base.add_child(load("res://map/tiles/fence_straight.tscn").instantiate())
diff --git a/client/map/tiles/fish_crate.gd b/client/map/tiles/fish_crate.gd
index 289bcce3..671dc384 100644
--- a/client/map/tiles/fish_crate.gd
+++ b/client/map/tiles/fish_crate.gd
@@ -16,6 +16,6 @@
class_name FishCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/fish_crate.tscn").instantiate())
diff --git a/client/map/tiles/floor.gd b/client/map/tiles/floor.gd
index 666a6699..ac4b0c15 100644
--- a/client/map/tiles/floor.gd
+++ b/client/map/tiles/floor.gd
@@ -16,5 +16,9 @@
class_name Floor
extends Tile
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
+ ctx.floor_mesher.add_tile(ctx.position)
+
func get_base_mesh():
return preload("res://map/tiles/floor.tscn").instantiate()
diff --git a/client/map/tiles/floor.png b/client/map/tiles/floor.png
new file mode 100644
index 00000000..557cb8d3
--- /dev/null
+++ b/client/map/tiles/floor.png
Binary files differ
diff --git a/client/map/tiles/floor.png.import b/client/map/tiles/floor.png.import
new file mode 100644
index 00000000..37a774f3
--- /dev/null
+++ b/client/map/tiles/floor.png.import
@@ -0,0 +1,36 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://dexb1ms3xcm4h"
+path.s3tc="res://.godot/imported/floor.png-f30002fe9e7b5dbe5fc67e98616b296a.s3tc.ctex"
+path.etc2="res://.godot/imported/floor.png-f30002fe9e7b5dbe5fc67e98616b296a.etc2.ctex"
+metadata={
+"imported_formats": ["s3tc_bptc", "etc2_astc"],
+"vram_texture": true
+}
+
+[deps]
+
+source_file="res://map/tiles/floor.png"
+dest_files=["res://.godot/imported/floor.png-f30002fe9e7b5dbe5fc67e98616b296a.s3tc.ctex", "res://.godot/imported/floor.png-f30002fe9e7b5dbe5fc67e98616b296a.etc2.ctex"]
+
+[params]
+
+compress/mode=2
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=true
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/client/map/tiles/floor.res b/client/map/tiles/floor.res
index eaba0c52..bcd3625c 100644
--- a/client/map/tiles/floor.res
+++ b/client/map/tiles/floor.res
Binary files differ
diff --git a/client/map/tiles/floor.tscn b/client/map/tiles/floor.tscn
index 61299e3a..5132f15b 100644
--- a/client/map/tiles/floor.tscn
+++ b/client/map/tiles/floor.tscn
@@ -6,5 +6,6 @@
[node name="Mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
+visible = false
mesh = ExtResource("1_8pd6m")
skeleton = NodePath("")
diff --git a/client/map/tiles/floor_material.tres b/client/map/tiles/floor_material.tres
new file mode 100644
index 00000000..9ae98f89
--- /dev/null
+++ b/client/map/tiles/floor_material.tres
@@ -0,0 +1,7 @@
+[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://lpi2oc57ldhh"]
+
+[ext_resource type="Texture2D" uid="uid://dexb1ms3xcm4h" path="res://map/tiles/floor.png" id="1_o12fq"]
+
+[resource]
+albedo_texture = ExtResource("1_o12fq")
+texture_filter = 0
diff --git a/client/map/tiles/floor_mesher.gd b/client/map/tiles/floor_mesher.gd
new file mode 100644
index 00000000..2345a834
--- /dev/null
+++ b/client/map/tiles/floor_mesher.gd
@@ -0,0 +1,86 @@
+# Hurry Curry! - a game about cooking
+# Copyright 2024 nokoe
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+class_name FloorMesher
+extends Object
+
+
+var tiles: Dictionary
+var instance: MeshInstance3D
+
+func add_tile(pos: Vector2i):
+ tiles[str(pos)] = pos
+
+func flush() -> ArrayMesh:
+ var st := SurfaceTool.new()
+ st.begin(Mesh.PRIMITIVE_TRIANGLES)
+
+ while not tiles.is_empty():
+ var key: String = tiles.keys()[0]
+ var tile_position: Vector2i = tiles[key]
+ var shift := Vector2i.ZERO
+ # move the origin of the rectangle to the upper left corner
+ while true:
+ #if tiles.has(str(tile_position + shift + Vector2i.UP + Vector2i.LEFT)):
+ # shift += Vector2i.UP + Vector2i.LEFT
+ if tiles.has(str(tile_position + shift + Vector2i.UP)):
+ shift += Vector2i.UP
+ elif tiles.has(str(tile_position + shift + Vector2i.LEFT)):
+ shift += Vector2i.LEFT
+ else:
+ break
+
+ var rectangle_origin := tile_position + shift
+ var rectangle := Vector2i.ONE
+
+ # go down as long as possible
+ while tiles.has(str(rectangle_origin + Vector2i(0, rectangle.y))):
+ rectangle.y += 1
+
+ # try to go right as long as possible by checking if whole columns are long enough
+ while true:
+ var column_possible := true
+ for i in range(0, rectangle.y):
+ column_possible = tiles.has(str(rectangle_origin + Vector2i(rectangle.x, i)))
+ if not column_possible: break
+ if column_possible:
+ rectangle.x += 1
+ else: break
+
+ st.set_normal(Vector3.UP)
+ st.set_uv(Vector2.ZERO)
+ st.add_vertex(Vector3(rectangle_origin.x, 0., rectangle_origin.y))
+ st.set_normal(Vector3.UP)
+ st.set_uv(Vector2(rectangle.x, 0.))
+ st.add_vertex(Vector3(rectangle_origin.x + rectangle.x, 0., rectangle_origin.y))
+ st.set_normal(Vector3.UP)
+ st.set_uv(rectangle)
+ st.add_vertex(Vector3(rectangle_origin.x + rectangle.x, 0., rectangle_origin.y + rectangle.y))
+
+ st.set_normal(Vector3.UP)
+ st.set_uv(Vector2(0., rectangle.y))
+ st.add_vertex(Vector3(rectangle_origin.x, 0., rectangle_origin.y + rectangle.y))
+ st.set_normal(Vector3.UP)
+ st.set_uv(Vector2.ZERO)
+ st.add_vertex(Vector3(rectangle_origin.x, 0., rectangle_origin.y))
+ st.set_normal(Vector3.UP)
+ st.set_uv(rectangle)
+ st.add_vertex(Vector3(rectangle_origin.x + rectangle.x, 0., rectangle_origin.y + rectangle.y))
+
+ # remove the rectangle from the "queue"
+ for x in range(rectangle_origin.x, rectangle_origin.x + rectangle.x):
+ for y in range(rectangle_origin.y, rectangle_origin.y + rectangle.y):
+ tiles.erase(str(Vector2i(x, y)))
+ return st.commit()
diff --git a/client/map/tiles/flour_crate.gd b/client/map/tiles/flour_crate.gd
index 4949e646..89ba07a3 100644
--- a/client/map/tiles/flour_crate.gd
+++ b/client/map/tiles/flour_crate.gd
@@ -16,6 +16,6 @@
class_name FlourCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/flour_crate.tscn").instantiate())
diff --git a/client/map/tiles/freezer.gd b/client/map/tiles/freezer.gd
index bca8d607..13d7ae07 100644
--- a/client/map/tiles/freezer.gd
+++ b/client/map/tiles/freezer.gd
@@ -18,8 +18,8 @@ extends Counter
var freezer: FreezerModel = load("res://map/tiles/freezer.tscn").instantiate()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(freezer)
func put_item(i: Item):
diff --git a/client/map/tiles/full_tile.gd b/client/map/tiles/full_tile.gd
index 99f12296..ed612e97 100644
--- a/client/map/tiles/full_tile.gd
+++ b/client/map/tiles/full_tile.gd
@@ -18,8 +18,8 @@ extends Floor
var static_body = StaticBody3D.new()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var shape = CollisionShape3D.new()
var box = BoxShape3D.new()
shape.position.y += .5
diff --git a/client/map/tiles/generic_tile.gd b/client/map/tiles/generic_tile.gd
index 87d7aab4..fbc7ab12 100644
--- a/client/map/tiles/generic_tile.gd
+++ b/client/map/tiles/generic_tile.gd
@@ -16,10 +16,10 @@
class_name GenericTile
extends Floor
-func _init(rename: String, neighbors: Array, kind: String):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var label = Label3D.new()
- label.text = kind
+ label.text = ctx.tile_name
label.position.y = 0.5
label.billboard = BaseMaterial3D.BILLBOARD_ENABLED
item_base.add_child(label)
diff --git a/client/map/tiles/grass.gd b/client/map/tiles/grass.gd
index 9b5cbe7b..0f67174c 100644
--- a/client/map/tiles/grass.gd
+++ b/client/map/tiles/grass.gd
@@ -18,11 +18,11 @@ extends Tile
const GRASS_MESH: Mesh = preload("res://map/tiles/grass_side.tres")
-func _init(rename: String, _neighbors: Array):
- super(rename, _neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var random = RandomNumberGenerator.new()
- random.seed = rename.hash()
+ random.seed = str(ctx.position).hash()
var multimesh_instance := MultiMeshInstance3D.new()
diff --git a/client/map/tiles/grass_side.tres b/client/map/tiles/grass_side.tres
index 3e9e0729..3f29e10e 100644
--- a/client/map/tiles/grass_side.tres
+++ b/client/map/tiles/grass_side.tres
@@ -1,12 +1,12 @@
[gd_resource type="ArrayMesh" load_steps=4 format=3 uid="uid://l2by4gv4wpd1"]
-[ext_resource type="Texture2D" uid="uid://p35o0tkyfmrl" path="res://map/tiles/grass_side.webp" id="1_ud4dd"]
+[ext_resource type="Texture2D" uid="uid://p35o0tkyfmrl" path="res://map/tiles/grass_side.webp" id="1_d17wb"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nudmg"]
resource_name = "grass"
transparency = 4
cull_mode = 2
-albedo_texture = ExtResource("1_ud4dd")
+albedo_texture = ExtResource("1_d17wb")
subsurf_scatter_strength = 1.0
backlight_enabled = true
backlight = Color(1, 1, 1, 1)
diff --git a/client/map/tiles/item_portal.gd b/client/map/tiles/item_portal.gd
index c4762ae2..080b70ed 100644
--- a/client/map/tiles/item_portal.gd
+++ b/client/map/tiles/item_portal.gd
@@ -17,7 +17,7 @@ class_name ItemPortal
extends CounterBase
var model: PortalModel = load("res://map/tiles/portal.tscn").instantiate()
-func _init(rename: String, neighbors: Array, type: bool):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC, type: bool):
+ super(ctx)
model.configure(0.2, type)
base.add_child(model)
diff --git a/client/map/tiles/lamp.gd b/client/map/tiles/lamp.gd
index 41713845..0493deaf 100644
--- a/client/map/tiles/lamp.gd
+++ b/client/map/tiles/lamp.gd
@@ -16,6 +16,6 @@
class_name Lamp
extends Grass
-func _init(rename: String, neighbors: Array):
+func _init(ctx: TileFactory.TileCC):
base.add_child(preload("res://map/tiles/lamp.tscn").instantiate())
- super(rename, neighbors)
+ super(ctx)
diff --git a/client/map/tiles/leek_crate.gd b/client/map/tiles/leek_crate.gd
index a025516b..d61ad767 100644
--- a/client/map/tiles/leek_crate.gd
+++ b/client/map/tiles/leek_crate.gd
@@ -16,6 +16,6 @@
class_name LeekCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/leek_crate.tscn").instantiate())
diff --git a/client/map/tiles/oven.gd b/client/map/tiles/oven.gd
index c5df63f8..84f64e20 100644
--- a/client/map/tiles/oven.gd
+++ b/client/map/tiles/oven.gd
@@ -18,8 +18,8 @@ extends Counter
var oven: OvenModel = load("res://map/tiles/oven.tscn").instantiate()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(oven)
func put_item(i: Item):
diff --git a/client/map/tiles/player_portal.gd b/client/map/tiles/player_portal.gd
index 637f2c78..bc5fa9d1 100644
--- a/client/map/tiles/player_portal.gd
+++ b/client/map/tiles/player_portal.gd
@@ -17,7 +17,7 @@ class_name PlayerPortal
extends Floor
var model: PortalModel = load("res://map/tiles/portal.tscn").instantiate()
-func _init(rename: String, neighbors: Array, type: bool):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC, type: bool):
+ super(ctx)
model.configure(0.4, type)
base.add_child(model)
diff --git a/client/map/tiles/raw_steak_crate.gd b/client/map/tiles/raw_steak_crate.gd
index 4c1240ff..ef439101 100644
--- a/client/map/tiles/raw_steak_crate.gd
+++ b/client/map/tiles/raw_steak_crate.gd
@@ -16,6 +16,6 @@
class_name RawSteakCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/raw_steak_crate.tscn").instantiate())
diff --git a/client/map/tiles/rice_crate.gd b/client/map/tiles/rice_crate.gd
index 7c596d44..c5352a93 100644
--- a/client/map/tiles/rice_crate.gd
+++ b/client/map/tiles/rice_crate.gd
@@ -16,6 +16,6 @@
class_name RiceCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/rice_crate.tscn").instantiate())
diff --git a/client/map/tiles/sink.gd b/client/map/tiles/sink.gd
index efa85ed0..fa587097 100644
--- a/client/map/tiles/sink.gd
+++ b/client/map/tiles/sink.gd
@@ -20,8 +20,8 @@ var particles: SinkParticles = preload("res://map/tiles/sink_particles.tscn").in
var running: AudioStreamPlayer3D = AudioStreamPlayer3D.new()
var stopping: AudioStreamPlayer3D = AudioStreamPlayer3D.new()
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(particles)
match kind:
CounterKind.STRAIGHT:
diff --git a/client/map/tiles/steak_crate.gd b/client/map/tiles/steak_crate.gd
index 71062b39..33316807 100644
--- a/client/map/tiles/steak_crate.gd
+++ b/client/map/tiles/steak_crate.gd
@@ -16,6 +16,6 @@
class_name SteakCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/raw_steak_crate.tscn").instantiate())
diff --git a/client/map/tiles/stove.gd b/client/map/tiles/stove.gd
index 9792041f..d659b570 100644
--- a/client/map/tiles/stove.gd
+++ b/client/map/tiles/stove.gd
@@ -16,8 +16,8 @@
class_name Stove
extends Counter
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/stove.tscn").instantiate())
static func interact_target() -> Vector3:
diff --git a/client/map/tiles/strawberry_crate.gd b/client/map/tiles/strawberry_crate.gd
index 6a236af4..186ecbe8 100644
--- a/client/map/tiles/strawberry_crate.gd
+++ b/client/map/tiles/strawberry_crate.gd
@@ -16,6 +16,6 @@
class_name StrawberryCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/strawberry_crate.tscn").instantiate())
diff --git a/client/map/tiles/table.gd b/client/map/tiles/table.gd
index 8d04b60a..11dee83d 100644
--- a/client/map/tiles/table.gd
+++ b/client/map/tiles/table.gd
@@ -16,8 +16,8 @@
class_name Table
extends FullTile
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/table.tscn").instantiate())
static func interact_target() -> Vector3:
diff --git a/client/map/tiles/tile.gd b/client/map/tiles/tile.gd
index bd507760..c5f75c57 100644
--- a/client/map/tiles/tile.gd
+++ b/client/map/tiles/tile.gd
@@ -28,11 +28,11 @@ enum Facing {
X = 3,
}
-func _init(rename: String, _neighbors: Array):
+func _init(ctx: TileFactory.TileCC):
base.name = "Base"
base.position += Vector3(0.5, 0, 0.5)
add_child(base)
- self.name = rename
+ self.name = str(ctx.position)
var item_base_ = Node3D.new()
# this method is supposed to be overriden
@warning_ignore("static_called_on_instance")
diff --git a/client/map/tiles/tomato_crate.gd b/client/map/tiles/tomato_crate.gd
index bcfc67d5..e9351bbf 100644
--- a/client/map/tiles/tomato_crate.gd
+++ b/client/map/tiles/tomato_crate.gd
@@ -17,6 +17,6 @@
class_name TomatoCrate
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/tomato_crate.tscn").instantiate())
diff --git a/client/map/tiles/trash.gd b/client/map/tiles/trash.gd
index ad93a1d9..cbbe78b4 100644
--- a/client/map/tiles/trash.gd
+++ b/client/map/tiles/trash.gd
@@ -16,6 +16,6 @@
class_name Trash
extends Crate
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
base.add_child(load("res://map/tiles/trash.tscn").instantiate())
diff --git a/client/map/tiles/wall.gd b/client/map/tiles/wall.gd
index a6d650da..5b183412 100644
--- a/client/map/tiles/wall.gd
+++ b/client/map/tiles/wall.gd
@@ -16,8 +16,8 @@
class_name Wall
extends WallTile
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
match kind:
WallKind.STRAIGHT:
base.add_child(load("res://map/tiles/wall_straight.tscn").instantiate())
diff --git a/client/map/tiles/wall_tile.gd b/client/map/tiles/wall_tile.gd
index 0f3e6230..0276baea 100644
--- a/client/map/tiles/wall_tile.gd
+++ b/client/map/tiles/wall_tile.gd
@@ -34,15 +34,15 @@ enum WallKind {
var kind: WallKind = WallKind.STRAIGHT
var facing: int = 0
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
var max_series: int = 0
var max_idx: int = 0
for start in range(4):
var series = 0
for i in range(4):
- var i_name = neighbors[(start + i) % 4]
+ var i_name = ctx.neighbors[(start + i) % 4]
if WallTile.is_wall(i_name):
series += 1
else:
diff --git a/client/map/tiles/window.gd b/client/map/tiles/window.gd
index 0a3c9eba..c41890c8 100644
--- a/client/map/tiles/window.gd
+++ b/client/map/tiles/window.gd
@@ -19,8 +19,8 @@ extends WallTile
static func interact_target() -> Vector3:
return Vector3(0, 0.625, 0)
-func _init(rename: String, neighbors: Array):
- super(rename, neighbors)
+func _init(ctx: TileFactory.TileCC):
+ super(ctx)
match kind:
WallKind.STRAIGHT:
base.add_child(load("res://map/tiles/window.tscn").instantiate())
diff --git a/client/multiplayer.gd b/client/multiplayer.gd
index 1b56572d..d70dbaed 100644
--- a/client/multiplayer.gd
+++ b/client/multiplayer.gd
@@ -22,7 +22,7 @@ signal packet(packet: Dictionary)
signal connection_closed()
static var VERSION_MAJOR: int = 7
-static var VERSION_MINOR: int = 2
+static var VERSION_MINOR: int = 3
var connected := false
var socket := WebSocketPeer.new()