#Getting entities out of a query

1 messages · Page 1 of 1 (latest)

forest granite
#

... that have a component value that is not a shared component's value. IE getting all entities in the world that have full growth value. I essentially want to do the same kind of search as the SetSharedComponentFilter, but without it.

I've been scrounging the forums I just don't fully understand where this kind of search is

fickle gale
#

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.

forest granite
#

I see, so in otherwords there's not a way to just do a filter that can check a components value simultaneously.

fickle gale
#

yep

#

the only thing you could use in filters is enable components to filter for bits

deft orbit
#

Just make a job that fills NativeList. Should be simple to implement and will be pretty soft on perfomance

forest granite
#

@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?

deft orbit
#

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

fickle gale
#

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

deft orbit
#

resizing is not possible in parallel

#

yeah, just doing all work in 1 job would definitely be best if it fits your case

fickle gale
#

and in case you need to get it out maybe nativeStream fits the bill. no headache with sizing it correctly

#

and writeable in parallel

forest granite
#

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

deft orbit
#

no, we were saying that merging jobs whenever possible - is better (for perfomance)

forest granite
#

Sorry, bad choice of words on my part, but I know what you mean