Event Trigger Update

This commit is contained in:
2025-06-09 09:24:32 -05:00
parent 8f52da0f5d
commit 3c11b232fa
17 changed files with 131 additions and 133 deletions

View File

@@ -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()

View File

@@ -0,0 +1 @@
uid://dwcd277pv3p1t

View File

@@ -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()