-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why Event<> in the interface? #4
Comments
Hi! The idea here is that an event can be both triggered from the caller (like a method), but also subscribed to. So for example, a listener could be interested in knowing when another IInteractable was hovered, and a method does not allow this. In the ideal world, this access control would be better — the component should be able to explicitly define whether an event can be subscribed externally, or published externally, or both. This is something I've been working on in my own private fork of GoCS for our game project and it's working quite well. Down the line, I'll probably update GoCS with this approach. |
I humbly submit https://github.com/RealityStop/gocs as a stopgap until the new official version of GoCS arrives. I felt the same need for directionality in Events, so I made a few alterations. It adds: Arguably, there is little benefit to the IHandledEvent over a method (Perhaps the ability to have a null event to signal that it isn't supported vs an empty no-op method or a predicate syntax). However, IEmittedEvent is exceptionally useful, and correctly signals that the event is not listened to by the component. For me, this is desirable because they are reaction points for systems, particularly when mixed with some OOP code. In my little project, a creature's AI is running on the instance, even if the individual aspects such as movement are handled via Systems. Thus, when the creature AI directs it to (for example) enter its den, I need my Systems to be able to react to that Event. And that's a fundamentally different Event style than the regular System-dispatched (IHandledEvent) Events. |
Hi,
a question regarding design of component interfaces: why do interfaces expose Event(s) instead of explicitly declaring a method?
say why:
instead of:
The text was updated successfully, but these errors were encountered: