-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Require components that can't be defaulted #16194
Comments
I much prefer non-defaulted required components over using archetype invariants to resolve this problem. |
As much as this would be nice to have, I don't think it's something possible to do without some kind of const-comparable |
After implementing #16209, I feel dissatisfied with my own solution. Because of how dynamic we are allowed to be (you can register required components at runtime), the only valid solution AFAIK is just panicking at runtime. This basically seems like worse archetype invariants to me. |
Yeah, the transitive and dynamic nature of required components makes this quite hard to use effectively. |
@alice-i-cecile, thoughts on just closing this and the PR and just waiting for archetype invariants? |
I think I'm in favor of closing this, yeah. I don't see any good way to handle the non-trivial / ecosystem implications, and any full, thoroughly designed solutions feels more in line with a complete archetype invariants design (#1481, for those who are out of the loop). |
What problem does this solve or what need does it fill?
Today, a required component either needs to impl
Default
or needs to have an explicit constructor function passed in. This is problematic for components which require some initial state. Consider the following setup:I want to say that an enemy needs to be inserted with a target, but a defaulted target doesn't really make sense and
Entity
doesn't even implDefault
.What solution would you like?
require
should be able to not use a constructor at all and just require that the bundle inserts the component. Perhaps this could be done with a keyword like#[require(EnemyTarget(explicit))]
to say that a component must be explicitly inserted and will fail (at compile time) otherwise.This would severely decrease the remaining need for bundles.
One downside is that you can still break this invariant by explicitly removing one of the components after the fact, but that is already true.
What alternative(s) have you considered?
Wait for archetype invariants. This would unfortunately mean problems would be detected at runtime.
The text was updated successfully, but these errors were encountered: