Refactor code structure for improved readability and maintainability
This commit is contained in:
+11
-3
@@ -70,7 +70,7 @@ var g_active_items: Dictionary = {}
|
||||
|
||||
var owniverse:Owniverse = Owniverse.new()
|
||||
var owniverse_items: Dictionary[String, OwniverseItem] = {}
|
||||
var locked_items:Dictionary = {}
|
||||
#var locked_items:Dictionary = {}
|
||||
|
||||
var item_list_to_update: Dictionary = {}
|
||||
|
||||
@@ -161,8 +161,8 @@ func _init_owniverse_items() -> bool:
|
||||
item.init_button(item_props)
|
||||
item.item_activated.connect(item_activated)
|
||||
|
||||
if owniverse.entities.has(item_id):
|
||||
item.visible = owniverse.entities[item_id].is_unlocked
|
||||
#if owniverse.entities.has(item_id):
|
||||
#item.visible = owniverse.entities[item_id].is_unlocked
|
||||
|
||||
owniverse_items[item_id] = item
|
||||
|
||||
@@ -176,6 +176,11 @@ func item_activated(item: OwniverseItem) -> void:
|
||||
print(item.item_id)
|
||||
if item.item_id == "S" or item.item_id == "H":
|
||||
owniverse.produce(item.item_id, 1)
|
||||
|
||||
func _unlock_item(item_id: String):
|
||||
owniverse_items[item_id].visible = true
|
||||
print("Unlocked ", item_id)
|
||||
pass
|
||||
|
||||
|
||||
func _check_counters(delta: float) -> Array:
|
||||
@@ -235,11 +240,14 @@ func _ready() -> void:
|
||||
owniverse.init_enitities()
|
||||
_init_owniverse_items()
|
||||
|
||||
owniverse.unlock_item.connect(_unlock_item)
|
||||
g_counters.swipe.sec = 0.2
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# Update date
|
||||
owniverse.cycle(delta)
|
||||
|
||||
var sdt: String = str(snapped(owniverse.add_time_delta(delta), 0.1))
|
||||
set_datetime(sdt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user