Add docs
This commit is contained in:
@@ -96,12 +96,15 @@ func _ready() -> void:
|
||||
assert(data != null, "Data cannot be null")
|
||||
|
||||
_generator_id = _resolve_generator_id()
|
||||
#_ensure_registered()
|
||||
cycle_progress_seconds = 0.0
|
||||
|
||||
GameState.currency_changed.connect(_on_currency_changed)
|
||||
GameState.generator_state_changed.connect(_on_generated_state_changed)
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
|
||||
# Register with default state first, then evaluate unlock goal
|
||||
_ensure_registered()
|
||||
if data != null and data.unlocks_automatically_from_goal():
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
|
||||
## Updates click cooldown/click grants and runs automatic production cycles.
|
||||
func _process(delta: float) -> void:
|
||||
@@ -319,7 +322,8 @@ func reset_runtime_state_for_prestige() -> void:
|
||||
cycle_progress_seconds = 0.0
|
||||
_remaining_click_cooldown_seconds = 0.0
|
||||
_ensure_registered()
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
if data != null and data.unlocks_automatically_from_goal():
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
#_evaluate_buff_unlock_goals()
|
||||
visible = is_available_to_player()
|
||||
|
||||
@@ -579,7 +583,8 @@ func _try_unlock_buff_from_goal(buff: GeneratorBuffData) -> void:
|
||||
|
||||
func _on_currency_changed(_changed_currency_id: StringName, _new_amount: BigNumber) -> void:
|
||||
GameState.evaluate_all_goals()
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
if data != null and data.unlocks_automatically_from_goal():
|
||||
_evaluate_generator_unlock_goal(false)
|
||||
|
||||
func try_unlock_from_goal() -> bool:
|
||||
return _evaluate_generator_unlock_goal(true)
|
||||
@@ -595,12 +600,17 @@ func _evaluate_generator_unlock_goal(allow_manual_unlock: bool) -> bool:
|
||||
return false
|
||||
|
||||
var goal_id: StringName = data.get_unlock_goal_id()
|
||||
if goal_id.is_empty() or not GameState.is_goal_completed(goal_id):
|
||||
if goal_id.is_empty():
|
||||
return false
|
||||
|
||||
var goal_completed: bool = GameState.is_goal_completed(goal_id)
|
||||
if not goal_completed:
|
||||
return false
|
||||
|
||||
GameState.set_generator_unlocked(_generator_id, true)
|
||||
GameState.set_generator_available(_generator_id, true)
|
||||
goal_achieved.emit(_generator_id, goal_id)
|
||||
_on_generated_state_changed(_generator_id, GameState._get_generator_state(_generator_id))
|
||||
return true
|
||||
|
||||
## Default unlocked state loaded from generator data.
|
||||
@@ -634,3 +644,5 @@ func _on_area_2d_mouse_exited() -> void:
|
||||
func _on_generated_state_changed(generator_id: StringName, _state: Dictionary) -> void:
|
||||
if generator_id == _generator_id:
|
||||
visible = is_available_to_player()
|
||||
if info_generator_container != null:
|
||||
info_generator_container._refresh_generator_ui()
|
||||
|
||||
Reference in New Issue
Block a user