diff options
Diffstat (limited to 'client/map')
| -rw-r--r-- | client/map/map.gd | 12 | ||||
| -rw-r--r-- | client/map/tile_factory.gd | 4 | ||||
| -rw-r--r-- | client/map/tiles/screen/screen.gd | 5 | ||||
| -rw-r--r-- | client/map/tiles/screen/screen.tscn | 3 | ||||
| -rw-r--r-- | client/map/tiles/screen/screen_model.gd | 22 | ||||
| -rw-r--r-- | client/map/tiles/screen/screen_model.gd.uid | 1 |
6 files changed, 39 insertions, 8 deletions
diff --git a/client/map/map.gd b/client/map/map.gd index eb1e13bb..da9f3f68 100644 --- a/client/map/map.gd +++ b/client/map/map.gd @@ -49,11 +49,11 @@ func get_tile_item(pos: Vector2i): # -> Item? if e == null: return null return e.item -func set_all_tiles(changes: Dictionary[Vector2i, Array]): +func set_all_tiles(changes: Dictionary[Vector2i, Array], srv: Game.ServerContext = null): for pos: Vector2i in changes: - set_tiles(Vector2i(pos.x, pos.y), changes[pos], changes) + set_tiles(Vector2i(pos.x, pos.y), changes[pos], changes, srv) -func set_tiles(pos: Vector2i, tiles: Array = [], pending_changes: Dictionary[Vector2i, Array] = {}): # tiles: Array[String] +func set_tiles(pos: Vector2i, tiles: Array = [], pending_changes: Dictionary[Vector2i, Array] = {}, srv: Game.ServerContext = null): # tiles: Array[String] var tile_info = tile_by_pos.get(pos) if tile_info != null: for inst: Tile in tile_info.tile_instances: @@ -61,10 +61,10 @@ func set_tiles(pos: Vector2i, tiles: Array = [], pending_changes: Dictionary[Vec # TODO: Don't return, but handle changes which weren't handled by the instance below. if inst.change(tile): return # Instance handled change itself! _remove_tile(pos) - if not tiles.is_empty(): _add_tiles(pos, tiles, pending_changes) + if not tiles.is_empty(): _add_tiles(pos, tiles, pending_changes, srv) if autoflush: flush() -func _add_tiles(pos: Vector2i, tiles: Array, pending_changes: Dictionary[Vector2i, Array] = {}) -> void: +func _add_tiles(pos: Vector2i, tiles: Array, pending_changes: Dictionary[Vector2i, Array], srv: Game.ServerContext) -> void: # Combinate tiles for k in TILE_COMBINATOR: if G.has_all(tiles, k): @@ -86,7 +86,7 @@ func _add_tiles(pos: Vector2i, tiles: Array, pending_changes: Dictionary[Vector2 add_child(tiles_parent) var tile_instances: Array[Tile] = [] for tile_name: String in tiles: - var tile := tile_factory.produce(tile_name, pos, neighbors) + var tile := tile_factory.produce(tile_name, pos, neighbors, srv) tile_instances.append(tile) tile.position = Vector3(pos.x, 0, pos.y) tiles_parent.add_child(tile) diff --git a/client/map/tile_factory.gd b/client/map/tile_factory.gd index ce239f4c..1ff6baf4 100644 --- a/client/map/tile_factory.gd +++ b/client/map/tile_factory.gd @@ -31,6 +31,7 @@ class TileCC: var position: Vector2i var neighbors: Array var floor_meshers: Dictionary[String, FloorMesher] + var server_context: Game.ServerContext var floor_meshers: Dictionary[String, FloorMesher] = { "floor": FloorMesher.new(Floor.floor_mesh()), @@ -39,7 +40,7 @@ var floor_meshers: Dictionary[String, FloorMesher] = { "street": FloorMesher.new(Street.floor_mesh()) } -func produce(raw_name: String, position: Vector2i, neighbors: Array) -> Tile: +func produce(raw_name: String, position: Vector2i, neighbors: Array, server_context: Game.ServerContext = null) -> Tile: var tile_name = TileName.new(raw_name) var ctx := TileCC.new() @@ -51,6 +52,7 @@ func produce(raw_name: String, position: Vector2i, neighbors: Array) -> Tile: else: return null ) ctx.floor_meshers = floor_meshers + ctx.server_context = server_context match tile_name.name: "book": return CounterBase.new(ctx, preload("res://map/tiles/book.tscn")) diff --git a/client/map/tiles/screen/screen.gd b/client/map/tiles/screen/screen.gd index c95f0753..3e059fc1 100644 --- a/client/map/tiles/screen/screen.gd +++ b/client/map/tiles/screen/screen.gd @@ -18,4 +18,7 @@ extends Tile func _init(ctx: TileFactory.TileCC): super(ctx) - base.add_child(load("res://map/tiles/screen/screen.tscn").instantiate()) + var screen_model: ScreenModel = load("res://map/tiles/screen/screen.tscn").instantiate() + base.add_child(screen_model) + screen_model.set_server_context(ctx.server_context) +
\ No newline at end of file diff --git a/client/map/tiles/screen/screen.tscn b/client/map/tiles/screen/screen.tscn index 82221eeb..a1f88294 100644 --- a/client/map/tiles/screen/screen.tscn +++ b/client/map/tiles/screen/screen.tscn @@ -1,11 +1,13 @@ [gd_scene format=3 uid="uid://vqe0wrt0ddq"] [ext_resource type="ArrayMesh" uid="uid://g6nwwhptmmmd" path="res://map/tiles/screen/screen_display.res" id="1_d1utq"] +[ext_resource type="Script" uid="uid://cye7akcsp46cv" path="res://map/tiles/screen/screen_model.gd" id="1_fabw7"] [ext_resource type="ArrayMesh" uid="uid://nsmq1ko2woad" path="res://map/tiles/screen/screen_base.res" id="1_mm46a"] [ext_resource type="PackedScene" uid="uid://d22cslgao5jd4" path="res://map/tiles/floor.tscn" id="3_dmy1m"] [ext_resource type="PackedScene" uid="uid://dgtdfctc0x78v" path="res://gui/menus/screen_info.tscn" id="4_ebgc8"] [node name="Screen" type="Node3D" unique_id=1614533170] +script = ExtResource("1_fabw7") [node name="Base" type="MeshInstance3D" parent="." unique_id=597805735] transform = Transform3D(2, 0, 0, 0, 0, -2, 0, 2, 0, 0, 0, 0) @@ -20,6 +22,7 @@ disable_3d = true size = Vector2i(834, 480) [node name="ScreenInfo" parent="Display/ScreenViewport" unique_id=907327052 instance=ExtResource("4_ebgc8")] +script = null [node name="Floor" parent="." unique_id=527188940 instance=ExtResource("3_dmy1m")] transform = Transform3D(12.117, 0, 0, 0, 12.117, 0, 0, 0, 12.117, 0, 0, 0) diff --git a/client/map/tiles/screen/screen_model.gd b/client/map/tiles/screen/screen_model.gd new file mode 100644 index 00000000..c0f0cbde --- /dev/null +++ b/client/map/tiles/screen/screen_model.gd @@ -0,0 +1,22 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2025 Hurry Curry! contributors +# +# 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/>. +# +extends Node3D +class_name ScreenModel + +func set_server_context(server_context: Game.ServerContext) -> void: + $Display/ScreenViewport/ScreenInfo/MarginContainer/VBoxContainer/RichTextLabel.text = """[font_size=48][b]%s[/b] + +%s[/font_size]""" % [server_context.name, server_context.motd] diff --git a/client/map/tiles/screen/screen_model.gd.uid b/client/map/tiles/screen/screen_model.gd.uid new file mode 100644 index 00000000..6a2a81b0 --- /dev/null +++ b/client/map/tiles/screen/screen_model.gd.uid @@ -0,0 +1 @@ +uid://cye7akcsp46cv |