librelist archives

« back to archive

Establishing Dependencies

Establishing Dependencies

From:
ryan alexander
Date:
2014-08-11 @ 06:43
Hi! I just picked up EntityX. It looks nice so far!

I'm curious about where you'd suggest setting up dependencies. It seems
like Systems should be able to specify deps for their own Components, but
they do not have access to the SystemManager. The example seems to suggest
that you'd do this wherever the SystemManager is defined, which seems like
it would require the user of a System / Component to know and reiterate its
deps. Alternatively, I could pass the SystemManager to the System's
constructor, but that seems like a kludge.

Where do you normally set up these relationships?

Any insight would be appreciated! :)

ryan

# Ryan Alexander
# http://onecm.com

Re: [entityx] Establishing Dependencies

From:
Alec Thomas
Date:
2014-08-11 @ 07:03
Hi Ryan,  

While it may be more “correct” to have systems define dependencies in 
isolation, it’s less efficient because each dependency creates a new 
receiver for ComponentAddedEvents. If you have partially overlapping 
dependencies, you’ll create redundant listeners.

Truthfully, the deps code is most useful as an example. For a truly 
efficient implementation you’d want a single DepsSystem with one 
ComponentAddedEvent receiver, that you add dependencies to. You could then
pass this to your System’s constructor.

Alec  


On Monday, 11 August 2014 at 4:43 pm, ryan alexander wrote:

> Hi! I just picked up EntityX. It looks nice so far!
>  
> I'm curious about where you'd suggest setting up dependencies. It seems 
like Systems should be able to specify deps for their own Components, but 
they do not have access to the SystemManager. The example seems to suggest
that you'd do this wherever the SystemManager is defined, which seems like
it would require the user of a System / Component to know and reiterate 
its deps. Alternatively, I could pass the SystemManager to the System's 
constructor, but that seems like a kludge.
>  
> Where do you normally set up these relationships?
>  
> Any insight would be appreciated! :)
>  
> ryan
>  
> # Ryan Alexander
> # http://onecm.com