diff --git a/addons/babushkahelpers/babushka_dialogue_style.tres b/addons/babushkahelpers/babushka_dialogue_style.tres index ec319c2..647f7c8 100644 --- a/addons/babushkahelpers/babushka_dialogue_style.tres +++ b/addons/babushkahelpers/babushka_dialogue_style.tres @@ -12,42 +12,34 @@ [sub_resource type="Resource" id="Resource_w535h"] script = ExtResource("1_hr3vo") -overrides = {} [sub_resource type="Resource" id="Resource_j3dy5"] script = ExtResource("1_hr3vo") scene = ExtResource("2_cpmol") -overrides = {} [sub_resource type="Resource" id="Resource_d5o1r"] script = ExtResource("1_hr3vo") scene = ExtResource("3_12uyf") -overrides = {} [sub_resource type="Resource" id="Resource_g7mor"] script = ExtResource("1_hr3vo") scene = ExtResource("4_ncyk4") -overrides = {} [sub_resource type="Resource" id="Resource_wgjgg"] script = ExtResource("1_hr3vo") scene = ExtResource("5_qg2g4") -overrides = {} [sub_resource type="Resource" id="Resource_45hxc"] script = ExtResource("1_hr3vo") scene = ExtResource("6_c5ex4") -overrides = {} [sub_resource type="Resource" id="Resource_c53vn"] script = ExtResource("1_hr3vo") scene = ExtResource("7_bopa1") -overrides = {} [sub_resource type="Resource" id="Resource_n6k7j"] script = ExtResource("1_hr3vo") scene = ExtResource("8_oycnw") -overrides = {} [resource] script = ExtResource("9_i6i1n") @@ -63,6 +55,4 @@ layer_info = { "15": SubResource("Resource_c53vn"), "16": SubResource("Resource_n6k7j") } -base_overrides = {} -layers = Array[ExtResource("1_hr3vo")]([]) metadata/_latest_layer = "" diff --git a/addons/dialogic/vesna_style.tres b/addons/dialogic/vesna_style.tres index 89a40f3..1bfe954 100644 --- a/addons/dialogic/vesna_style.tres +++ b/addons/dialogic/vesna_style.tres @@ -22,17 +22,14 @@ overrides = { [sub_resource type="Resource" id="Resource_awdqn"] script = ExtResource("1_kc0s3") scene = ExtResource("2_wjopr") -overrides = {} [sub_resource type="Resource" id="Resource_5pou4"] script = ExtResource("1_kc0s3") scene = ExtResource("3_depsi") -overrides = {} [sub_resource type="Resource" id="Resource_6xrvb"] script = ExtResource("1_kc0s3") scene = ExtResource("4_wy5ku") -overrides = {} [sub_resource type="Resource" id="Resource_k1327"] script = ExtResource("1_kc0s3") @@ -55,7 +52,6 @@ overrides = { [sub_resource type="Resource" id="Resource_qtijl"] script = ExtResource("1_kc0s3") scene = ExtResource("6_iipq0") -overrides = {} [sub_resource type="Resource" id="Resource_nalij"] script = ExtResource("1_kc0s3") @@ -72,17 +68,14 @@ overrides = { [sub_resource type="Resource" id="Resource_ymn1b"] script = ExtResource("1_kc0s3") scene = ExtResource("8_4ig6v") -overrides = {} [sub_resource type="Resource" id="Resource_8j3qh"] script = ExtResource("1_kc0s3") scene = ExtResource("9_gni8k") -overrides = {} [sub_resource type="Resource" id="Resource_uu1x2"] script = ExtResource("1_kc0s3") scene = ExtResource("6_iipq0") -overrides = {} [resource] script = ExtResource("10_l174f") @@ -100,6 +93,4 @@ layer_info = { "17": SubResource("Resource_8j3qh"), "18": SubResource("Resource_uu1x2") } -base_overrides = {} -layers = Array[ExtResource("1_kc0s3")]([]) metadata/_latest_layer = "13" diff --git a/dialog/NPC_narrative.tres b/dialog/NPC_narrative.tres index 8d2e8b1..8acc773 100644 --- a/dialog/NPC_narrative.tres +++ b/dialog/NPC_narrative.tres @@ -24,17 +24,14 @@ overrides = { [sub_resource type="Resource" id="Resource_uxnk3"] script = ExtResource("1_0jwhi") scene = ExtResource("2_8wrfq") -overrides = {} [sub_resource type="Resource" id="Resource_ihoat"] script = ExtResource("1_0jwhi") scene = ExtResource("3_t7aeg") -overrides = {} [sub_resource type="Resource" id="Resource_pw0bl"] script = ExtResource("1_0jwhi") scene = ExtResource("4_85y6g") -overrides = {} [sub_resource type="Resource" id="Resource_lfav5"] script = ExtResource("1_0jwhi") @@ -58,7 +55,6 @@ overrides = { [sub_resource type="Resource" id="Resource_clhbu"] script = ExtResource("1_0jwhi") scene = ExtResource("6_i6h15") -overrides = {} [sub_resource type="Resource" id="Resource_umvdi"] script = ExtResource("1_0jwhi") @@ -75,17 +71,14 @@ overrides = { [sub_resource type="Resource" id="Resource_ci2ul"] script = ExtResource("1_0jwhi") scene = ExtResource("8_h83v4") -overrides = {} [sub_resource type="Resource" id="Resource_sadu5"] script = ExtResource("1_0jwhi") scene = ExtResource("9_4c2uo") -overrides = {} [sub_resource type="Resource" id="Resource_0jwhi"] script = ExtResource("1_0jwhi") scene = ExtResource("6_i6h15") -overrides = {} [resource] script = ExtResource("10_e3ue2") @@ -103,6 +96,4 @@ layer_info = { "17": SubResource("Resource_sadu5"), "18": SubResource("Resource_0jwhi") } -base_overrides = {} -layers = Array[ExtResource("1_0jwhi")]([]) metadata/_latest_layer = "13" diff --git a/project.godot b/project.godot index 4b22b5d..4a1f774 100644 --- a/project.godot +++ b/project.godot @@ -121,7 +121,6 @@ directories/tres_directory={ "8_goto_bed": "res://resources/quests/demo/8_goto_bed.tres", "9_talk_to_chuga": "res://resources/quests/demo/9_talk_to_chuga.tres", "Babushka_NPC_Namebox_background": "res://dialog/Babushka_NPC_Namebox_background.tres", -"ColorEvent": "res://resources/events/ColorEvent.tres", "InputFieldsStyle": "res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres", "MainTheme": "res://addons/dialogic/Editor/Theme/MainTheme.tres", "NPC_narrative": "res://dialog/NPC_narrative.tres", @@ -133,7 +132,6 @@ directories/tres_directory={ "SectionPanel": "res://addons/dialogic/Editor/Events/styles/SectionPanel.tres", "SimpleButtonHover": "res://addons/dialogic/Editor/Events/styles/SimpleButtonHover.tres", "SimpleButtonNormal": "res://addons/dialogic/Editor/Events/styles/SimpleButtonNormal.tres", -"TestStringEvent": "res://resources/events/TestStringEvent.tres", "TextBackground": "res://addons/dialogic/Editor/Events/styles/TextBackground.tres", "TitleBgStylebox": "res://addons/dialogic/Editor/Common/TitleBgStylebox.tres", "babushka_dialogue_style": "res://addons/babushkahelpers/babushka_dialogue_style.tres", @@ -146,6 +144,8 @@ directories/tres_directory={ "default_bus_layout": "res://audio/default_bus_layout.tres", "default_stylebox": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/default_stylebox.tres", "default_vn_style": "res://addons/dialogic/Modules/DefaultLayoutParts/Style_VN_Default/default_vn_style.tres", +"event_colorButtonClicked": "res://resources/low code/test/event_colorButtonClicked.tres", +"event_textLabelClicked": "res://resources/low code/test/event_textLabelClicked.tres", "farming_equipment_glossary": "res://dialog/farming_equipment_glossary.tres", "hoe": "res://resources/items/hoe.tres", "inventory_interactable_outline": "res://art/materials/inventory_interactable_outline.tres", @@ -168,6 +168,7 @@ directories/tres_directory={ "tomato": "res://resources/items/tomato.tres", "tomato_seed": "res://resources/items/tomato_seed.tres", "unselected_stylebox": "res://addons/dialogic/Editor/Events/styles/unselected_stylebox.tres", +"var_ColorTestValue": "res://resources/low code/test/var_ColorTestValue.tres", "vesna_style": "res://addons/dialogic/vesna_style.tres", "vn_textbox_default_panel": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_default_panel.tres", "vn_textbox_name_label_panel": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_name_label_panel.tres", diff --git a/resources/events/ColorEvent.tres b/resources/events/ColorEvent.tres deleted file mode 100644 index 03399f5..0000000 --- a/resources/events/ColorEvent.tres +++ /dev/null @@ -1,9 +0,0 @@ -[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://dc7e13hq47uma"] - -[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_ufwo5"] - -[resource] -script = ExtResource("1_ufwo5") -_showLog = true -Payload = Color(0.84002423, 0.44197178, 0.5653889, 1) -metadata/_custom_type_script = "uid://ci3t5mvnopntg" diff --git a/resources/events/TestStringEvent.tres b/resources/low code/test/event_colorButtonClicked.tres similarity index 51% rename from resources/events/TestStringEvent.tres rename to resources/low code/test/event_colorButtonClicked.tres index aa7a312..39d8efc 100644 --- a/resources/events/TestStringEvent.tres +++ b/resources/low code/test/event_colorButtonClicked.tres @@ -1,9 +1,7 @@ -[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://bgfxakxxfmoxs"] +[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://bfw1dfd0r8avr"] -[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_dd3u7"] +[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_yg3mc"] [resource] -script = ExtResource("1_dd3u7") -_showLog = true -Payload = "This is a test." +script = ExtResource("1_yg3mc") metadata/_custom_type_script = "uid://ci3t5mvnopntg" diff --git a/resources/low code/test/event_textLabelClicked.tres b/resources/low code/test/event_textLabelClicked.tres new file mode 100644 index 0000000..1c2fe6f --- /dev/null +++ b/resources/low code/test/event_textLabelClicked.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://boijwlxmth68v"] + +[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_vfqv2"] + +[resource] +script = ExtResource("1_vfqv2") +metadata/_custom_type_script = "uid://ci3t5mvnopntg" diff --git a/resources/low code/test/var_ColorTestValue.tres b/resources/low code/test/var_ColorTestValue.tres new file mode 100644 index 0000000..1c579b1 --- /dev/null +++ b/resources/low code/test/var_ColorTestValue.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="VariableResource" load_steps=2 format=3 uid="uid://dpnre2bn041jm"] + +[ext_resource type="Script" uid="uid://dtvx2cakx0bey" path="res://scripts/CSharp/Low Code/Variables/VariableResource.cs" id="1_h8big"] + +[resource] +script = ExtResource("1_h8big") +Payload = Color(0, 0, 0, 1) +metadata/_custom_type_script = "uid://dtvx2cakx0bey" diff --git a/scenes/testing/eventTest.tscn b/scenes/testing/eventTest.tscn index d7a968c..6a0923e 100644 --- a/scenes/testing/eventTest.tscn +++ b/scenes/testing/eventTest.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://6n3p3psmxovj"] +[gd_scene load_steps=7 format=3 uid="uid://6n3p3psmxovj"] +[ext_resource type="Script" uid="uid://pqemey80frcq" path="res://scripts/CSharp/Low Code/Variables/VariableListener.cs" id="1_4h3ry"] [ext_resource type="Script" uid="uid://bc6uaaxsx5k5p" path="res://scripts/CSharp/Low Code/Events/EventListener.cs" id="1_w5ykc"] -[ext_resource type="Resource" uid="uid://dc7e13hq47uma" path="res://resources/events/ColorEvent.tres" id="2_4h3ry"] +[ext_resource type="Resource" uid="uid://dpnre2bn041jm" path="res://resources/low code/test/var_ColorTestValue.tres" id="2_bj4kf"] [ext_resource type="Script" uid="uid://b5dotkx17gvxg" path="res://scripts/CSharp/Low Code/Events/EventRaiser.cs" id="3_bj4kf"] -[ext_resource type="Resource" uid="uid://bgfxakxxfmoxs" path="res://resources/events/TestStringEvent.tres" id="4_5dsed"] +[ext_resource type="Resource" uid="uid://boijwlxmth68v" path="res://resources/low code/test/event_textLabelClicked.tres" id="5_4h3ry"] [ext_resource type="Script" uid="uid://co1b320qemg1i" path="res://scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs" id="5_nm8dh"] [node name="EventTest" type="Node2D"] @@ -19,45 +20,48 @@ offset_bottom = 329.0 layout_mode = 0 offset_right = 178.0 offset_bottom = 145.0 -script = ExtResource("1_w5ykc") -_eventResources = Array[Object]([ExtResource("2_4h3ry")]) -_showLog = true +script = ExtResource("1_4h3ry") +_variableResources = Array[Object]([ExtResource("2_bj4kf")]) -[node name="LabelTextEventButton" type="Button" parent="Control"] +[node name="ChangeColorButton" type="Button" parent="Control"] layout_mode = 0 -offset_left = 194.0 offset_top = 148.0 -offset_right = 351.0 +offset_right = 112.0 offset_bottom = 179.0 -text = "Show Event Text +text = "Change Color " -script = ExtResource("3_bj4kf") -_eventResources = Array[Object]([ExtResource("4_5dsed")]) +script = ExtResource("5_nm8dh") +_variableResource = ExtResource("2_bj4kf") -[node name="ChangeColorButton" type="Button" parent="Control"] +[node name="LabelTextEventButton" type="Button" parent="Control"] layout_mode = 0 +offset_left = 194.0 offset_top = 148.0 -offset_right = 112.0 +offset_right = 351.0 offset_bottom = 179.0 -text = "Change Color +text = "Show Event Text " -script = ExtResource("5_nm8dh") -_eventResource = ExtResource("2_4h3ry") +script = ExtResource("3_bj4kf") +_eventResources = Array[Object]([ExtResource("5_4h3ry")]) [node name="TestLabel" type="Label" parent="Control"] +visible = false layout_mode = 0 offset_left = 237.0 offset_top = 54.0 offset_right = 277.0 offset_bottom = 77.0 +text = "[Dieser Text erscheint, +wenn das Event richtig +verknüpft ist]" script = ExtResource("1_w5ykc") -_eventResources = Array[Object]([ExtResource("4_5dsed")]) +_eventResources = Array[Object]([ExtResource("5_4h3ry")]) [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(239, 110) zoom = Vector2(3.4, 3.4) [connection signal="NewEventPayload" from="Control/ColorRect" to="Control/ColorRect" method="set_color"] -[connection signal="pressed" from="Control/LabelTextEventButton" to="Control/LabelTextEventButton" method="RaiseEvents"] [connection signal="pressed" from="Control/ChangeColorButton" to="Control/ChangeColorButton" method="RandomizeEventResource"] -[connection signal="EventRaisedWithPayload" from="Control/TestLabel" to="Control/TestLabel" method="set_text"] +[connection signal="pressed" from="Control/LabelTextEventButton" to="Control/LabelTextEventButton" method="RaiseEvents"] +[connection signal="EventRaised" from="Control/TestLabel" to="Control/TestLabel" method="show"] diff --git a/scripts/CSharp/Low Code/Events/EventListener.cs b/scripts/CSharp/Low Code/Events/EventListener.cs index caa2801..085fbf4 100644 --- a/scripts/CSharp/Low Code/Events/EventListener.cs +++ b/scripts/CSharp/Low Code/Events/EventListener.cs @@ -23,27 +23,6 @@ public partial class EventListener : Node /// [Signal] public delegate void EventRaisedEventHandler(); - /// - /// The signal that is triggered when this listener is called by one of the . - /// - [Signal] public delegate void EventRaisedWithPayloadEventHandler(Variant payload); - - /// - /// A signal that is triggered when the payload of one of the changed. - /// - [Signal] public delegate void PayloadChangedEventHandler(Variant payload, Variant oldPayload); - - /// - /// A signal that is triggered when the payload of one of the changed. - /// - [Signal] public delegate void NewEventPayloadEventHandler(Variant payload); - - /// - /// A signal that is triggered when the payload of one of the changed. - /// - [Signal] public delegate void OldEventPayloadEventHandler(Variant oldPayload); - - /// /// Subscribes to all s present in the array. /// @@ -72,24 +51,12 @@ public partial class EventListener : Node /// Called by a s from the array. /// Propagates the event by emitting signal. /// - public void EventInvoked(Variant payload) + public void EventInvoked() { if(_showLog) GD.Print("Event Raised on: " + Name); EmitSignal(SignalName.EventRaised); - EmitSignal(SignalName.EventRaisedWithPayload, payload); } - /// - /// Called by a s from the array. - /// Propagates the event by emitting signal. - /// - public void EventPayloadChanged(Variant payload, Variant oldPayload) - { - if(_showLog) - GD.Print($"Calling Event Payload Changed Signals on: " + Name); - EmitSignal(SignalName.PayloadChanged, payload, oldPayload); - EmitSignal(SignalName.NewEventPayload, payload); - EmitSignal(SignalName.OldEventPayload, oldPayload); - } + } \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Events/EventResource.cs b/scripts/CSharp/Low Code/Events/EventResource.cs index 4811348..4b829a3 100644 --- a/scripts/CSharp/Low Code/Events/EventResource.cs +++ b/scripts/CSharp/Low Code/Events/EventResource.cs @@ -14,24 +14,6 @@ public partial class EventResource : Resource /// Log into console when this event resource is adding or removing listeners, and when it's raised. /// [Export] private bool _showLog; - - [Export] - public Variant Payload - { - get { return _payload; } - set - { - if (!_payload.Equals(value)) - { - _lastPayload = _payload; - _payload = value; - ValueChangeHandler(); - } - } - } - - private Variant _payload; - private Variant _lastPayload; /// /// Raise-Button Call with Editor Export for easier debugging. @@ -74,22 +56,10 @@ public partial class EventResource : Resource foreach (var eventListener in _eventListeners) { - eventListener.EventInvoked(_payload); + eventListener.EventInvoked(); } } - /// - /// Called when the Payload value changed. - /// - public void ValueChangeHandler() - { - if(_showLog) - GD.Print($"Event payload changed from {_lastPayload} to {_payload} on event resource: " + ResourcePath.GetFile().TrimSuffix(".tres")); - - foreach (var eventListener in _eventListeners) - { - eventListener.EventPayloadChanged(_payload, _lastPayload); - } - } + } \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs b/scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs index 178af0d..140b400 100644 --- a/scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs +++ b/scripts/CSharp/Low Code/Randomizer/VariantRandomizer.cs @@ -1,5 +1,6 @@ using System; using Babushka.scripts.CSharp.Low_Code.Events; +using Babushka.scripts.CSharp.Low_Code.Variables; using Godot; @@ -13,23 +14,23 @@ public partial class VariantRandomizer : Node /// /// The event resource to work on. /// - [Export] public EventResource _eventResource; + [Export] public VariableResource _variableResource; /// /// Sets the payload of a randomizable event resource to a random value. /// public void RandomizeEventResource() { - switch (_eventResource.Payload.VariantType) + switch (_variableResource.Payload.VariantType) { case Variant.Type.Color: - _eventResource.Payload= GetRandomColor(); + _variableResource.Payload= GetRandomColor(); break; case Variant.Type.Int: - _eventResource.Payload= GetRandomInt(); + _variableResource.Payload= GetRandomInt(); break; case Variant.Type.Float: - _eventResource.Payload= GetRandomFloat(); + _variableResource.Payload= GetRandomFloat(); break; } } diff --git a/scripts/CSharp/Low Code/Variables/VariableListener.cs b/scripts/CSharp/Low Code/Variables/VariableListener.cs new file mode 100644 index 0000000..238381f --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableListener.cs @@ -0,0 +1,69 @@ +using Godot; +using Godot.Collections; + +namespace Babushka.scripts.CSharp.Low_Code.Variables; + +public partial class VariableListener : Node +{ + /// + /// The event resource to listen to. + /// + [Export] private Array _variableResources; + + /// + /// Log to console when this event is being raised. + /// + [Export] private bool _showLog; + + /// + /// A signal that is triggered when the payload of one of the changed. + /// + [Signal] public delegate void PayloadChangedEventHandler(Variant payload, Variant oldPayload); + + /// + /// A signal that is triggered when the payload of one of the changed. + /// + [Signal] public delegate void NewEventPayloadEventHandler(Variant payload); + + /// + /// A signal that is triggered when the payload of one of the changed. + /// + [Signal] public delegate void OldEventPayloadEventHandler(Variant oldPayload); + + /// + /// Subscribes to all s present in the array. + /// + /// + public override void _EnterTree() + { + foreach (var resource in _variableResources) + { + resource.RegisterListener(this); + } + } + + /// + /// Unsubscribes from all s present in the array. + /// + /// + public override void _ExitTree() + { + foreach (var variableResource in _variableResources) + { + variableResource.UnregisterListener(this); + } + } + + /// + /// Called by a s from the array. + /// Propagates the event by emitting signal. + /// + public void EventPayloadChanged(Variant payload, Variant oldPayload) + { + if(_showLog) + GD.Print($"Calling Event Payload Changed Signals on: " + Name); + EmitSignal(SignalName.PayloadChanged, payload, oldPayload); + EmitSignal(SignalName.NewEventPayload, payload); + EmitSignal(SignalName.OldEventPayload, oldPayload); + } +} \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Variables/VariableListener.cs.uid b/scripts/CSharp/Low Code/Variables/VariableListener.cs.uid new file mode 100644 index 0000000..8ed0b0c --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableListener.cs.uid @@ -0,0 +1 @@ +uid://pqemey80frcq diff --git a/scripts/CSharp/Low Code/Variables/VariableResource.cs b/scripts/CSharp/Low Code/Variables/VariableResource.cs new file mode 100644 index 0000000..77bc13e --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableResource.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using Godot; + +namespace Babushka.scripts.CSharp.Low_Code.Variables; + +[GlobalClass] +public partial class VariableResource : Resource +{ + /// + /// Log into console when this event resource is adding or removing listeners, and when it's raised. + /// + [Export] private bool _showLog; + + [Export] + public Variant Payload + { + get { return _payload; } + set + { + if (!_payload.Equals(value)) + { + _lastPayload = _payload; + _payload = value; + ValueChangeHandler(); + } + } + } + + private Variant _payload; + private Variant _lastPayload; + + private List _varListeners = new (); + + /// + /// Adds an EventListener to the calling list for this event. + /// + /// + public void RegisterListener(VariableListener listener) + { + if(_showLog) + GD.Print("Registering listener " + listener); + _varListeners.Add(listener); + } + + /// + /// Removes an Eventlistener from the calling list for this event. + /// + /// + public void UnregisterListener(VariableListener listener) + { + if(_showLog) + GD.Print("Unregistering listener " + listener); + _varListeners.Remove(listener); + } + + /// + /// Called when the Payload value changed. + /// + public void ValueChangeHandler() + { + if(_showLog) + GD.Print($"Event payload changed from {_lastPayload} to {_payload} on event resource: " + ResourcePath.GetFile().TrimSuffix(".tres")); + + foreach (var eventListener in _varListeners) + { + eventListener.EventPayloadChanged(_payload, _lastPayload); + } + } +} \ No newline at end of file diff --git a/scripts/CSharp/Low Code/Variables/VariableResource.cs.uid b/scripts/CSharp/Low Code/Variables/VariableResource.cs.uid new file mode 100644 index 0000000..dc3a112 --- /dev/null +++ b/scripts/CSharp/Low Code/Variables/VariableResource.cs.uid @@ -0,0 +1 @@ +uid://dtvx2cakx0bey