Event Trigger Update
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
class_name EventIf extends "res://scripts/Event/Flow/EventGroup.gd"
|
||||
|
||||
signal eventConditionMet
|
||||
|
||||
func ifCondition() -> bool:
|
||||
return false
|
||||
|
||||
func subscribeEvents() -> void:
|
||||
# Override this method to subscribe to any events needed for the condition check
|
||||
pass
|
||||
|
||||
func unsubscribeEvents() -> void:
|
||||
# Override this method to unsubscribe from any events when the condition is no longer needed
|
||||
pass
|
||||
|
||||
func shouldAutoStart() -> bool:
|
||||
return false
|
||||
|
||||
@@ -10,4 +20,15 @@ func start() -> void:
|
||||
super.start()
|
||||
|
||||
if ifCondition():
|
||||
startEventGroup()
|
||||
startEventGroup()
|
||||
|
||||
func onEventTrigger() -> void:
|
||||
if !ifCondition():
|
||||
return
|
||||
eventConditionMet.emit()
|
||||
|
||||
func onTriggerListening(_trigger:EventTrigger) -> void:
|
||||
subscribeEvents()
|
||||
|
||||
func onTriggerNotListening(_trigger:EventTrigger) -> void:
|
||||
unsubscribeEvents()
|
||||
|
1
scripts/Event/Condition/EventIfQuest.gd.uid
Normal file
1
scripts/Event/Condition/EventIfQuest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dwcd277pv3p1t
|
@@ -1,70 +0,0 @@
|
||||
class_name EventIfQuestObjective extends "res://scripts/Event/Condition/EventIf.gd"
|
||||
|
||||
enum Type {
|
||||
ANY_OF_OBJECTIVES_COMPLETED,
|
||||
ALL_OF_OBJECTIVES_COMPLETED,
|
||||
ANY_OF_OBJECTIVES_NOT_COMPLETED,
|
||||
ALL_OF_OBJECTIVES_NOT_COMPLETED,
|
||||
SPECIFIC_OBJECTIVE_COMPLETED,
|
||||
SPECIFIC_OBJECTIVE_NOT_COMPLETED,
|
||||
}
|
||||
|
||||
@export var questKey:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST
|
||||
@export var type:Type = Type.ALL_OF_OBJECTIVES_COMPLETED
|
||||
@export var objective:int = 0
|
||||
@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
|
||||
|
||||
match type:
|
||||
Type.ANY_OF_OBJECTIVES_COMPLETED:
|
||||
for objective in quest.objecitves:
|
||||
if !objective.isCompleted():
|
||||
continue
|
||||
self.start()
|
||||
return
|
||||
|
||||
Type.ALL_OF_OBJECTIVES_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if !objective.isCompleted():
|
||||
return
|
||||
self.start()
|
||||
|
||||
Type.ANY_OF_OBJECTIVES_NOT_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if objective.isCompleted():
|
||||
continue
|
||||
self.start()
|
||||
return
|
||||
|
||||
Type.ALL_OF_OBJECTIVES_NOT_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if objective.isCompleted():
|
||||
return
|
||||
self.start()
|
||||
|
||||
Type.SPECIFIC_OBJECTIVE_COMPLETED:
|
||||
if quest.objectives[objective].isCompleted():
|
||||
self.start()
|
||||
return
|
||||
|
||||
Type.SPECIFIC_OBJECTIVE_NOT_COMPLETED:
|
||||
if quest.objectives[objective].isCompleted():
|
||||
return
|
||||
self.start()
|
Reference in New Issue
Block a user