This is a simple Event System and Event Dispatcher written in C# with DotNetCore 6.0.
- To understand how one would work.
- To learn C# before my OOP III class (which is in C#).
- As a reference for future work/game development.
- As a challenge
- Create custom events which can include methods and values
- Call methods from outer-scope with the Observer design pattern (Event System)
- Manage event listener
- Dispatch events to the correct callback
- Sorting events with filters
- Clearing events of specific type
- Events queuing
- Delaying events
- EventSystem.cs class manages listeners.
- EventDispatcher.cs dispatches events to the right callback for listener classes.
- Event.cs is an abstract class every custom events needs to inherit from.
- IEventListener is and interface every event listener class needs to implement.
See the Calculator example in the App project. In this example, there's a basic calculator calling and an event depending on the operator is selected. Once the event is done, the calculator will be notified. The dispatcher will call the right callback depending on the event type. See the DivisionEvent to see the impact of the EventSystem class, since the DivisionEvent also calls a function in the TestClass, to show how the subscribe system allows for multiple listeners for the same event type.
Feel free to contribute if you have refactors or ideas in mind.
I would like to add a queue system and a filter system. Though I do not think I'll comeback to this small project as school will takeover all my free time.