-
If I'm not missing something, the only way to query Entities is via the presence (or absence) of Components. I find this limitation makes my code a little too loose and harder to read. Let me explain. Say I have a I think it would be nice to be able to do a component like:
And since there are no custom filtering lambdas I can pass over to DefaultECS I'd have to filter the entities myself:
But this "if" would cause a branch divergence as far as I know and I'd lose performance. Also, I realize that maybe it's impractical to implement a filtering functionality within DefaultECS since you'd give up on using spans... unless you manage to create a more complex system of declaring member properties of a component as indexes I think. Am I better off just creating new Components for these "properties" so I can filter my entities or is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can actually query on the component value too using the With(ComponentPredicate) api. Only thing to keep in mind when using it, you need to Notify explicitly (doing an |
Beta Was this translation helpful? Give feedback.
You can actually query on the component value too using the With(ComponentPredicate) api. Only thing to keep in mind when using it, you need to Notify explicitly (doing an
entity.Set(newValue)
does it implicitely, usingentity.Get<T>() = newValue
does not) that the value has changed so the systems can recheck the entity.