From 0e3a90149b9ef907967317d8694093fec206ce9a Mon Sep 17 00:00:00 2001 From: Matteo Tietz Date: Sat, 20 Apr 2024 17:36:26 +0200 Subject: [PATCH] Implement TriggerOnCollision --- project.godot | 8 +++++++- scripts/Library/Actions/TriggerOnCollision.gd | 9 ++++++--- scripts/OnMusicChangedSlowTrigger.gd | 11 ----------- 3 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 scripts/OnMusicChangedSlowTrigger.gd diff --git a/project.godot b/project.godot index 488eeed..9cea6b9 100644 --- a/project.godot +++ b/project.godot @@ -22,7 +22,7 @@ _global_script_classes=[ { "base": "Node", "class": "MusicChangedSlowAction", "language": "GDScript", -"path": "res://scripts/OnMusicChangedSlowTrigger.gd" +"path": "res://scripts/TriggerOnMusicChangedSlow.gd" }, { "base": "Action", "class": "PlaySound", @@ -35,6 +35,11 @@ _global_script_classes=[ { "path": "res://scripts/Library/Actions/TriggerBase.gd" }, { "base": "TriggerBase", +"class": "TriggerOnCollision", +"language": "GDScript", +"path": "res://scripts/Library/Actions/TriggerOnCollision.gd" +}, { +"base": "TriggerBase", "class": "TriggerOnReady", "language": "GDScript", "path": "res://scripts/Library/Actions/TriggerOnReady.gd" @@ -45,6 +50,7 @@ _global_script_class_icons={ "MusicChangedSlowAction": "", "PlaySound": "", "TriggerBase": "", +"TriggerOnCollision": "", "TriggerOnReady": "" } diff --git a/scripts/Library/Actions/TriggerOnCollision.gd b/scripts/Library/Actions/TriggerOnCollision.gd index 9f14dd2..4f03bdb 100644 --- a/scripts/Library/Actions/TriggerOnCollision.gd +++ b/scripts/Library/Actions/TriggerOnCollision.gd @@ -1,6 +1,9 @@ -extends TriggerBase +class_name TriggerOnCollision extends TriggerBase -export var collision_area +export(NodePath) var collision_area func _ready(): - pass # Replace with function body. + collision_area.connect("body_entered", self, "_on_body_entered") + +func _on_body_entered(body: Node): + triggerAction(body) diff --git a/scripts/OnMusicChangedSlowTrigger.gd b/scripts/OnMusicChangedSlowTrigger.gd deleted file mode 100644 index 1d57758..0000000 --- a/scripts/OnMusicChangedSlowTrigger.gd +++ /dev/null @@ -1,11 +0,0 @@ -class_name MusicChangedSlowAction extends Node - -func _ready(): - MusicSingleton.register_change_action(self) - MusicSingleton.change_music() - -func _exit_tree(): - MusicSingleton.unregister_change_action(self) - -func execute() -> void: - print("Executed OnMusicChangedSlowAction")