Cleanup goal unlocks behaviour
This commit is contained in:
@@ -1104,29 +1104,21 @@ func _try_complete_goal(goal_id: StringName) -> void:
|
||||
if _goal_completed[goal_id]:
|
||||
return
|
||||
if goal.is_met():
|
||||
if _is_goal_manual_unlock(goal_id):
|
||||
if goal.unlock_behavior == GoalData.UnlockBehavior.MANUAL:
|
||||
return
|
||||
_goal_completed[goal_id] = true
|
||||
goal_completed.emit(goal_id)
|
||||
|
||||
func _is_goal_manual_unlock(goal_id: StringName) -> bool:
|
||||
func _complete_goal_manually(goal_id: StringName) -> void:
|
||||
var goal: GoalData = _goal_definitions.get(goal_id, null)
|
||||
if goal == null or not goal.has_id():
|
||||
return false
|
||||
|
||||
var scene_root: Node = get_tree().current_scene
|
||||
if scene_root == null:
|
||||
return false
|
||||
|
||||
var gen_nodes: Array[Node] = scene_root.find_children("*", "CurrencyGenerator", true, false)
|
||||
for node in gen_nodes:
|
||||
if node.has_method("get_generator_id") and node.has_method("data"):
|
||||
var data: Variant = node.get("data")
|
||||
if data != null and data.has_method("has_unlock_goal") and data.has_method("unlocks_automatically_from_goal"):
|
||||
if data.has_unlock_goal() and data.get_unlock_goal_id() == goal_id:
|
||||
return not data.unlocks_automatically_from_goal()
|
||||
|
||||
return false
|
||||
if goal == null:
|
||||
return
|
||||
if _goal_completed[goal_id]:
|
||||
return
|
||||
if not goal.is_met():
|
||||
return
|
||||
_goal_completed[goal_id] = true
|
||||
goal_completed.emit(goal_id)
|
||||
|
||||
func _serialize_goals() -> Dictionary:
|
||||
var result: Dictionary = {}
|
||||
|
||||
Reference in New Issue
Block a user