dominion-dev / dominion-ecs-java

Insanely fast ECS (Entity Component System) for Java
https://dominion-dev.github.io
MIT License
288 stars 17 forks source link

Add Ability to Retrieve All Entities #163

Closed KShizuko closed 1 year ago

KShizuko commented 1 year ago

Description

Would it be possible to add an option to the API to retrieve all entities?

I am currently using a workaround where I add a dummy component to all entities and then just do:

dominion.findEntitiesWith(FillerComponent.class).iterator();

And then just iterate through it to get a list of all my entities, while it works, it would be nicer if I did not have to add a dummy component.

Use case

I wanted to fetch all entities for a debug menu so that I could implement a GUI where I can just click to select an entity from the list to add or remove a component from UI during testing. This is a lot faster than having to make all component changes programmatically.

enricostara commented 1 year ago

Hi @Kureika , please check new Dominion.findAllEntities and let me know

enricostara commented 1 year ago

This change was included in the new RC2

KShizuko commented 1 year ago

Apologies about the delay, I started testing it yesterday but I was having some really odd problems and I was not sure if it was just me or a bug, I am still not sure as I have not had the time to check it today.

For reference, I was just replacing instances of dominion.findEntitiesWith(FillerComponent.class).iterator(); with dominion.findAllEntities().iterator(); on the assumption it would give me the exact same results, and it even works for most of my test scenes, just that for 1 particular scene it only returns 3 out 5 entities and I am trying to figure out if I have a bug somewhere.

I reckon your changes are fine, just that some of my logic is bugged, need to debug it a bit more.

If it does end up being something with findAllEntities(), I will raise another issue.

enricostara commented 1 year ago

Thanks a lot for your feedback! Let me know and yes, please rise a new issue if you feel something is still wrong ☺️