KKMMMTTT / AstroSoar

0 stars 0 forks source link

[#9] Event Parameters #12

Closed MatthewChrobak closed 4 years ago

MatthewChrobak commented 4 years ago

Closes #9

With these changes, events can now be defined as classes.

public class YourEvent : CustomEvent
{
    private readonly object _parameters;

    public YourEvent(object parameters, string eventID, int interval, int delay) : base(eventID, interval, delay) {
        this._parameters = parameters;
    }

    protected override void Run(EventArgs args) {
        // Event logic
    }
}

and can still be added in a similar fashion.

ServiceProvider.EventService.AddEvent(PriorityType.LOGIC, new YourEvent(new object(), "", 100, 0));
MatthewChrobak commented 4 years ago

Same comment as @MatthewTeolis, and quick question about the concept of events in Annex - I saw that there are various types of events, from sounds to graphics, etc. Does this mean that the scope for events are meant to be atomic and specific for conventional use?

Events are indeed atomic. The event queues are managed by a single thread, and thus, each event is run in isolation. I've toyed around with event groups that would allow for parallel execution, but it is currently not implemented.

I'm not sure what is meant by 'specific for conventional use'. Feel free to ping me and we can discuss this further (: