#Getting entities out of a query
1 messages · Page 1 of 1 (latest)
you basically need to loop through all entities and check for the value you are looking for.
SharedComponents sort the Entities in different chunks based on the value set in the component. So the query can directly return only those chunks where the first entity in the chunk has the right SharedComponent value. all other entities in that chunk will have the same value.
So if you dont want chunks to be your "search structure" you'll need to implement and maintain your own or brute force iterate over all chunks.
I see, so in otherwords there's not a way to just do a filter that can check a components value simultaneously.
Just make a job that fills NativeList. Should be simple to implement and will be pretty soft on perfomance
@deft orbit Would that work like Creating a native array, passing it through, and having the job somehow collect the entities that meet that criteria?
Have you got any references I could use?
it's just going to be a job
nothing fancy
IJobEntity would do
you pass NativeList or other container of your choice into job
and in Execute just check whether entity fits your criteria
if it does - add
but if you want NativeList to be resizable (you don't know max amount of entities) you'd need Schedule not ScheduleParallel
but do you really need to get the entities out of the job? most of the time you just loop through all entities and do your check e.g. has full growth value? and then do your operation in the same job
resizing is not possible in parallel
yeah, just doing all work in 1 job would definitely be best if it fits your case
and in case you need to get it out maybe nativeStream fits the bill. no headache with sizing it correctly
and writeable in parallel
I have to first collect the entities that match the criteria of having the components on, then I need to get the closest one to an unit and have them then go do work on that object if it's available, otherwise I want to ignore it. I'm already using a job to get the closest one after this which is reused in other areas, but if you're saying it's more efficient to write another job to do that, then that's what I'll do
no, we were saying that merging jobs whenever possible - is better (for perfomance)
Sorry, bad choice of words on my part, but I know what you mean