35 lines
672 B
GDScript
35 lines
672 B
GDScript
class_name GoalData
|
|
extends Resource
|
|
|
|
enum UnlockBehavior {
|
|
AUTOMATIC,
|
|
MANUAL,
|
|
}
|
|
|
|
@export var id: StringName = &""
|
|
@export var requirements: Array[GoalRequirementData] = []
|
|
@export var unlock_behavior: UnlockBehavior = UnlockBehavior.MANUAL
|
|
|
|
func has_id() -> bool:
|
|
return not String(id).strip_edges().is_empty()
|
|
|
|
func get_requirements() -> Array[GoalRequirementData]:
|
|
return requirements.duplicate()
|
|
|
|
func is_valid() -> bool:
|
|
if not has_id():
|
|
return false
|
|
|
|
if requirements.is_empty():
|
|
return false
|
|
|
|
for req in requirements:
|
|
if req == null:
|
|
continue
|
|
if req.get_currency() == null:
|
|
continue
|
|
if not req.has_valid_amount():
|
|
continue
|
|
|
|
return true
|