-
Notifications
You must be signed in to change notification settings - Fork 437
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
refactor EntitySystem proxy into its own class, give proxy to BUIs #5561
base: master
Are you sure you want to change the base?
Conversation
unless this could cause performance issues somehow pls merge 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not a fan of this approach. If BUIs need to be able to access these, I think it would be better if BUIs somehow became a subtype of EntitySystem
instead.
not just buis need this, things like entity effects are ugly because they cant use proxy |
Aren't those also things that really should be entity systems instead? |
There's been a few other instances where I've wished that a non-system class had access to the same helper/proxy methods without having to re-write all of them. E.g., all the helper methods in Making things systems wherever possible (or I guess in the case of toolshed commands, allowing systems to easily turn methods into commands) is probably a better approach, but wouldn't help with some cases, like integration tests. Maybe a better approach would be some kinda source generator? So that you can take any class that has an entity manager field, make it partial, and auto-generate the proxy methods? That way you'd still only need to write them once, but you also wouldn't need everything to inherit from the same base class. |
that would be ideal but:
|
I'm not very familiar with source generators either, but there already are some in the project that could be a starting point if you want to learn (though I have no idea if they're good examples). E.g.,
Again, not all that familiar with source generators, but I assume it'd just be equivalent to writing out the code, so it shouldn't bloat it? To be clear, it definitely shouldn't generate the methods for each and every system class, only the base system class and likewise for other types. |
Yeah source gens would probably be the best choice here. Furthermore, since this would be a pretty simple generator, it should have completely negligible compiler performance impact. |
EntManProxy
, and moved RaiseLocalEvent etc to it as wellTryComp
and stuff in BUIsIoCManager.InjectDependencies(this);
and it just works, as long as there is no other parent class. BUI and EntitySystem had no base class so it works for themno breaking changes, BUI still has EntMan to get the entity manager so code doesnt need changing