From 6b2fa2b38169b7f7fc488eec7475a70272e6fa12 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 20 May 2025 07:28:02 -0500 Subject: [PATCH] Event Go To --- scenes/Maps/TestMap/TestMap.tscn | 14 ++++++++---- scripts/Event/Event.gd | 3 +++ scripts/Event/EventConversation.gd | 20 ++++++++++++----- scripts/Event/EventPause.gd | 5 +++-- scripts/Event/Flow/EventGoTo.gd | 35 +++++++++++++++++++++++++++++ scripts/Event/Flow/EventGoTo.gd.uid | 1 + scripts/Event/Flow/EventGroup.gd | 3 +++ 7 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 scripts/Event/Flow/EventGoTo.gd create mode 100644 scripts/Event/Flow/EventGoTo.gd.uid diff --git a/scenes/Maps/TestMap/TestMap.tscn b/scenes/Maps/TestMap/TestMap.tscn index 25b8eec..f6dc0d0 100644 --- a/scenes/Maps/TestMap/TestMap.tscn +++ b/scenes/Maps/TestMap/TestMap.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 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"] @@ -12,6 +12,7 @@ [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://da7fr2bave0c" path="res://scripts/Event/Flow/EventGoTo.gd" id="13_60ixl"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1h75"] sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) @@ -89,6 +90,10 @@ metadata/_custom_type_script = "uid://0ygswaohp7kj" script = ExtResource("6_gxq5o") text = "I am giving you a quest to gather some ingredients." +[node name="EventGoTo" type="Node" parent="Events/TestConversation" node_paths=PackedStringArray("event")] +script = ExtResource("13_60ixl") +event = NodePath("../../TextTest") + [node name="Quest" type="Node" parent="Events/TestConversation"] script = ExtResource("7_brp0k") metadata/_custom_type_script = "uid://c4d7nithqnx5y" @@ -106,6 +111,7 @@ metadata/_custom_type_script = "uid://b41umpbgqfuc2" script = ExtResource("6_gxq5o") text = "Thanks for taking that potion." -[node name="EventConversation" type="Node" parent="Events"] -script = ExtResource("5_cg1ph") -metadata/_custom_type_script = "uid://tkfc88q8m86f" +[node name="TextTest" type="Node" parent="Events"] +script = ExtResource("6_gxq5o") +text = "testestest +" diff --git a/scripts/Event/Event.gd b/scripts/Event/Event.gd index 442400f..ebd9dc3 100644 --- a/scripts/Event/Event.gd +++ b/scripts/Event/Event.gd @@ -35,6 +35,9 @@ func end() -> void: assert(ended == false) ended = true +func isEndingEvent() -> bool: + return false + func reset() -> void: started = false ended = false diff --git a/scripts/Event/EventConversation.gd b/scripts/Event/EventConversation.gd index f138017..471fa0b 100644 --- a/scripts/Event/EventConversation.gd +++ b/scripts/Event/EventConversation.gd @@ -10,6 +10,8 @@ class_name EventConversation extends "res://scripts/Event/Flow/EventGroup.gd" @export var turnInteractee:bool = true @export var turnInteractor:bool = true +var endPauseEvent:EventPause = null + func start() -> void: # Turn events if interactee && interactor: @@ -37,14 +39,20 @@ func start() -> void: addExtraEvent(startPause, 0) # Create end pause event. - var endPause = EventPause.new() - endPause.pauseType = endPauseType - endPause.entities = entities + endPauseEvent = EventPause.new() + endPauseEvent.pauseType = endPauseType + endPauseEvent.entities = entities if pauseInteractee && interactee.entity: - endPause.includeInteractee = pauseInteractee + endPauseEvent.includeInteractee = pauseInteractee if pauseInteractor && interactor.entity: - endPause.includeInteractor = pauseInteractor - addExtraEvent(endPause, -1) + endPauseEvent.includeInteractor = pauseInteractor + addExtraEvent(endPauseEvent, -1) # Pass off to event group super.start() + +func end() -> void: + # Manually end pause + if endPauseEvent != null && !endPauseEvent.started: + endPauseEvent.start() + super.end() diff --git a/scripts/Event/EventPause.gd b/scripts/Event/EventPause.gd index 0089308..881c6ee 100644 --- a/scripts/Event/EventPause.gd +++ b/scripts/Event/EventPause.gd @@ -7,10 +7,11 @@ const PauseSystem = preload("res://scripts/Singleton/Pause.gd") @export var includeInteractee:bool = true @export var includeInteractor:bool = true -func start() -> void: +func end() -> void: + super.end() var ents:Array[Entity] = entities if interactor && includeInteractor && interactor.entity: ents.append(interactor.entity) if interactee && includeInteractee && interactee.entity: ents.append(interactee.entity) - PAUSE.pause(pauseType, ents) + PAUSE.pause(pauseType, ents) \ No newline at end of file diff --git a/scripts/Event/Flow/EventGoTo.gd b/scripts/Event/Flow/EventGoTo.gd new file mode 100644 index 0000000..acc9748 --- /dev/null +++ b/scripts/Event/Flow/EventGoTo.gd @@ -0,0 +1,35 @@ +class_name EventGoTo extends "res://scripts/Event/Event.gd" + +enum Type { + GO_TO, + GO_TO_AND_WAIT, + GO_TO_AND_CONTINUE +} + +@export var event:Event = null +@export var type:Type = Type.GO_TO + +func start() -> void: + super.start() + if event == null: + print("EventGoTo: No event set") + return + + event.start() + +func isDone(): + if !super.isDone(): + return false + + if event == null: + return true + + if type == Type.GO_TO_AND_WAIT: + return event.isDone() + + return true + +func isEndingEvent() -> bool: + if type == Type.GO_TO: + return true + return false \ No newline at end of file diff --git a/scripts/Event/Flow/EventGoTo.gd.uid b/scripts/Event/Flow/EventGoTo.gd.uid new file mode 100644 index 0000000..1802d89 --- /dev/null +++ b/scripts/Event/Flow/EventGoTo.gd.uid @@ -0,0 +1 @@ +uid://da7fr2bave0c diff --git a/scripts/Event/Flow/EventGroup.gd b/scripts/Event/Flow/EventGroup.gd index 41ef5d8..d1cf143 100644 --- a/scripts/Event/Flow/EventGroup.gd +++ b/scripts/Event/Flow/EventGroup.gd @@ -76,3 +76,6 @@ func startChild(child:Event) -> void: child.interactee = self.interactee child.interactor = self.interactor child.start() + + if child.isEndingEvent(): + self.end() \ No newline at end of file