From 8fe13a42ca6977955b1f54e6ea080fcfd8e6c716 Mon Sep 17 00:00:00 2001 From: adtpdn Date: Thu, 24 Oct 2024 17:40:10 +0800 Subject: [PATCH] last update --- addons/enhanced_gridmap/enhanced_gridmap.gd | 313 ++++++++++-------- .../enhanced_gridmap/meshlibrary/default.tres | 12 +- assets/models/tiles/tile_coin.tres | 43 +++ assets/models/tiles/tile_diamond.tres | 42 +++ assets/styles/box_flat.tres | 12 + scenes/main.tscn | 33 +- scenes/player.tscn | 7 +- 7 files changed, 320 insertions(+), 142 deletions(-) create mode 100644 assets/models/tiles/tile_coin.tres create mode 100644 assets/models/tiles/tile_diamond.tres create mode 100644 assets/styles/box_flat.tres diff --git a/addons/enhanced_gridmap/enhanced_gridmap.gd b/addons/enhanced_gridmap/enhanced_gridmap.gd index 7325ba1..59faad9 100644 --- a/addons/enhanced_gridmap/enhanced_gridmap.gd +++ b/addons/enhanced_gridmap/enhanced_gridmap.gd @@ -23,20 +23,46 @@ var grid_data: Array = [] # 3D array [floor][row][column] var astar_by_floor = {} # Dictionary of AStar2D instances per floor var path = [] -# Item states -enum ItemState {NORMAL, HOVER, START, END, NON_WALKABLE} +# Direction and movement systems +enum Direction { + NORTHWEST, NORTH, NORTHEAST, + WEST, CENTER, EAST, + SOUTHWEST, SOUTH, SOUTHEAST +} -# Add this to the class variables var diagonal_movement: bool = false +class NeighborInfo: + var position: Vector2i + var direction: Direction + var is_walkable: bool + + func _init(pos: Vector2i, dir: Direction, walkable: bool): + position = pos + direction = dir + is_walkable = walkable + func _ready(): mesh_library_changed.connect(_on_mesh_library_changed) if not Engine.is_editor_hint() and auto_generate: generate_grid() - - # Validate item indices validate_item_indices() +# Core grid management functions +func set_columns(value: int): + columns = value + if auto_generate: + generate_grid() + else: + update_grid_data() + +func set_rows(value: int): + rows = value + if auto_generate: + generate_grid() + else: + update_grid_data() + func set_floors(value: int): floors = value if auto_generate: @@ -44,6 +70,12 @@ func set_floors(value: int): else: update_grid_data() +func set_auto_generate(value: bool): + auto_generate = value + if auto_generate: + generate_grid() + +# Item validation func validate_item_indices(): if not mesh_library: print("Warning: No MeshLibrary assigned to GridMap") @@ -63,34 +95,13 @@ func validate_item_indices(): if non_walkable_items.is_empty(): non_walkable_items = [max_index] -func set_columns(value: int): - columns = value - if auto_generate: - generate_grid() - else: - update_grid_data() - -func set_rows(value: int): - rows = value - if auto_generate: - generate_grid() - else: - update_grid_data() - -func set_auto_generate(value: bool): - auto_generate = value - if auto_generate: - generate_grid() - -# Modified generate_grid to support floors +# Grid generation and management func generate_grid(floor_index: int = -1): if floor_index == -1: - # Generate all floors clear() for y in range(floors): generate_floor(y) else: - # Generate specific floor clear_floor(floor_index) generate_floor(floor_index) @@ -114,14 +125,13 @@ func generate_floor(floor_index: int): for z in range(rows): set_cell_item(Vector3i(x, floor_index, z), normal_items[0]) -# Clear specific floor +# Grid operations func clear_floor(floor_index: int): for x in range(columns): for z in range(rows): - set_cell_item(Vector3i(x, floor_index, z), INVALID_CELL_ITEM) + set_cell_item(Vector3i(x, floor_index, z), -1) update_grid_data() -# Modified clear_grid to support floors func clear_grid(floor_index: int = -1): if floor_index == -1: clear() @@ -129,7 +139,36 @@ func clear_grid(floor_index: int = -1): clear_floor(floor_index) update_grid_data() -# Modified randomize_grid to support floors +func fill_grid(item_index: int, floor_index: int = -1): + if not mesh_library: + print("No MeshLibrary assigned to GridMap") + return + + if item_index < 0 or item_index >= mesh_library.get_item_list().size(): + print("Invalid item index") + return + + if floor_index == -1: + for y in range(floors): + fill_floor(item_index, y) + else: + if floor_index >= 0 and floor_index < floors: + fill_floor(item_index, floor_index) + else: + print("Invalid floor index") + + update_grid_data() + initialize_astar() + update_astar_costs() + +func fill_floor(item_index: int, floor_index: int): + for x in range(columns): + for z in range(rows): + var cell_pos = Vector3i(x, floor_index, z) + var current_orientation = get_cell_item_orientation(cell_pos) + set_cell_item(cell_pos, item_index, current_orientation) + +# Randomization functions func randomize_grid(floor_index: int = -1): if floor_index == -1: for y in range(floors): @@ -153,7 +192,7 @@ func randomize_floor(floor_index: int): for x in range(columns): for z in range(rows): - var random_value = rng.randi() % 100 # Generate a random number between 0 and 99 + var random_value = rng.randi() % 100 var item_index if random_value < 80: item_index = normal_items[rng.randi() % normal_items.size()] @@ -161,7 +200,6 @@ func randomize_floor(floor_index: int): item_index = non_walkable_items[rng.randi() % non_walkable_items.size()] set_cell_item(Vector3i(x, floor_index, z), item_index) -# Modified randomize_grid_custom to properly handle mesh library items func randomize_grid_custom(randomize_states: Array, floor_index: int = -1): if not mesh_library: print("Error: No MeshLibrary assigned to GridMap") @@ -171,7 +209,6 @@ func randomize_grid_custom(randomize_states: Array, floor_index: int = -1): for y in range(floors): randomize_floor_custom(randomize_states, y) else: - # Randomize specific floor if floor_index >= 0 and floor_index < floors: randomize_floor_custom(randomize_states, floor_index) else: @@ -203,13 +240,11 @@ func randomize_floor_custom(randomize_states: Array, floor_index: int): selected_state = state break - # Get current cell orientation var current_orientation = get_cell_item_orientation(cell_pos) if selected_state: set_cell_item(cell_pos, selected_state.id, current_orientation) else: - # Find first enabled state or use normal item as fallback var fallback_state = null for state in randomize_states: if state.include_in_randomize: @@ -221,117 +256,102 @@ func randomize_floor_custom(randomize_states: Array, floor_index: int): else: set_cell_item(cell_pos, normal_items[0], current_orientation) -# Fill grid for specific floor -func fill_grid(item_index: int, floor_index: int = -1): - if not mesh_library: - print("No MeshLibrary assigned to GridMap") - return +# Improved neighbor checking system +func get_neighbors(current_pos: Vector2i, floor_index: int) -> Array[NeighborInfo]: + var neighbors: Array[NeighborInfo] = [] - if item_index < 0 or item_index >= mesh_library.get_item_list().size(): - print("Invalid item index") - return + var directions = { + Direction.NORTHWEST: Vector2i(-1, -1), + Direction.NORTH: Vector2i(0, -1), + Direction.NORTHEAST: Vector2i(1, -1), + Direction.WEST: Vector2i(-1, 0), + Direction.EAST: Vector2i(1, 0), + Direction.SOUTHWEST: Vector2i(-1, 1), + Direction.SOUTH: Vector2i(0, 1), + Direction.SOUTHEAST: Vector2i(1, 1) + } - if floor_index == -1: - for y in range(floors): - fill_floor(item_index, y) - else: - # Fill specific floor - if floor_index >= 0 and floor_index < floors: - fill_floor(item_index, floor_index) - else: - print("Invalid floor index") + for dir in directions: + var offset = directions[dir] + var neighbor_pos = current_pos + offset + + if is_position_valid(neighbor_pos): + var is_walkable = is_cell_walkable(neighbor_pos, floor_index) + + if is_diagonal_direction(dir): + var adjacent1: Vector2i + var adjacent2: Vector2i + + match dir: + Direction.NORTHWEST: + adjacent1 = current_pos + Vector2i(-1, 0) + adjacent2 = current_pos + Vector2i(0, -1) + Direction.NORTHEAST: + adjacent1 = current_pos + Vector2i(1, 0) + adjacent2 = current_pos + Vector2i(0, -1) + Direction.SOUTHWEST: + adjacent1 = current_pos + Vector2i(-1, 0) + adjacent2 = current_pos + Vector2i(0, 1) + Direction.SOUTHEAST: + adjacent1 = current_pos + Vector2i(1, 0) + adjacent2 = current_pos + Vector2i(0, 1) + + is_walkable = is_walkable and \ + is_position_valid(adjacent1) and is_cell_walkable(adjacent1, floor_index) and \ + is_position_valid(adjacent2) and is_cell_walkable(adjacent2, floor_index) + + if diagonal_movement or not is_diagonal_direction(dir): + neighbors.append(NeighborInfo.new(neighbor_pos, dir, is_walkable)) - update_grid_data() - initialize_astar() - update_astar_costs() + return neighbors -func fill_floor(item_index: int, floor_index: int): - for x in range(columns): - for z in range(rows): - var cell_pos = Vector3i(x, floor_index, z) - # Preserve the current cell's orientation when filling - var current_orientation = get_cell_item_orientation(cell_pos) - set_cell_item(cell_pos, item_index, current_orientation) +# Helper functions for neighbor checking +func is_diagonal_direction(direction: Direction) -> bool: + return direction in [Direction.NORTHWEST, Direction.NORTHEAST, + Direction.SOUTHWEST, Direction.SOUTHEAST] -func _on_mesh_library_changed(): - validate_item_indices() - if auto_generate: - generate_grid() +func is_position_valid(pos: Vector2i) -> bool: + return pos.x >= 0 and pos.x < columns and pos.y >= 0 and pos.y < rows -func _set(property, value): - if property == "mesh_library": - mesh_library = value - _on_mesh_library_changed() - return true - return false +func is_cell_walkable(pos: Vector2i, floor_index: int) -> bool: + var cell_item = get_cell_item(Vector3i(pos.x, floor_index, pos.y)) + return cell_item != -1 and not (cell_item in non_walkable_items) -# Modified update_grid_data for 3D array -func update_grid_data(): - grid_data.clear() - for y in range(floors): - var floor_data = [] - for z in range(rows): - var row = [] - for x in range(columns): - row.append(get_cell_item(Vector3i(x, y, z))) - floor_data.append(row) - grid_data.append(floor_data) - emit_signal("grid_updated") - -# New function to swap items on a specific floor -func swap_items(old_item: int, new_item: int, floor_index: int = -1): - if floor_index == -1: - for y in range(floors): - swap_items_on_floor(old_item, new_item, y) - else: - swap_items_on_floor(old_item, new_item, floor_index) - - update_grid_data() - initialize_astar() - update_astar_costs() - -func swap_items_on_floor(old_item: int, new_item: int, floor_index: int): - for x in range(columns): - for z in range(rows): - var cell_pos = Vector3i(x, floor_index, z) - if get_cell_item(cell_pos) == old_item: - set_cell_item(cell_pos, new_item) - -# Modified A* pathfinding for multiple floors +# Improved A* pathfinding func initialize_astar(): astar_by_floor.clear() for y in range(floors): var astar = AStar2D.new() + + # Add all points for x in range(columns): for z in range(rows): var point_id = z * columns + x astar.add_point(point_id, Vector2(x, z)) + + # Connect points based on neighbors + for x in range(columns): + for z in range(rows): + var current_pos = Vector2i(x, z) + var current_point_id = z * columns + x - if x > 0: - astar.connect_points(point_id, point_id - 1) - if z > 0: - astar.connect_points(point_id, point_id - columns) + if not is_cell_walkable(current_pos, y): + continue - if diagonal_movement: - if x > 0 and z > 0: - astar.connect_points(point_id, point_id - columns - 1) # Top-left - if x < columns - 1 and z > 0: - astar.connect_points(point_id, point_id - columns + 1) # Top-right + var neighbors = get_neighbors(current_pos, y) + for neighbor in neighbors: + if neighbor.is_walkable: + var neighbor_id = neighbor.position.y * columns + neighbor.position.x + + if not astar.are_points_connected(current_point_id, neighbor_id): + var weight = 1.0 if not is_diagonal_direction(neighbor.direction) else 1.4142 + astar.connect_points(current_point_id, neighbor_id, true) + astar.set_point_weight_scale(neighbor_id, weight) astar_by_floor[y] = astar + update_astar_costs() -func set_diagonal_movement(enable: bool): - diagonal_movement = enable - initialize_astar() # Reinitialize the A* graph with new connections - -func set_point_solid(x: int, z: int, floor_index: int, is_solid: bool): - var astar = astar_by_floor.get(floor_index) - if astar: - var point_id = z * columns + x - astar.set_point_disabled(point_id, is_solid) - -# Modified path finding for specific floor func find_path(start: Vector2, end: Vector2, floor_index: int = 0) -> Array: var astar = astar_by_floor.get(floor_index) if not astar: @@ -350,7 +370,7 @@ func find_path(start: Vector2, end: Vector2, floor_index: int = 0) -> Array: return path -# Modified path visualization clearing for specific floor +# Path visualization func clear_path_visualization(floor_index: int = 0): for x in range(columns): for z in range(rows): @@ -358,6 +378,7 @@ func clear_path_visualization(floor_index: int = 0): if cell_item == hover_item or cell_item == start_item or cell_item == end_item: set_cell_item(Vector3i(x, floor_index, z), normal_items[0]) +# Cost calculation and updates func get_cell_cost(x: int, z: int, floor_index: int = 0) -> float: var cell_item = get_cell_item(Vector3i(x, floor_index, z)) if cell_item in non_walkable_items: @@ -368,7 +389,6 @@ func get_cell_cost(x: int, z: int, floor_index: int = 0) -> float: return 0.0 return 1.0 -# Modified update_astar_costs for multiple floors func update_astar_costs(): for floor_index in range(floors): var astar = astar_by_floor.get(floor_index) @@ -383,11 +403,42 @@ func update_astar_costs(): astar.set_point_disabled(point_id, false) astar.set_point_weight_scale(point_id, cost) +# Grid data management +func update_grid_data(): + grid_data.clear() + for y in range(floors): + var floor_data = [] + for z in range(rows): + var row = [] + for x in range(columns): + row.append(get_cell_item(Vector3i(x, y, z))) + floor_data.append(row) + grid_data.append(floor_data) + emit_signal("grid_updated") + +# Cell rotation handling func get_cell_rotation(position: Vector3i) -> int: return get_cell_item_orientation(position) func set_cell_rotation(position: Vector3i, mode: int): var item = get_cell_item(position) - if item != INVALID_CELL_ITEM: - var orientation = int(mode) - set_cell_item(position, item, orientation) + if item != -1: + set_cell_item(position, item, mode) + +# Mesh library handling +func _on_mesh_library_changed(): + validate_item_indices() + if auto_generate: + generate_grid() + +func _set(property, value): + if property == "mesh_library": + mesh_library = value + _on_mesh_library_changed() + return true + return false + +# Toggle diagonal movement +func set_diagonal_movement(enable: bool): + diagonal_movement = enable + initialize_astar() diff --git a/addons/enhanced_gridmap/meshlibrary/default.tres b/addons/enhanced_gridmap/meshlibrary/default.tres index 7bbd5b6..e0e0909 100644 --- a/addons/enhanced_gridmap/meshlibrary/default.tres +++ b/addons/enhanced_gridmap/meshlibrary/default.tres @@ -8,7 +8,7 @@ [ext_resource type="ArrayMesh" uid="uid://bgvropltcot0q" path="res://assets/models/meshes/normal.res" id="5_san4u"] [ext_resource type="ArrayMesh" uid="uid://36tgon3b60db" path="res://assets/models/tiles/tile_heart.tres" id="6_r6sve"] [ext_resource type="ArrayMesh" uid="uid://cv4bedhida00g" path="res://assets/models/tiles/tile_star.tres" id="7_v40i1"] -[ext_resource type="ArrayMesh" uid="uid://bhlvvdtiykgnn" path="res://assets/models/meshes/tiles.res" id="8_ul3lk"] +[ext_resource type="ArrayMesh" uid="uid://b5ta7tcw0iscd" path="res://assets/models/tiles/tile_coin.tres" id="9_44311"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2vf4e"] resource_name = "boost" @@ -17,7 +17,7 @@ cull_mode = 2 albedo_color = Color(0.91, 0.91, 0.91, 0.45098) albedo_texture = ExtResource("3_re0fd") -[sub_resource type="ArrayMesh" id="ArrayMesh_0evu4"] +[sub_resource type="ArrayMesh" id="ArrayMesh_ff8mg"] _surfaces = [{ "aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), "format": 34896613377, @@ -31,7 +31,7 @@ _surfaces = [{ }] blend_shape_mode = 0 -[sub_resource type="ArrayMesh" id="ArrayMesh_pte2c"] +[sub_resource type="ArrayMesh" id="ArrayMesh_64nap"] resource_name = "tile_diamond" _surfaces = [{ "aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), @@ -47,7 +47,7 @@ _surfaces = [{ "vertex_data": PackedByteArray("AAD//////78AAP//////vwAA/////6oqAAD+/wAAAAAAAP7/AAD/vwAA/v8AAKoq/////////7//////////v//////////////+/wAAAAD///7/AAD/v////v8AAP////8AAP///7///wAA////P///AAD///////8AAAAAAAD//wAAAAD/P///AAAAAP//AAAAAP///78AAAAA////PwAAAAD//6oqAAAAAAAAAAAAAAAAAAD/PwAAAAAAAKoq/////////39U1VTV/7//v////39U1VTV/////////3//v/9//7//v////3//v/9//////wAA/3//v/9//7//vwAA/3//v/9//////wAA/39U1VTV/7//vwAA/39U1VTV") }] blend_shape_mode = 0 -shadow_mesh = SubResource("ArrayMesh_0evu4") +shadow_mesh = SubResource("ArrayMesh_ff8mg") [sub_resource type="PlaneMesh" id="PlaneMesh_ti6kf"] material = ExtResource("3_qi66w") @@ -103,13 +103,13 @@ item/8/shapes = [] item/8/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/8/navigation_layers = 1 item/9/name = "tile_coin" -item/9/mesh = ExtResource("8_ul3lk") +item/9/mesh = ExtResource("9_44311") item/9/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0) item/9/shapes = [] item/9/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/9/navigation_layers = 1 item/10/name = "tile_diamond" -item/10/mesh = SubResource("ArrayMesh_pte2c") +item/10/mesh = SubResource("ArrayMesh_64nap") item/10/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0) item/10/shapes = [] item/10/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) diff --git a/assets/models/tiles/tile_coin.tres b/assets/models/tiles/tile_coin.tres new file mode 100644 index 0000000..a1c3f97 --- /dev/null +++ b/assets/models/tiles/tile_coin.tres @@ -0,0 +1,43 @@ +[gd_resource type="ArrayMesh" load_steps=4 format=4 uid="uid://b5ta7tcw0iscd"] + +[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_po712"] +load_path = "res://.godot/imported/tile_coin.png-07bdc9862d055beeb72a967a0094a5c7.s3tc.ctex" + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_7ya48"] +resource_name = "boost" +transparency = 1 +cull_mode = 2 +albedo_color = Color(0.91, 0.91, 0.91, 0.45098) +albedo_texture = SubResource("CompressedTexture2D_po712") + +[sub_resource type="ArrayMesh" id="ArrayMesh_acoqc"] +_surfaces = [{ +"aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), +"format": 34896613377, +"index_count": 36, +"index_data": PackedByteArray("BwAEAAUABwAGAAQABQACAAMABQAEAAIAAAAEAAYAAAACAAQABQABAAcABQADAAEAAgABAAMAAgAAAAEAAQAGAAcAAQAAAAYA"), +"name": "boost", +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 8, +"vertex_data": PackedByteArray("AAD/////AAAAAP7/AAAAAP///////wAA///+/wAAAAD//wAA//8AAP//AAAAAAAAAAAAAP//AAAAAAAAAAAAAA==") +}] +blend_shape_mode = 0 + +[resource] +resource_name = "tile_diamond" +_surfaces = [{ +"aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), +"attribute_data": PackedByteArray("sPss5W0hot47+9DosPv6720hXCE7+6/6sPvl75Heot6r9qfksPu0+pHeXCHM5KfkSvvl78X6sfqr9kDkSvu0+sX6tuTM5EDkSvss5c7ksfrU+tDoSvv6787ktuTU+q/6"), +"format": 34896613399, +"index_count": 36, +"index_data": PackedByteArray("FgANABAAFgATAA0AEQAIAAsAEQAOAAgAAAAMABIAAAAGAAwADwADABUADwAJAAMABwAEAAoABwABAAQABQAUABcABQACABQA"), +"material": SubResource("StandardMaterial3D_7ya48"), +"name": "tile_coin_diamond", +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 24, +"vertex_data": PackedByteArray("AAD//////78AAP//////vwAA/////6oqAAD+/wAAAAAAAP7/AAD/vwAA/v8AAKoq/////////7//////////v//////////////+/wAAAAD///7/AAD/v////v8AAP////8AAP///7///wAA////P///AAD///////8AAAAAAAD//wAAAAD/P///AAAAAP//AAAAAP///78AAAAA////PwAAAAD//6oqAAAAAAAAAAAAAAAAAAD/PwAAAAAAAKoq/////////39U1VTV/7//v////39U1VTV/////////3//v/9//7//v////3//v/9//////wAA/3//v/9//7//vwAA/3//v/9//////wAA/39U1VTV/7//vwAA/39U1VTV") +}] +blend_shape_mode = 0 +shadow_mesh = SubResource("ArrayMesh_acoqc") diff --git a/assets/models/tiles/tile_diamond.tres b/assets/models/tiles/tile_diamond.tres new file mode 100644 index 0000000..b130073 --- /dev/null +++ b/assets/models/tiles/tile_diamond.tres @@ -0,0 +1,42 @@ +[gd_resource type="ArrayMesh" load_steps=4 format=4 uid="uid://dr80txgr61irt"] + +[ext_resource type="Texture2D" uid="uid://dpkx1a780pvwv" path="res://assets/textures/tile_diamond.png" id="1_66odq"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2vf4e"] +resource_name = "boost" +transparency = 1 +cull_mode = 2 +albedo_color = Color(0.91, 0.91, 0.91, 0.45098) +albedo_texture = ExtResource("1_66odq") + +[sub_resource type="ArrayMesh" id="ArrayMesh_ff8mg"] +_surfaces = [{ +"aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), +"format": 34896613377, +"index_count": 36, +"index_data": PackedByteArray("BwAEAAUABwAGAAQABQACAAMABQAEAAIAAAAEAAYAAAACAAQABQABAAcABQADAAEAAgABAAMAAgAAAAEAAQAGAAcAAQAAAAYA"), +"name": "boost", +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 8, +"vertex_data": PackedByteArray("AAD/////AAAAAP7/AAAAAP///////wAA///+/wAAAAD//wAA//8AAP//AAAAAAAAAAAAAP//AAAAAAAAAAAAAA==") +}] +blend_shape_mode = 0 + +[resource] +resource_name = "tile_diamond" +_surfaces = [{ +"aabb": AABB(-0.282176, -0.000324821, -0.282176, 0.564351, 0.050792, 0.564351), +"attribute_data": PackedByteArray("sPss5W0hot47+9DosPv6720hXCE7+6/6sPvl75Heot6r9qfksPu0+pHeXCHM5KfkSvvl78X6sfqr9kDkSvu0+sX6tuTM5EDkSvss5c7ksfrU+tDoSvv6787ktuTU+q/6"), +"format": 34896613399, +"index_count": 36, +"index_data": PackedByteArray("FgANABAAFgATAA0AEQAIAAsAEQAOAAgAAAAMABIAAAAGAAwADwADABUADwAJAAMABwAEAAoABwABAAQABQAUABcABQACABQA"), +"material": SubResource("StandardMaterial3D_2vf4e"), +"name": "tile_coin_diamond", +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 24, +"vertex_data": PackedByteArray("AAD//////78AAP//////vwAA/////6oqAAD+/wAAAAAAAP7/AAD/vwAA/v8AAKoq/////////7//////////v//////////////+/wAAAAD///7/AAD/v////v8AAP////8AAP///7///wAA////P///AAD///////8AAAAAAAD//wAAAAD/P///AAAAAP//AAAAAP///78AAAAA////PwAAAAD//6oqAAAAAAAAAAAAAAAAAAD/PwAAAAAAAKoq/////////39U1VTV/7//v////39U1VTV/////////3//v/9//7//v////3//v/9//////wAA/3//v/9//7//vwAA/3//v/9//////wAA/39U1VTV/7//vwAA/39U1VTV") +}] +blend_shape_mode = 0 +shadow_mesh = SubResource("ArrayMesh_ff8mg") diff --git a/assets/styles/box_flat.tres b/assets/styles/box_flat.tres new file mode 100644 index 0000000..9b369ef --- /dev/null +++ b/assets/styles/box_flat.tres @@ -0,0 +1,12 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://dlw1ogamn741n"] + +[resource] +bg_color = Color(0, 0, 0, 0.784314) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 +expand_margin_left = 5.0 +expand_margin_top = 5.0 +expand_margin_right = 5.0 +expand_margin_bottom = 5.0 diff --git a/scenes/main.tscn b/scenes/main.tscn index 5ad50c7..e8ac5f0 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,9 +1,12 @@ -[gd_scene load_steps=5 format=3 uid="uid://dxn87yj8qnfpp"] +[gd_scene load_steps=7 format=3 uid="uid://dxn87yj8qnfpp"] [ext_resource type="MeshLibrary" uid="uid://54tpx8cmksfc" path="res://addons/enhanced_gridmap/meshlibrary/default.tres" id="1_110wo"] [ext_resource type="Script" path="res://scenes/main.gd" id="1_xcpe3"] [ext_resource type="Script" path="res://addons/enhanced_gridmap/enhanced_gridmap.gd" id="2_hbe1v"] [ext_resource type="Environment" uid="uid://jbptgqvstei3" path="res://assets/main-environment.tres" id="4_ky38j"] +[ext_resource type="StyleBox" uid="uid://dlw1ogamn741n" path="res://assets/styles/box_flat.tres" id="5_dvx6y"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1cewu"] [node name="Main" type="Node3D"] script = ExtResource("1_xcpe3") @@ -13,7 +16,7 @@ turn_based_mode = false mesh_library = ExtResource("1_110wo") cell_size = Vector3(1, 1, 1) data = { -"cells": PackedInt32Array(9, 0, 0, 9, 1, 0, 9, 2, 0, 9, 3, 0, 9, 4, 0, 9, 5, 0, 9, 8, 0, 9, 9, 0, 9, 7, 0, 9, 6, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 1, 0, 0, 1, 1, 0, 1, 2, 0, 1, 3, 0, 1, 4, 0, 1, 5, 0, 1, 6, 0, 1, 7, 0, 1, 8, 0, 1, 9, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0, 2, 3, 0, 2, 4, 0, 2, 5, 0, 2, 6, 0, 2, 7, 0, 2, 8, 0, 2, 9, 0, 3, 0, 0, 3, 1, 0, 3, 2, 0, 3, 3, 0, 3, 4, 0, 3, 5, 0, 3, 6, 0, 3, 7, 0, 3, 8, 0, 3, 9, 0, 4, 0, 0, 4, 1, 0, 4, 2, 0, 4, 3, 0, 4, 4, 0, 4, 5, 0, 4, 6, 0, 4, 7, 0, 4, 8, 0, 4, 9, 0, 5, 0, 0, 5, 1, 0, 5, 2, 0, 5, 3, 0, 5, 4, 0, 5, 5, 0, 5, 6, 0, 5, 7, 0, 5, 8, 0, 5, 9, 0, 6, 0, 0, 6, 1, 0, 6, 2, 0, 6, 3, 0, 6, 4, 0, 6, 5, 0, 6, 6, 0, 6, 7, 0, 6, 8, 0, 6, 9, 0, 7, 0, 0, 7, 1, 0, 7, 2, 0, 7, 3, 0, 7, 4, 0, 7, 5, 0, 7, 6, 0, 7, 7, 0, 7, 8, 0, 7, 9, 0, 8, 0, 0, 8, 1, 0, 8, 2, 0, 8, 3, 0, 8, 4, 0, 8, 5, 0, 8, 6, 0, 8, 7, 0, 8, 8, 0, 8, 9, 0, 65536, 0, 7, 65536, 1, 7, 65536, 2, 7, 65536, 3, 7, 65536, 4, 8, 65536, 5, 7, 65536, 6, 7, 65536, 7, 7, 65536, 8, 7, 65536, 9, 7, 65537, 0, 7, 65537, 1, 7, 65537, 2, 8, 65537, 3, 8, 65537, 4, 7, 65537, 5, 7, 65537, 6, 7, 65537, 7, 8, 65537, 8, 8, 65537, 9, 7, 65538, 0, 8, 65538, 1, 7, 65538, 2, 8, 65538, 3, 8, 65538, 4, 9, 65538, 5, 7, 65538, 6, 8, 65538, 7, 7, 65538, 8, 9, 65538, 9, 8, 65539, 0, 9, 65539, 1, 7, 65539, 2, 7, 65539, 3, 7, 65539, 4, 8, 65539, 5, 7, 65539, 6, 9, 65539, 7, 7, 65539, 8, 9, 65539, 9, 9, 65540, 0, 7, 65540, 1, 9, 65540, 2, 8, 65540, 3, 7, 65540, 4, 7, 65540, 5, 7, 65540, 6, 7, 65540, 7, 8, 65540, 8, 9, 65540, 9, 7, 65541, 0, 8, 65541, 1, 9, 65541, 2, 8, 65541, 3, 7, 65541, 4, 7, 65541, 5, 9, 65541, 6, 8, 65541, 7, 7, 65541, 8, 9, 65541, 9, 7, 65542, 0, 7, 65542, 1, 7, 65542, 2, 7, 65542, 3, 9, 65542, 4, 8, 65542, 5, 8, 65542, 6, 7, 65542, 7, 8, 65542, 8, 7, 65542, 9, 7, 65543, 0, 8, 65543, 1, 9, 65543, 2, 7, 65543, 3, 9, 65543, 4, 7, 65543, 5, 7, 65543, 6, 7, 65543, 7, 8, 65543, 8, 7, 65543, 9, 8, 65544, 0, 8, 65544, 1, 7, 65544, 2, 9, 65544, 3, 8, 65544, 4, 7, 65544, 5, 9, 65544, 6, 9, 65544, 7, 9, 65544, 8, 7, 65544, 9, 9, 65545, 0, 8, 65545, 1, 8, 65545, 2, 8, 65545, 3, 8, 65545, 4, 9, 65545, 5, 7, 65545, 6, 8, 65545, 7, 8, 65545, 8, 7, 65545, 9, 7) +"cells": PackedInt32Array(9, 0, 0, 9, 1, 0, 9, 2, 0, 9, 3, 0, 9, 4, 0, 9, 5, 0, 9, 8, 0, 9, 9, 0, 9, 7, 0, 9, 6, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 1, 0, 0, 1, 1, 0, 1, 2, 0, 1, 3, 0, 1, 4, 0, 1, 5, 0, 1, 6, 0, 1, 7, 0, 1, 8, 0, 1, 9, 0, 2, 0, 0, 2, 1, 0, 2, 2, 0, 2, 3, 0, 2, 4, 0, 2, 5, 0, 2, 6, 0, 2, 7, 0, 2, 8, 0, 2, 9, 0, 3, 0, 0, 3, 1, 0, 3, 2, 0, 3, 3, 0, 3, 4, 0, 3, 5, 0, 3, 6, 0, 3, 7, 0, 3, 8, 0, 3, 9, 0, 4, 0, 0, 4, 1, 0, 4, 2, 0, 4, 3, 0, 4, 4, 0, 4, 5, 0, 4, 6, 0, 4, 7, 0, 4, 8, 0, 4, 9, 0, 5, 0, 0, 5, 1, 0, 5, 2, 0, 5, 3, 0, 5, 4, 0, 5, 5, 0, 5, 6, 0, 5, 7, 0, 5, 8, 0, 5, 9, 0, 6, 0, 0, 6, 1, 0, 6, 2, 0, 6, 3, 0, 6, 4, 0, 6, 5, 0, 6, 6, 0, 6, 7, 0, 6, 8, 0, 6, 9, 0, 7, 0, 0, 7, 1, 0, 7, 2, 0, 7, 3, 0, 7, 4, 0, 7, 5, 0, 7, 6, 0, 7, 7, 0, 7, 8, 0, 7, 9, 0, 8, 0, 0, 8, 1, 0, 8, 2, 0, 8, 3, 0, 8, 4, 0, 8, 5, 0, 8, 6, 0, 8, 7, 0, 8, 8, 0, 8, 9, 0, 65536, 0, 7, 65536, 1, 10, 65536, 2, 9, 65536, 3, 9, 65536, 4, 8, 65536, 5, 7, 65536, 6, 9, 65536, 7, 9, 65536, 8, 10, 65536, 9, 8, 65537, 0, 9, 65537, 1, 8, 65537, 2, 10, 65537, 3, 9, 65537, 4, 7, 65537, 5, 10, 65537, 6, 9, 65537, 7, 9, 65537, 8, 10, 65537, 9, 10, 65538, 0, 7, 65538, 1, 10, 65538, 2, 9, 65538, 3, 8, 65538, 4, 9, 65538, 5, 10, 65538, 6, 9, 65538, 7, 8, 65538, 8, 9, 65538, 9, 10, 65539, 0, 9, 65539, 1, 10, 65539, 2, 9, 65539, 3, 10, 65539, 4, 9, 65539, 5, 9, 65539, 6, 10, 65539, 7, 10, 65539, 8, 9, 65539, 9, 9, 65540, 0, 7, 65540, 1, 7, 65540, 2, 7, 65540, 3, 10, 65540, 4, 9, 65540, 5, 7, 65540, 6, 9, 65540, 7, 9, 65540, 8, 7, 65540, 9, 8, 65541, 0, 8, 65541, 1, 7, 65541, 2, 7, 65541, 3, 10, 65541, 4, 10, 65541, 5, 8, 65541, 6, 7, 65541, 7, 7, 65541, 8, 8, 65541, 9, 9, 65542, 0, 10, 65542, 1, 10, 65542, 2, 9, 65542, 3, 7, 65542, 4, 8, 65542, 5, 9, 65542, 6, 10, 65542, 7, 9, 65542, 8, 10, 65542, 9, 9, 65543, 0, 7, 65543, 1, 8, 65543, 2, 10, 65543, 3, 8, 65543, 4, 7, 65543, 5, 10, 65543, 6, 10, 65543, 7, 7, 65543, 8, 10, 65543, 9, 8, 65544, 0, 9, 65544, 1, 9, 65544, 2, 8, 65544, 3, 8, 65544, 4, 8, 65544, 5, 7, 65544, 6, 8, 65544, 7, 9, 65544, 8, 10, 65544, 9, 10, 65545, 0, 10, 65545, 1, 8, 65545, 2, 10, 65545, 3, 8, 65545, 4, 8, 65545, 5, 7, 65545, 6, 9, 65545, 7, 9, 65545, 8, 9, 65545, 9, 9) } script = ExtResource("2_hbe1v") floors = 2 @@ -40,6 +43,7 @@ offset_top = 6.0 offset_right = 77.0 offset_bottom = 59.0 grow_horizontal = 2 +theme_override_styles/panel = ExtResource("5_dvx6y") [node name="NetworkInfo" type="VBoxContainer" parent="."] anchors_preset = 5 @@ -74,13 +78,36 @@ offset_right = 85.0 offset_bottom = 33.0 grow_horizontal = 2 grow_vertical = 2 +theme_override_constants/separation = 20 [node name="Host" type="Button" parent="Menu"] layout_mode = 2 +theme_override_styles/focus = ExtResource("5_dvx6y") +theme_override_styles/disabled_mirrored = ExtResource("5_dvx6y") +theme_override_styles/disabled = ExtResource("5_dvx6y") +theme_override_styles/hover_pressed_mirrored = ExtResource("5_dvx6y") +theme_override_styles/hover_pressed = ExtResource("5_dvx6y") +theme_override_styles/hover_mirrored = ExtResource("5_dvx6y") +theme_override_styles/hover = ExtResource("5_dvx6y") +theme_override_styles/pressed_mirrored = ExtResource("5_dvx6y") +theme_override_styles/pressed = ExtResource("5_dvx6y") +theme_override_styles/normal_mirrored = ExtResource("5_dvx6y") +theme_override_styles/normal = ExtResource("5_dvx6y") text = "Host" [node name="Join" type="Button" parent="Menu"] layout_mode = 2 +theme_override_styles/focus = ExtResource("5_dvx6y") +theme_override_styles/disabled_mirrored = ExtResource("5_dvx6y") +theme_override_styles/disabled = ExtResource("5_dvx6y") +theme_override_styles/hover_pressed_mirrored = ExtResource("5_dvx6y") +theme_override_styles/hover_pressed = ExtResource("5_dvx6y") +theme_override_styles/hover_mirrored = ExtResource("5_dvx6y") +theme_override_styles/hover = ExtResource("5_dvx6y") +theme_override_styles/pressed_mirrored = ExtResource("5_dvx6y") +theme_override_styles/pressed = ExtResource("5_dvx6y") +theme_override_styles/normal_mirrored = ExtResource("5_dvx6y") +theme_override_styles/normal = ExtResource("5_dvx6y") text = "Join" [node name="MessageInput" type="LineEdit" parent="."] @@ -95,6 +122,8 @@ offset_right = 210.0 offset_bottom = -15.0 grow_horizontal = 2 grow_vertical = 0 +theme_override_styles/focus = SubResource("StyleBoxFlat_1cewu") +theme_override_styles/normal = ExtResource("5_dvx6y") placeholder_text = "Chat" alignment = 1 diff --git a/scenes/player.tscn b/scenes/player.tscn index e2ad91b..2ff53e9 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -65,20 +65,21 @@ uppercase = true autowrap_mode = 2 [node name="Bubble" type="Sprite3D" parent="."] -transform = Transform3D(0.625, 0, 0, 0, 0.625, 0, 0, 0, 0.625, 0, 2.63593, 0) +transform = Transform3D(0.625, 0, 0, 0, 0.5, 0, 0, 0, 0.625, 0, 2.63593, 0) visible = false +modulate = Color(0, 0, 0, 1) billboard = 1 texture = ExtResource("2_5w327") [node name="Message" type="Label3D" parent="Bubble"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00144005, 0) +transform = Transform3D(1, 0, 0, 0, 1.25, 0, 0, 0, 1, 0, 0.00180054, 0) billboard = 1 double_sided = false no_depth_test = true render_priority = 1 text = ". . . ." font = SubResource("FontVariation_q2tkp") -font_size = 48 +font_size = 64 outline_size = 24 uppercase = true autowrap_mode = 3