I want to make my items clickable. I know how to make spatials clickabel. How can I get the entity in ES based game? My first thought here was to store the entityid as a userdata in the spatial. as soon as I click it I can get the entity id from spatials userdata if exist and add a new entity with IsClicked component and a Decay component to shortly highlight it with a Highlighting system.
So why ask when I have the solution? Because there is a downside as I have clickable and non clickable spatials but all as entities with position model and so on. I would need to store the the entity in my visual appstate and not for all of them only a subset (items only). So I would end with a maybe two visual systems one for items one for the rest. Or I would have to get the Item component in visuals with ed.getComponent(e, Item.class). Or do think to far and this the way going. Is there a better solution?
Mainly I want to pickup and place items. Click it should show a nice effect. I as well want a hover effect so the player knows that is clickabel. Seems I’m not on a completely wrong path then.
What bothers me is that my visual system display everything with a model, position and rotation. So I have one system to display everything. Now I have query Item.class to know if it is clickable on addEntities. But that Item component is not in the systems entity set, because for displaying it is a) not needed b) would be then only a subset of the visuals. I hope it is understandable what I mean