Track priority of quest objectives (i.e. "find disk 2" has higher priority than "install disk 4")
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
1 parent
6452b486fc
commit
0f998f94b6
4 files changed
+20
-8
No files matched your search
@@ -7,5 +7,5 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _on_picked_up() -> void:
|
func _on_picked_up() -> void:
|
||||||
%Player2D.give_disk(disk_num)
|
%Player2D.give_disk(disk_num)
|
||||||
%Player2D.give_objective("disk%d" % disk_num, "Install data disk %d" % disk_num)
|
%Player2D.give_objective("disk%d" % disk_num, disk_num, "Install data disk %d" % disk_num)
|
||||||
print("Picked up disk ", disk_num)
|
print("Picked up disk ", disk_num)
|
||||||
+2
-2
@@ -3,6 +3,6 @@ extends RichTextLabel
|
|||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var new_text = "OBJECTIVES:\n"
|
var new_text = "OBJECTIVES:\n"
|
||||||
for objective in %Player2D.objectives:
|
for objective in %Player2D.get_current_objectives():
|
||||||
new_text = new_text + %Player2D.objectives[objective] + "\n"
|
new_text = new_text + objective + "\n"
|
||||||
text = new_text
|
text = new_text
|
||||||
+1
-1
@@ -36,4 +36,4 @@ func _on_interacted() -> void:
|
|||||||
if (not wanted_disk) or %Player2D.has_disk(wanted_disk):
|
if (not wanted_disk) or %Player2D.has_disk(wanted_disk):
|
||||||
return
|
return
|
||||||
|
|
||||||
%Player2D.give_objective("disk%d" % wanted_disk, "Locate data disk %d" % wanted_disk)
|
%Player2D.give_objective("disk%d" % wanted_disk, wanted_disk, "Locate data disk %d" % wanted_disk)
|
||||||
+16
-4
@@ -52,14 +52,26 @@ func take_disk(disk_num) -> bool:
|
|||||||
func has_disk(disk_num: int) -> bool:
|
func has_disk(disk_num: int) -> bool:
|
||||||
return disk_num in data_disks
|
return disk_num in data_disks
|
||||||
|
|
||||||
func give_objective(id: String, description: String) -> void:
|
func give_objective(id: String, priority: int, description: String) -> void:
|
||||||
objectives[id] = description
|
objectives[id] = {
|
||||||
|
"priority": priority,
|
||||||
|
"description": description,
|
||||||
|
"completed": false
|
||||||
|
}
|
||||||
|
|
||||||
func has_objective(id: String) -> bool:
|
func has_objective(id: String) -> bool:
|
||||||
return objectives.has(id)
|
return objectives.has(id) and not objectives[id].completed
|
||||||
|
|
||||||
|
func get_current_objectives() -> Array[String]:
|
||||||
|
var current_objectives = objectives.values()
|
||||||
|
current_objectives.sort_custom(func(a, b): return a.priority < b.priority)
|
||||||
|
return current_objectives.filter(func(objective): return not objective.completed).map(func(objective): return objective.description)
|
||||||
|
|
||||||
func complete_objective(id: String) -> bool:
|
func complete_objective(id: String) -> bool:
|
||||||
return objectives.erase(id)
|
if not has_objective(id):
|
||||||
|
return false
|
||||||
|
objectives[id].completed = true
|
||||||
|
return true
|
||||||
|
|
||||||
func on_teleport():
|
func on_teleport():
|
||||||
refresh_jump(1)
|
refresh_jump(1)
|
||||||
|
|||||||
Reference in new issue
Block a user