|
|
|
|
@ -31,6 +31,9 @@ var invalid_placement_material: StandardMaterial3D
|
|
|
|
|
# Central structure management
|
|
|
|
|
var _structures: Array[Structure] = []
|
|
|
|
|
|
|
|
|
|
# Variable to track selection state
|
|
|
|
|
var selectionEnabled: bool = false;
|
|
|
|
|
|
|
|
|
|
# Getter for structures that ensures deduplication
|
|
|
|
|
func get_structures() -> Array[Structure]:
|
|
|
|
|
return _structures
|
|
|
|
|
@ -145,14 +148,6 @@ func _ready():
|
|
|
|
|
|
|
|
|
|
update_cash()
|
|
|
|
|
|
|
|
|
|
# Override the setter for structures to ensure deduplication
|
|
|
|
|
func _set_structures(new_structures: Array[Structure]) -> void:
|
|
|
|
|
structures = new_structures
|
|
|
|
|
_deduplicate_structures()
|
|
|
|
|
# Update construction manager with deduplicated structures
|
|
|
|
|
if construction_manager:
|
|
|
|
|
construction_manager.structures = structures
|
|
|
|
|
|
|
|
|
|
# Function to add a structure to the array
|
|
|
|
|
func add_structure(structure: Structure) -> void:
|
|
|
|
|
structures.append(structure)
|
|
|
|
|
@ -178,7 +173,7 @@ func _process(delta):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Make sure selector is visible
|
|
|
|
|
if !selector.visible:
|
|
|
|
|
if !selector.visible and selectionEnabled:
|
|
|
|
|
selector.visible = true
|
|
|
|
|
|
|
|
|
|
# Controls
|
|
|
|
|
@ -344,6 +339,10 @@ func find_mesh_instance(node):
|
|
|
|
|
|
|
|
|
|
func action_build(gridmap_position, can_place: bool):
|
|
|
|
|
if Input.is_action_just_pressed("build"):
|
|
|
|
|
#Check if selection is on
|
|
|
|
|
if(not selectionEnabled):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Check if the mouse is over any UI elements before building
|
|
|
|
|
if is_mouse_over_ui():
|
|
|
|
|
return
|
|
|
|
|
@ -561,7 +560,7 @@ func remove_navigation_region(position: Vector3):
|
|
|
|
|
# Rotates the 'cursor' 90 degrees
|
|
|
|
|
|
|
|
|
|
func action_rotate():
|
|
|
|
|
if Input.is_action_just_pressed("rotate"):
|
|
|
|
|
if Input.is_action_just_pressed("rotate") and selectionEnabled:
|
|
|
|
|
selector.rotate_y(deg_to_rad(90))
|
|
|
|
|
|
|
|
|
|
# Toggle between structures to build
|
|
|
|
|
@ -572,6 +571,7 @@ func action_structure_toggle(structure:Structure):
|
|
|
|
|
print("No structure found!")
|
|
|
|
|
else:
|
|
|
|
|
index = found_index
|
|
|
|
|
selectionEnabled = true
|
|
|
|
|
update_structure()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1196,7 +1196,7 @@ func _on_structures_unlocked():
|
|
|
|
|
selector.visible = false
|
|
|
|
|
else:
|
|
|
|
|
# Show the selector since we have a structure to place
|
|
|
|
|
if selector:
|
|
|
|
|
if selector and selectionEnabled:
|
|
|
|
|
selector.visible = true
|
|
|
|
|
|
|
|
|
|
update_structure()
|
|
|
|
|
|