In order to be able to use Events you can just create a new Type that inherits from Neuron.Core.Events.Listener and add an Automatic Attribute to the Type
An instance of this Type will now be created between the Loading and Enabling of your Plugin/Module.
How can I now hook the Events?
Well it's really simple just create a public void Method and use as arguments the Parameters for the Event you want to use and also mark the Method with the EventHandlerAttribute
usingNeuron.Core.Events;usingNeuron.Core.Meta;usingSynapse3.SynapseModule.Events;namespaceDocsExample;[Automatic]publicclassEventHandlers:Listener{ [EventHandler] //The Method must be publicpublicvoidOnRoundStart(RoundStartEvent ev) { //The code inside this method will now be excuted when the Round Starts //You can use ev to get more information about the specific event //However in this case the Round Start event doesn't have any additional informtaion }}
Manually subscribing
In some cases you want to subscribe manually to an event and this is also possible with Synapse3: You just have to get the proper EventService that contains the Event you wan't to hook and call the Subscribe Method of the Event
usingNeuron.Core.Events;usingNeuron.Core.Meta;usingSynapse3.SynapseModule.Events;namespaceDocsExample;[Automatic]publicclassEventHandlers:Listener{publicEventHandlers(ItemEvents itemEvents) { //This will subscribe the method //This can be used everywhere, the method must not be inside a ListeneritemEvents.ConsumeItem.Subscribe(OnConsumeItem); } //Since you are subscribing manually can the method be privateprivatevoidOnConsumeItem(ConsumeItemEvent ev) { } [EventHandler] //But it needs to be public if it is automatically subscribed topublicvoidOnRoundStart(RoundStartEvent ev) { }}
Multiple Events
Many Event Arguments inherits the same common Type which means you can use this Type as argument inside your method and hook multiple Events to the same method