Specifying components required by a component in Zay-ES

In some entity systems components are allowed to specify “required” components. Depending on the implementation model, either that component automatically adds the required ones, or an error is generated, notifying us of the absence of the required components. Is there any similar feature in Zay-ES?

I don’t understand the requirement and without a specific use-case it’s tough to address. Many other ES frameworks do a dozen other things wrong which leads them to do other sometimes screwy things to make up for it… so it’s hard to say here.

But components depending on other components sounds like unnecessary coupling to me. Why are they separate components in the first place?

In general, components should be 100% independent of one another because it’s entirely up to the systems how they are used (together or not).

1 Like

My approach here is simple: be practical. This way you will get information that immediately touches your problem instead of some abstract thinking like ”ok this could work, and this would not”

1 Like

To illustrate the question better, here is the link and another link. I too do not think that this feature is very important or good for the code, but just decided to ask, since I spend some time in Unity3D on my job and that issue seemed interesting to me. More theoretically.

A very good advice indeed! :slight_smile:

Not being an expert in Unity I could say that specifying requirements on logic level is a bad habit that means you’re about to lose control of your logic mechanics.Which means your design isn’t clear and you have to redo certain places of it.

Since I’ve played a bit with Unity I can join on this. I developed many components to myself and never used this required annotation. IMO its usefull only when you develop complex Unity plugins and you want to have sure you users won’t get lost by missing a component dependency.

Its possible to develop something like it, but I think our lovely developers and contributors may spend their valuable time on more important features.

Ah, well, see… this is completely different than what you asked, actually. This isn’t some component requiring another component… it’s a way to annotate a game object as requiring a component.

Still, in Zay-ES terms (and pure ES terms) this doesn’t really have any meaning the way that they do it. It’s something that would operate at a higher level… say if your game or environment allowed plugins. You might want to annotate the plugin as requiring some component type so that you knew the game even used it. But to me that’s a plugin->plugin dependency.

Else, a system will ask for entities with some set of components and it will either get some or it won’t… but not getting some might be a transient state. There’s nothing really to check the annotation against.

1 Like

Actually you can easily do this (in development).

A system with a map of entityid to requiredcomponents
and it requests just all components there are, and check against this map.
So if you create a Whatever just tell your system what components it needs, and the system will do the check the next update automatically.

Then for productive just disable the system. (performance might suffer quite a bit, due to requesting everything for every entity)

1 Like