Mostly for debugging, sometimes i look at a break point and a Entity reference, no knowing what I am even looking at. Having a method that prints out a string array of all types associated with a entity would be pretty good to call in the debugger evaluator.
Another use is to read the interfaces that all types implement so I can build implied behaviours to types, like “IDontDestroy” to “PlantLinkComponentData” and “TreeLinkComponentData” so I know that I must not destroy the a pot with neither a plant nor a tree planted on it without having to manage a list of all types I need to check for.
How:
This would work, but not exactly performant for the second use case, but should work fine for the first one. Technically all I really need for the second one is the type indexes of all of the types, and I can pre compute many lists to match against for all interface types I would want to query for, so if anyone knows a faster way to do it, please tell me.
If multiple types of components can add the DontDestroy IComponentData, then you are in for management hell. You either have to check all components when the components change (to determine if you need to add, remove or retain the DontDestroy component) or when you want to destroy the entity if you are not doing the former. I am also not sure if there is a surefire way to detect arquetype changes to trigger the checking to begin with.
Okey doke, to answer the question more solidly, for debugging you are likely fine with what you have; although, Unity’s debug window should be able to do this now, as you can just look at the entity in the inspector and it shows all the component types already. You can even make custom Inspectors from what I have been informed of.
As for the second, to me it sounds like the routing of the problem is a little iffy. Of course I am not familiar with what you are doing, nor all of your use cases so I am sorry I can’t give you any further information on what you desire, but It sounds like when a plant is in the pot, the pot should not be destroyed yes? You likely could just query all pots without plants (of any component type) that would give you your “destroy-ables”. Again, not really sure of your grand scope.
It would be fine if I could select entities from debugging and that the Editor didn’t freeze up while looking at breakpoints. Many times I am debugging code and all I have is a number and version to figure out what entitiy I am looking at
I am basically attempting to implicitly associate behavior to the existence of a component in a way that multiple components can share the same implicit behavior without me needing to rewrite the same code multiple times.