-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
264 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Decembrist.Events; | ||
using Godot; | ||
|
||
namespace Decembrist.Example.EventBusEvents | ||
{ | ||
public class EventTest : Node2D | ||
{ | ||
|
||
public override void _Ready() | ||
{ | ||
var messageCount = 0; | ||
|
||
void IncrementCountCallback() | ||
{ | ||
messageCount++; | ||
} | ||
GD.Print("EventBus event test started for........................................"); | ||
var subscription1 = this.EventListener("event1", IncrementCountCallback); | ||
var subscription2 = this.EventListener("event1", IncrementCountCallback); | ||
this.FireEvent("event1"); | ||
subscription2.Stop(); | ||
subscription1.Stop(); | ||
this.FireEvent("event1"); | ||
Assertions.AssertTrue(messageCount == 2, "Event without params test"); | ||
|
||
messageCount = 0; | ||
|
||
void PlusCountCallback(int input) | ||
{ | ||
messageCount += input; | ||
} | ||
subscription1 = this.EventListener<int>("event2", PlusCountCallback); | ||
subscription2 = this.EventListener<int>("event2", PlusCountCallback); | ||
this.FireEvent("event2", 2); | ||
subscription2.Stop(); | ||
subscription1.Stop(); | ||
this.FireEvent("event2", 2); | ||
Assertions.AssertTrue(messageCount == 4, "Event with params test"); | ||
GD.Print("EventBus event test stopped..........................................."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
[gd_scene load_steps=4 format=2] | ||
[gd_scene load_steps=5 format=2] | ||
|
||
[ext_resource path="res://Example/DiTestNode.cs" type="Script" id=1] | ||
[ext_resource path="res://Example/EventBusTest/Producer.cs" type="Script" id=2] | ||
[ext_resource path="res://Example/EventBusTest/Consumer.cs" type="Script" id=3] | ||
[ext_resource path="res://Example/EventBusMessages/Producer.cs" type="Script" id=2] | ||
[ext_resource path="res://Example/EventBusMessages/Consumer.cs" type="Script" id=3] | ||
[ext_resource path="res://Example/EventBusEvents/EventTest.cs" type="Script" id=4] | ||
|
||
[node name="Node2D" type="Node2D"] | ||
|
||
[node name="DiTestNode" type="Node2D" parent="."] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="EventBusTestNode" type="Node2D" parent="."] | ||
[node name="EventBusMessages" type="Node2D" parent="."] | ||
|
||
[node name="Producer1" type="Node2D" parent="EventBusTestNode"] | ||
[node name="Producer1" type="Node2D" parent="EventBusMessages"] | ||
script = ExtResource( 2 ) | ||
_messageAddress = "consumer-address1" | ||
|
||
[node name="Producer2" type="Node2D" parent="EventBusTestNode"] | ||
script = ExtResource( 2 ) | ||
_messageAddress = "consumer-address2" | ||
|
||
[node name="Consumer" type="Node2D" parent="EventBusTestNode"] | ||
[node name="Consumer" type="Node2D" parent="EventBusMessages"] | ||
script = ExtResource( 3 ) | ||
|
||
[node name="EventBusEvents" type="Node2D" parent="."] | ||
|
||
[node name="EventTest" type="Node2D" parent="EventBusEvents"] | ||
script = ExtResource( 4 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.