#IEnableableComponent use case?

1 messages · Page 1 of 1 (latest)

terse flax
#

I have only very vague and shallow understanding of it. in docs it states its ideal for high-frequency state changes.
As far as I understand there to little to none of a performance impact of this vs simple bool flag, BUT it have nice query support where disabled component is ignored by query ootb.
Also it does not trigger structural changes. So effectively it can change query results without structural changes. So I wonder how good of an impact it have than?
If any one already know and/or have their conclusion it would save me a bit of time trying to profile it 👉👈.

Case for now that I want to try out is having entities entering a state of "Hungry" and instead of attaching, removing component data related to it or keep it on but have additional check in systems, they would just have EnablableHungerComponentData (temp working name).

So the thing is that I plan to have large number of entities that can enter this state, but on its self it not like very frequent... and also its unlikely for many entities to enter it at exactly same frame so it does not seems to be fit for batching. each entity might get hungry after some interval but in reality we can satisfy hunger of one entity at a time... of course there might be situation where 2 entities eat two different pieces of feed at same moment but it will be even more unlikely once there is actually lots of entities because there will be only one source of feed and its spawn rate will be limited by player input.

So I am not sure what frequency is considered high-frequency, I think? in context of dots I feel like they would mean a REALLY HIGH-frequency and in my case it might not have an impact?

Since I am at it... how does it work with Aspects? just wonder... might just try it and figure it out...

terse flax
#

Also Other case I wonder about is like pooling system, but I heard that pooling is not recommended with ecs since its cheep to batch instantiate / destroy entities.
But similar like with hunger case entities in my game will not die or be spawned at batches but 98% of case it will be one at a time. user will need to click on button to spawn single entity etc...

true beacon
#

i'm not on my pc right now, but you can read this thread
we went through pooling, creating, and enabling components in unity ecs

the main takeaway is to never pool entities
use state.EntityManager to create and destroy a large or not so much number of entities
use IEnableComponents for things not exposed to third parties like physics, etc

if that's not enough, give me some time and i can cook a better answer

https://discord.com/channels/489222168727519232/1391856804862103674

terse flax