Replies: 1 comment 5 replies
-
I've seen this difficulty come up before in input, UI and external integrations before: both of them tend to push first-pass designs towards massive monolithic systems that, like you point out, are hard to reason about or refactor. In a fully ECS-integrated design, I would:
Because you're only reading from the resource that contains It looks like the "which button did I press" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have noticed a tendency for my systems to accumulate more and more parameters as a project grows. Most of the time, it is not too hard to refactor a system into two or more systems and distribute the parameters between them. This seems like a good thing since it makes the design of the app cleaner.
However, I have come across a situation where I don't know how refactor my system. I have a system that uses
bevy_egui
to make a window with a bunch of buttons that modify the state of my application in various ways for testing purposes. I use events to dispatch button clicks to other systems that do actual work, the GUI system just draws the window and the buttons and sends out events. Every button fires a different event type and I end up with anEventWriter
parameter for each of them. Clippy is complaining and it's hard to disagree.I have considered some alternatives such as packing my event types into an enum or using a global resource with change detection instead of events to hook up the buttons to corresponding systems. But these seem like workarounds that just introduce different types of problems instead. Ideally, I think I would like
EventWriter
to be a non-generic type that instead has a genericsend
method since then I could have just one writer for all my event types (EventReader
would still be generic). But that's not how bevy events are designed and I'm out of ideas.I would welcome any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions