DoopelPonger
|
An event system is used for several unrelated components to send data to eachother. More...
Classes | |
class | CameraFadeOutParameters |
Parameters to give to listeners of the camera fade out event. More... | |
class | CameraShakeParameters |
Parameters to give listeners of the camera shake event. More... | |
class | ChangeTimeParameters |
Parameters to give listeners of the time change event. More... | |
class | CoopHealPlayerParameters |
Parameters to give to listeners of the heal players event. More... | |
class | CoopMusicChangeParameters |
Parameters to give to listenerrs of the change music event. More... | |
class | CoopPlayerChargeParameters |
Parameters to give to listeners of the player power up charge increase event. More... | |
class | CoopPlayerDeadParameters |
Parameters to give to listeners of the player death event. More... | |
class | CoopPlayerGoodHitParameters |
Parameters to give to listeners of the event emitted when a player gets hit by a good ball. More... | |
class | CoopPlayerHitParameters |
Parameters to give to listeners of the event emitted when a player gets hit by a bad ball. More... | |
class | CoopPlayerShieldDeflectParameters |
Parameters to give to listeners of the event emitted when a ball is deflected off a player's shield. More... | |
class | CoopPlayerSpawnedParameters |
Parameters to give to listeners of the player spawned event. More... | |
class | CoopPowerUpFinishedParameters |
Parameters to give to listeners of the player's power up running out event. More... | |
class | CoopPowerUpTriggeredParameters |
Parameters to give to listeners of the player's power up triggered event. More... | |
class | CoopStartGameParameters |
Parameters to give to listeners of the game starting event. More... | |
class | EventManager |
Orchestrates the publishing, receiving, registering and deregistering events and even listeners. More... | |
class | MenuBackgroundParameters |
Parameters to give to listeners of the event to enable/disable the background pong game in the main menu. More... | |
class | MenuTutorialParameters |
Parameters to give to listeners of the tutorial start event. More... | |
class | SubmenuBackParameters |
Parameters used to send to listeners of the event for switching back from a submenu like single player in the main menu. More... | |
An event system is used for several unrelated components to send data to eachother.
When several components need to comunicate information to eachother the EventManager is used. When publishing events, the publisher needs to provide two pieces of information: the type for the event and the parameters. The type must be defined in the EventType enum and the parameters must be of type EventParameters. To add a bit of strong typing to the events, the typeMapping exists which defines what type of EventParameters should be sent with the EventType. To receive an event, the RegisterListener method should be called with the EventType and the function that will be called when the EventType is published. The EventTypes can have as many listeners as possible to be notified when the event is triggered. Looking back, this could be rewritten with the parameters for the events being a template instead of the type EventParameters. In theory this could add overhead to compilation time but reduce the amount of configuration needed in this class to send events. There are two types of registering/deregistering event types: register immediately and register. Registering/deregistering immediately will update the list of listeners for the event in the function call while using the normal register method will queue up the register/deregister and only modify the list of listeners on the next FixedUpdate tick. The reason for the queue is that there if one is iterating through the list of listeners for an event and that list gets modified, C# will throw an exception saying you can't modify and iterate a list at the same time. So to keep iterations safe one should rarely call register/deregister immmediately.