Quest events
This commit is contained in:
28
scripts/Event/Trigger/EventQuestAllObjectivesComplete.gd
Normal file
28
scripts/Event/Trigger/EventQuestAllObjectivesComplete.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name EventQuestAllObjectivesComplete extends "res://scripts/Event/Flow/EventGroup.gd"
|
||||
|
||||
@export var questKey:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST
|
||||
@export var triggerMultipleTimes: bool = false
|
||||
|
||||
func _enter_tree() -> void:
|
||||
QUEST.questUpdated.connect(onQuestUpdated)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
QUEST.questUpdated.disconnect(onQuestUpdated)
|
||||
|
||||
func onQuestUpdated(quest:Quest) -> void:
|
||||
if self.ended:
|
||||
if !self.triggerMultipleTimes:
|
||||
return
|
||||
self.reset()
|
||||
|
||||
if quest.questKey != self.questKey:
|
||||
return
|
||||
|
||||
if !quest.isStarted():
|
||||
return
|
||||
|
||||
for objective in quest.objectives:
|
||||
if !objective.isCompleted():
|
||||
return
|
||||
|
||||
self.start()
|
@@ -0,0 +1 @@
|
||||
uid://ck0vs0awnc4n2
|
@@ -4,15 +4,11 @@ class_name EventQuestObjectiveComplete extends "res://scripts/Event/Flow/EventGr
|
||||
@export var quest:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST
|
||||
@export var objectiveIndex:int = 0
|
||||
|
||||
var hasTriggered:bool = false
|
||||
|
||||
func _enter_tree() -> void:
|
||||
QUEST.questUpdated.connect(onQuestUpdated)
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
QUEST.questUpdated.disconnect(onQuestUpdated)
|
||||
pass
|
||||
|
||||
func onQuestUpdated(quest:Quest) -> void:
|
||||
if self.ended:
|
||||
@@ -25,7 +21,4 @@ func onQuestUpdated(quest:Quest) -> void:
|
||||
|
||||
if !quest.objectives[objectiveIndex].isCompleted():
|
||||
return
|
||||
|
||||
print("onObjectiveCompleted: %s" % quest.questKey)
|
||||
self.start()
|
||||
pass
|
||||
self.start()
|
Reference in New Issue
Block a user