Event Trigger Update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dx6fv8n4jl5ku"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dx6fv8n4jl5ku"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="1_7b7hx"]
|
||||
[ext_resource type="Script" uid="uid://c37crdel0m5mw" path="res://scripts/Map/Map.gd" id="1_ru75d"]
|
||||
@@ -11,9 +11,8 @@
|
||||
[ext_resource type="Script" uid="uid://c4d7nithqnx5y" path="res://scripts/Event/Quest/EventStartQuest.gd" id="7_brp0k"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkj630bhmnvsi" path="res://scenes/Entities/Sign.tscn" id="9_xfqoe"]
|
||||
[ext_resource type="Script" uid="uid://b41umpbgqfuc2" path="res://scripts/Event/Item/EventGetItem.gd" id="10_avybc"]
|
||||
[ext_resource type="Script" uid="uid://0ygswaohp7kj" path="res://scripts/Event/EventFlagModify.gd" id="12_ncdgy"]
|
||||
[ext_resource type="Script" uid="uid://ccujhcc446mvh" path="res://scripts/Event/Condition/EventIfFlag.gd" id="13_60ixl"]
|
||||
[ext_resource type="Script" uid="uid://cvrib7pjlip8g" path="res://scripts/Event/Condition/EventIfQuestObjective.gd" id="14_i48p6"]
|
||||
[ext_resource type="Script" uid="uid://0ev1l0bf85gj" path="res://scripts/Event/Quest/EventIfQuest.gd" id="10_i48p6"]
|
||||
[ext_resource type="Script" uid="uid://cs7voh47aoca8" path="res://scripts/Event/EventTrigger.gd" id="13_60ixl"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1h75"]
|
||||
sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)
|
||||
@@ -103,21 +102,29 @@ omni_range = 281.646
|
||||
script = ExtResource("5_cg1ph")
|
||||
|
||||
[node name="After Quest Started" type="Node" parent="Events/TestConversation"]
|
||||
script = ExtResource("13_60ixl")
|
||||
event = 1
|
||||
eventFlag = 1
|
||||
metadata/_custom_type_script = "uid://ccujhcc446mvh"
|
||||
script = ExtResource("10_i48p6")
|
||||
type = 6
|
||||
metadata/_custom_type_script = "uid://0ev1l0bf85gj"
|
||||
|
||||
[node name="Text 2" type="Node" parent="Events/TestConversation/After Quest Started"]
|
||||
[node name="EventIfQuest" type="Node" parent="Events/TestConversation/After Quest Started"]
|
||||
script = ExtResource("10_i48p6")
|
||||
|
||||
[node name="Text 2" type="Node" parent="Events/TestConversation/After Quest Started/EventIfQuest"]
|
||||
script = ExtResource("6_gxq5o")
|
||||
text = "You are reading the words fo god"
|
||||
|
||||
[node name="EventIfQuest2" type="Node" parent="Events/TestConversation/After Quest Started"]
|
||||
script = ExtResource("10_i48p6")
|
||||
type = 2
|
||||
|
||||
[node name="Text 2" type="Node" parent="Events/TestConversation/After Quest Started/EventIfQuest2"]
|
||||
script = ExtResource("6_gxq5o")
|
||||
text = "map.test_map.event.gather_onion.text2"
|
||||
|
||||
[node name="Before Quest Started" type="Node" parent="Events/TestConversation"]
|
||||
script = ExtResource("13_60ixl")
|
||||
event = 1
|
||||
type = 2
|
||||
eventFlag = 1
|
||||
metadata/_custom_type_script = "uid://ccujhcc446mvh"
|
||||
script = ExtResource("10_i48p6")
|
||||
type = 7
|
||||
metadata/_custom_type_script = "uid://0ev1l0bf85gj"
|
||||
|
||||
[node name="Text 0" type="Node" parent="Events/TestConversation/Before Quest Started"]
|
||||
script = ExtResource("6_gxq5o")
|
||||
@@ -136,17 +143,14 @@ script = ExtResource("10_avybc")
|
||||
getType = 1
|
||||
metadata/_custom_type_script = "uid://b41umpbgqfuc2"
|
||||
|
||||
[node name="EventFlagModify" type="Node" parent="Events/TestConversation/Before Quest Started"]
|
||||
script = ExtResource("12_ncdgy")
|
||||
event = 1
|
||||
eventFlag = 1
|
||||
metadata/_custom_type_script = "uid://0ygswaohp7kj"
|
||||
[node name="EventTrigger" type="Node" parent="Events"]
|
||||
script = ExtResource("13_60ixl")
|
||||
|
||||
[node name="EventQuestAllObjectivesComplete" type="Node" parent="Events"]
|
||||
script = ExtResource("14_i48p6")
|
||||
metadata/_custom_type_script = "uid://cvrib7pjlip8g"
|
||||
[node name="EventIf" type="Node" parent="Events/EventTrigger"]
|
||||
script = ExtResource("10_i48p6")
|
||||
type = 6
|
||||
metadata/_custom_type_script = "uid://0ev1l0bf85gj"
|
||||
|
||||
[node name="TextTest" type="Node" parent="Events/EventQuestAllObjectivesComplete"]
|
||||
[node name="Text 0" type="Node" parent="Events/EventTrigger/EventIf"]
|
||||
script = ExtResource("6_gxq5o")
|
||||
text = "testestest
|
||||
"
|
||||
text = "Triggered"
|
||||
|
@@ -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
|
||||
|
||||
@@ -11,3 +21,14 @@ func start() -> void:
|
||||
|
||||
if ifCondition():
|
||||
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
|
32
scripts/Event/EventTrigger.gd
Normal file
32
scripts/Event/EventTrigger.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
class_name EventTrigger extends Node
|
||||
|
||||
@export var triggerMultipleTimes: bool = false
|
||||
|
||||
var eventIf:EventIf = null
|
||||
|
||||
func _enter_tree() -> void:
|
||||
for child in get_children():
|
||||
if !(child is EventIf):
|
||||
continue
|
||||
eventIf = child
|
||||
break
|
||||
|
||||
if eventIf == null:
|
||||
push_error(self, "requires an EventIf child to function properly")
|
||||
return
|
||||
|
||||
eventIf.eventConditionMet.connect(onConditionTriggered)
|
||||
eventIf.onTriggerListening(self)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if eventIf != null:
|
||||
eventIf.eventConditionMet.disconnect(onConditionTriggered)
|
||||
eventIf.onTriggerNotListening(self)
|
||||
|
||||
eventIf = null
|
||||
|
||||
func onConditionTriggered() -> void:
|
||||
if !triggerMultipleTimes:
|
||||
eventIf.eventConditionMet.disconnect(onConditionTriggered)
|
||||
eventIf.onTriggerNotListening(self)
|
||||
eventIf.start()
|
1
scripts/Event/EventTrigger.gd.uid
Normal file
1
scripts/Event/EventTrigger.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cs7voh47aoca8
|
@@ -1,4 +1,9 @@
|
||||
class_name EventIfQuestObjective extends "res://scripts/Event/Condition/EventIf.gd"
|
||||
class_name EventIfQuest extends "res://scripts/Event/Condition/EventIf.gd"
|
||||
## Event that checks if a quest is in a specific state, if the condition is met
|
||||
## then all children events will be run through.
|
||||
##
|
||||
## Can also be used as part of a trigger condition to fire if the quest state
|
||||
## is updated.
|
||||
|
||||
enum Type {
|
||||
ANY_OF_OBJECTIVES_COMPLETED,
|
||||
@@ -7,64 +12,66 @@ enum Type {
|
||||
ALL_OF_OBJECTIVES_NOT_COMPLETED,
|
||||
SPECIFIC_OBJECTIVE_COMPLETED,
|
||||
SPECIFIC_OBJECTIVE_NOT_COMPLETED,
|
||||
QUEST_STARTED,
|
||||
QUEST_NOT_STARTED,
|
||||
}
|
||||
|
||||
@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
|
||||
func ifCondition() -> bool:
|
||||
var quest:Quest = QUEST.quests.get(questKey)
|
||||
|
||||
match type:
|
||||
Type.ANY_OF_OBJECTIVES_COMPLETED:
|
||||
for objective in quest.objecitves:
|
||||
if !objective.isCompleted():
|
||||
continue
|
||||
self.start()
|
||||
return
|
||||
return true
|
||||
|
||||
Type.ALL_OF_OBJECTIVES_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if !objective.isCompleted():
|
||||
return
|
||||
self.start()
|
||||
return false
|
||||
return true
|
||||
|
||||
Type.ANY_OF_OBJECTIVES_NOT_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if objective.isCompleted():
|
||||
continue
|
||||
self.start()
|
||||
return
|
||||
if !objective.isCompleted():
|
||||
return true
|
||||
|
||||
Type.ALL_OF_OBJECTIVES_NOT_COMPLETED:
|
||||
for objective in quest.objectives:
|
||||
if objective.isCompleted():
|
||||
return
|
||||
self.start()
|
||||
return false
|
||||
return true
|
||||
|
||||
Type.SPECIFIC_OBJECTIVE_COMPLETED:
|
||||
if quest.objectives[objective].isCompleted():
|
||||
self.start()
|
||||
return
|
||||
return true
|
||||
|
||||
Type.SPECIFIC_OBJECTIVE_NOT_COMPLETED:
|
||||
if quest.objectives[objective].isCompleted():
|
||||
return false
|
||||
return true
|
||||
|
||||
Type.QUEST_STARTED:
|
||||
if quest.isStarted():
|
||||
return true
|
||||
|
||||
Type.QUEST_NOT_STARTED:
|
||||
if !quest.isStarted():
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func subscribeEvents() -> void:
|
||||
QUEST.questUpdated.connect(onQuestUpdated)
|
||||
|
||||
func unsubscribeEvents() -> void:
|
||||
QUEST.questUpdated.disconnect(onQuestUpdated)
|
||||
|
||||
func onQuestUpdated(quest:Quest) -> void:
|
||||
if quest.questKey != questKey:
|
||||
return
|
||||
self.start()
|
||||
self.onEventTrigger()
|
1
scripts/Event/Quest/EventIfQuest.gd.uid
Normal file
1
scripts/Event/Quest/EventIfQuest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://0ev1l0bf85gj
|
@@ -0,0 +1 @@
|
||||
uid://0aipsu5ele44
|
1
scripts/Event/Quest/EventQuestObjectiveComplete.gd.uid
Normal file
1
scripts/Event/Quest/EventQuestObjectiveComplete.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cnbl4x8p2xsx5
|
1
scripts/Event/Quest/EventQuestObjectiveUpdate.gd.uid
Normal file
1
scripts/Event/Quest/EventQuestObjectiveUpdate.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2aj13e48jjd4
|
@@ -1,17 +0,0 @@
|
||||
class_name EventAutoStart extends "res://scripts/Event/Flow/EventGroup.gd"
|
||||
|
||||
@export var restartWhenEnded: bool = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
super._process(delta)
|
||||
|
||||
if self.ended:
|
||||
if !self.restartWhenEnded:
|
||||
return
|
||||
|
||||
self.reset()
|
||||
|
||||
if self.started && !self.ended:
|
||||
return
|
||||
|
||||
self.start()
|
@@ -1 +0,0 @@
|
||||
uid://ckeqruxf6boav
|
@@ -1,28 +0,0 @@
|
||||
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()
|
@@ -1 +0,0 @@
|
||||
uid://ck0vs0awnc4n2
|
@@ -1,24 +0,0 @@
|
||||
class_name EventQuestObjectiveComplete extends "res://scripts/Event/Flow/EventGroup.gd"
|
||||
|
||||
@export var triggerIfObjectiveUncompletedThenComplatedAgain: bool = false
|
||||
@export var quest:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST
|
||||
@export var objectiveIndex:int = 0
|
||||
|
||||
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.triggerIfObjectiveUncompletedThenComplatedAgain:
|
||||
return
|
||||
self.reset()
|
||||
|
||||
if !quest.isStarted():
|
||||
return
|
||||
|
||||
if !quest.objectives[objectiveIndex].isCompleted():
|
||||
return
|
||||
self.start()
|
@@ -1 +0,0 @@
|
||||
uid://baywtxo4wy5i4
|
@@ -27,7 +27,7 @@ func isCompleted() -> bool:
|
||||
func isStarted() -> bool:
|
||||
return questStarted
|
||||
|
||||
func objectiveUpdated(objective:QuestObjective) -> void:
|
||||
func objectiveUpdated(_objective:QuestObjective) -> void:
|
||||
QUEST.questUpdated.emit(self)
|
||||
|
||||
func getTransContext() -> TransContext:
|
||||
|
Reference in New Issue
Block a user