Created Global function to unlock structures and then setup listener on the sticky menu (pop-up-menu-generator.gd) so that it can regenerate the menu with the unlocks.

pull/18/head
Wade 2025-05-08 12:48:37 +07:00
parent b9516eb80f
commit 6b10f662c2
6 changed files with 15 additions and 1 deletions

@ -3,6 +3,7 @@ extends Node
signal population_update(count:int)
signal receive_data_from_browser(args)
signal set_structure(structure:Structure)
signal structure_unlocked(structure:Structure)
var current_scene = null

@ -26,4 +26,8 @@ func set_structure(structure:Structure) -> void:
# Emit the signal to notify other nodes
EventBus.set_structure.emit(structure)
# Used when a new structure is unlocked
func structure_unlocked(structure:Structure) ->void:
EventBus.structure_unlocked.emit(structure)

@ -9,7 +9,7 @@ script = ExtResource("1_objective")
type = 0
target_count = 3
current_count = 0
description = "Build 3 Type A houses to unlock all building types"
description = "Build 3 Fountains to unlock all homes!"
completed = false
structure = ExtResource("2_hfe31")

@ -15,7 +15,10 @@ func _ready():
# Add to group for easy refreshing of all structure menus
add_to_group("structure_menus")
EventBus.structure_unlocked.connect(_on_structure_unlock)
# Load icons (you'll need to create or find these icons)
_lock_icon = load("res://sprites/sticky_builder_icons/lock.png") if ResourceLoader.exists("res://sprites/sticky_builder_icons/lock.png") else null
if(_lock_icon):
@ -178,3 +181,6 @@ func _unhandled_input(event: InputEvent) -> void:
get_viewport().set_input_as_handled()
if event is InputEventMouseButton:
event.pressed = false
func _on_structure_unlock(structure:Structure)->void:
refresh()

@ -93,6 +93,8 @@ func _unlock_starting_structures(structure_paths: Array) -> void:
if structure_path == possible_path:
structure.unlocked = true
found_match = true
# Let the rest of the game know a structure has been unlocked
Globals.structure_unlocked(structure)
break
if found_match:

@ -864,6 +864,7 @@ func _handle_structure_unlocking(mission):
if "unlocked" in structure:
structure.unlocked = true
unlocked_structures.append(structure)
Globals.structure_unlocked(structure)
found = true
if not found:
print("[Unlock] No match found for item_path: ", item_path)