Update
This commit is contained in:
@@ -32,6 +32,7 @@ enum Direction {
|
||||
|
||||
var diagonal_movement: bool = false
|
||||
|
||||
|
||||
class NeighborInfo:
|
||||
var position: Vector2i
|
||||
var direction: Direction
|
||||
@@ -430,6 +431,22 @@ func _on_mesh_library_changed():
|
||||
validate_item_indices()
|
||||
if auto_generate:
|
||||
generate_grid()
|
||||
_update_cell_option_buttons()
|
||||
|
||||
func _update_cell_option_buttons():
|
||||
if not mesh_library:
|
||||
return
|
||||
|
||||
var item_list = mesh_library.get_item_list()
|
||||
|
||||
for x in range(columns):
|
||||
for z in range(rows):
|
||||
var position = Vector3i(x, 0, z)
|
||||
var cell_item = get_cell_item(position)
|
||||
if cell_item != -1 and cell_item < item_list.size():
|
||||
set_cell_item(position, cell_item)
|
||||
else:
|
||||
set_cell_item(position, 0)
|
||||
|
||||
func _set(property, value):
|
||||
if property == "mesh_library":
|
||||
|
||||
@@ -152,6 +152,7 @@ func set_enhanced_gridmap(gridmap: EnhancedGridMap):
|
||||
if enhanced_gridmap:
|
||||
if enhanced_gridmap.grid_updated.is_connected(_on_grid_updated):
|
||||
enhanced_gridmap.grid_updated.disconnect(_on_grid_updated)
|
||||
|
||||
|
||||
enhanced_gridmap = gridmap
|
||||
if enhanced_gridmap:
|
||||
@@ -193,7 +194,7 @@ func _update_grid_ui():
|
||||
|
||||
var item_list = enhanced_gridmap.mesh_library.get_item_list()
|
||||
var current_floor = floor_spin.value as int
|
||||
|
||||
|
||||
for z in range(enhanced_gridmap.rows):
|
||||
var row_container = HBoxContainer.new()
|
||||
row_container.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
@@ -204,7 +205,7 @@ func _update_grid_ui():
|
||||
var cell_container = VBoxContainer.new()
|
||||
cell_container.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
cell_container.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
|
||||
|
||||
var coord_label = Label.new()
|
||||
coord_label.text = "(%d,%d,%d)" % [x, current_floor, z]
|
||||
coord_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
@@ -216,9 +217,14 @@ func _update_grid_ui():
|
||||
option.set_meta("grid_position", Vector3i(x, current_floor, z))
|
||||
for i in range(item_list.size()):
|
||||
option.add_item(enhanced_gridmap.mesh_library.get_item_name(item_list[i]), i)
|
||||
|
||||
# Ensure the selected item in the OptionButton corresponds to the current cell item
|
||||
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(x, current_floor, z))
|
||||
if cell_item != -1: # Changed from INVALID_CELL_ITEM to -1
|
||||
if cell_item != -1 and cell_item < option.get_item_count():
|
||||
option.select(cell_item)
|
||||
else:
|
||||
option.select(0)# Select the first item if the cell is empty
|
||||
|
||||
option.item_selected.connect(_on_cell_item_selected.bind(option))
|
||||
option.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
option.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
@@ -239,10 +245,11 @@ func _update_grid_ui():
|
||||
16: rotation_option.select(2)
|
||||
22: rotation_option.select(3)
|
||||
rotation_option.item_selected.connect(_on_cell_rotation_changed.bind(rotation_option))
|
||||
|
||||
|
||||
cell_container.add_child(rotation_option)
|
||||
row_container.add_child(cell_container)
|
||||
cell_options.append(option)
|
||||
enhanced_gridmap._update_cell_option_buttons()
|
||||
|
||||
func _update_astar_ui():
|
||||
start_x_spin.max_value = enhanced_gridmap.columns - 1
|
||||
@@ -273,6 +280,9 @@ func _on_floors_count_changed(value):
|
||||
func _on_floor_changed(value):
|
||||
if enhanced_gridmap:
|
||||
_update_grid_ui()
|
||||
_update_astar_ui()
|
||||
_update_item_state_ui()
|
||||
enhanced_gridmap.update_grid_data()
|
||||
|
||||
func _on_auto_generate_toggled(button_pressed):
|
||||
if enhanced_gridmap:
|
||||
@@ -321,7 +331,8 @@ func _on_fill_pressed():
|
||||
func _on_cell_item_selected(index: int, option: OptionButton):
|
||||
var position = option.get_meta("grid_position")
|
||||
if enhanced_gridmap:
|
||||
enhanced_gridmap.set_cell_item(position, index)
|
||||
if index >= 0 and index < enhanced_gridmap.mesh_library.get_item_list().size():
|
||||
enhanced_gridmap.set_cell_item(position, index)
|
||||
|
||||
func _on_find_path_pressed():
|
||||
if enhanced_gridmap:
|
||||
@@ -360,12 +371,14 @@ func _on_non_walkable_item_changed(value):
|
||||
|
||||
func _on_grid_updated():
|
||||
update_ui()
|
||||
enhanced_gridmap._update_cell_option_buttons()
|
||||
|
||||
func _on_cell_rotation_changed(index: int, option: OptionButton):
|
||||
var position = option.get_meta("grid_position")
|
||||
var rotation_value = option.get_item_id(index)
|
||||
if enhanced_gridmap:
|
||||
enhanced_gridmap.set_cell_rotation(position, rotation_value)
|
||||
if index >= 0 and index < 4:
|
||||
enhanced_gridmap.set_cell_rotation(position, rotation_value)
|
||||
|
||||
func _on_swap_items_pressed():
|
||||
if enhanced_gridmap:
|
||||
|
||||
@@ -1,14 +1,53 @@
|
||||
[gd_resource type="MeshLibrary" load_steps=14 format=4 uid="uid://54tpx8cmksfc"]
|
||||
[gd_resource type="MeshLibrary" load_steps=17 format=4 uid="uid://54tpx8cmksfc"]
|
||||
|
||||
[ext_resource type="ArrayMesh" uid="uid://dqguomxd16u0i" path="res://assets/models/meshes/start.res" id="1_xdwel"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dspusnbkr74hg" path="res://assets/models/meshes/hover.res" id="2_5gp4i"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dr80txgr61irt" path="res://assets/models/tiles/tile_diamond.tres" id="3_gqbid"]
|
||||
[ext_resource type="Material" uid="uid://bsyh0x4cy5qyr" path="res://assets/models/meshes/end.tres" id="3_qi66w"]
|
||||
[ext_resource type="Texture2D" uid="uid://dpkx1a780pvwv" path="res://assets/textures/tile_diamond.png" id="3_xej11"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://d4himvyb81in8" path="res://assets/models/meshes/non-walkable.res" id="4_h83ju"]
|
||||
[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://b5ta7tcw0iscd" path="res://assets/models/tiles/tile_coin.tres" id="9_44311"]
|
||||
|
||||
[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("3_xej11")
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_0hihf"]
|
||||
_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
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_3eode"]
|
||||
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_0hihf")
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_ti6kf"]
|
||||
material = ExtResource("3_qi66w")
|
||||
size = Vector2(1, 1)
|
||||
@@ -111,7 +150,7 @@ 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 = ExtResource("3_gqbid")
|
||||
item/10/mesh = SubResource("ArrayMesh_3eode")
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user