-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50ea7ae
commit 03c90ce
Showing
34 changed files
with
180 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using Hypercube.Client.Graphics.Windows; | ||
using Hypercube.Shared.EventBus.Events.Events; | ||
|
||
namespace Hypercube.Client.Graphics.Event; | ||
|
||
public readonly struct WindowClosedEvent(WindowRegistration registration) | ||
public readonly struct WindowClosedEvent(WindowRegistration registration) : IEventArgs | ||
{ | ||
public readonly WindowRegistration Registration = registration; | ||
} |
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,5 +1,6 @@ | ||
using Hypercube.Client.Graphics.Windows; | ||
using Hypercube.Shared.EventBus.Events.Events; | ||
|
||
namespace Hypercube.Client.Graphics.Event; | ||
|
||
public readonly record struct WindowFocusChangedEvent(WindowRegistration Registration, bool Focused); | ||
public readonly record struct WindowFocusChangedEvent(WindowRegistration Registration, bool Focused) : IEventArgs; |
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
3 changes: 2 additions & 1 deletion
3
Hypercube.Shared/Entities/Realisation/Events/ComponentAdded.cs
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,5 +1,6 @@ | ||
using Hypercube.Shared.Entities.Realisation.Components; | ||
using Hypercube.Shared.EventBus.Events.Events; | ||
|
||
namespace Hypercube.Shared.Entities.Realisation.Events; | ||
|
||
public readonly record struct ComponentAdded(EntityUid EntityUid, IComponent Component); | ||
public readonly record struct ComponentAdded(EntityUid EntityUid, IComponent Component) : IEventArgs; |
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,3 +1,5 @@ | ||
namespace Hypercube.Shared.Entities.Realisation.Events; | ||
using Hypercube.Shared.EventBus.Events.Events; | ||
|
||
public readonly record struct EntityAdded(EntityUid EntityUid); | ||
namespace Hypercube.Shared.Entities.Realisation.Events; | ||
|
||
public readonly record struct EntityAdded(EntityUid EntityUid) : IEventArgs; |
6 changes: 4 additions & 2 deletions
6
Hypercube.Shared/Entities/Realisation/Events/EntityRemoved.cs
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,3 +1,5 @@ | ||
namespace Hypercube.Shared.Entities.Realisation.Events; | ||
using Hypercube.Shared.EventBus.Events.Events; | ||
|
||
public readonly record struct EntityRemoved(EntityUid EntityUid); | ||
namespace Hypercube.Shared.Entities.Realisation.Events; | ||
|
||
public readonly record struct EntityRemoved(EntityUid EntityUid) : IEventArgs; |
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
4 changes: 3 additions & 1 deletion
4
Hypercube.Shared/EventBus/Events/Broadcast/BroadcastRegistration.cs
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
using Hypercube.Shared.EventBus.Events.Broadcast; | ||
|
||
namespace Hypercube.Shared.EventBus.Events; | ||
|
||
/// <summary> | ||
/// Saves information about a specific event. | ||
/// </summary> | ||
public readonly struct EventRegistration() | ||
{ | ||
private readonly HashSet<BroadcastRegistration> _broadcastRegistrations = new(); | ||
|
||
public IReadOnlySet<BroadcastRegistration> BroadcastRegistrations => _broadcastRegistrations; | ||
|
||
/// <exception cref="InvalidOperationException"></exception> | ||
public void Add(BroadcastRegistration registration) | ||
{ | ||
if (_broadcastRegistrations.Contains(registration)) | ||
throw new InvalidOperationException(); | ||
|
||
_broadcastRegistrations.Add(registration); | ||
} | ||
|
||
/// <exception cref="InvalidOperationException"></exception> | ||
public void Remove(BroadcastRegistration registration) | ||
{ | ||
if (!_broadcastRegistrations.Contains(registration)) | ||
throw new InvalidOperationException(); | ||
|
||
_broadcastRegistrations.Remove(registration); | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
...cube.Shared/EventBus/Events/IEventArgs.cs → ...Bus/Events/Events/CancellableEventArgs.cs
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,3 @@ | ||
namespace Hypercube.Shared.EventBus.Events.Events; | ||
|
||
public abstract class EventArgs : IEventArgs; |
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,3 @@ | ||
namespace Hypercube.Shared.EventBus.Events.Events; | ||
|
||
public interface IEventArgs; |
4 changes: 4 additions & 0 deletions
4
Hypercube.Shared/EventBus/Events/Exceptions/UnregisteredEventException.cs
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,4 @@ | ||
namespace Hypercube.Shared.EventBus.Events.Exceptions; | ||
|
||
public sealed class UnregisteredEventException(Type registrationType) : | ||
Exception($"Attempted to resolve unregistered event {registrationType.FullName}."); |
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,3 @@ | ||
namespace Hypercube.Shared.EventBus.Events.Handlers; | ||
|
||
public delegate void EventRefHandler<T>(ref T ev); |
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,3 @@ | ||
namespace Hypercube.Shared.EventBus.Events.Handlers; | ||
|
||
public delegate void RefHandler(ref Unit ev); |
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.