#Pass dynamic count of `DynamicComponentTypeHandle` into job

1 messages · Page 1 of 1 (latest)

regal junco
#

Since unity prevents using nested native containers I wonder what should I do if I need to pass arbitrary count of arbitrary type handle into job.

I want to do so because I want to test list of chunks if they have components, which types I get during runtime

cursive lance
#

Oh I had this exact issue, I wanted to pass in N number of dynamic type handles

#

I can't remember how I solved it, I think I wrote something custom

#

I'll try find it when I get to a pc

#

That said maybe for your problem masks are better?

regal junco
rapid briar
#

you could use the typeindex, maybe?

#

depending what you're trying to do with the info

regal junco
#

@rapid briar I'm using chunk.Has(ref DynamicComponentTypeHandle) to check if I have any chunks with wrong component setup

rapid briar
#

couldn't you do chunk.Archetype.GetComponentTypes

regal junco
cursive lance
#

anyway i'm at pc, let me see if i ended up finding a solution for myself for this or just did it a different way, i don't recall what code i wanted this for

regal junco
cursive lance
#

fast way to know if an entity matches multiple components

#

but yeah it's not really suitable here because it's for entities not chunks

#

but if you had somehting like
HasComponent<A> && HasComponent<B> && HasComponent<C>

#

you can replace it with a mask of abc and do it in a single check

#

Mask.Matches(entity)

#

oh wait i'm wrong

#

you can use EntityQueryMask on chunks

regal junco
#

is it any more optimal then one by one checking or just syntax thing?

cursive lance
#

so you could use this if you wanted to match X components

cursive lance
#

so i guess question is, are you trying to match every component?

regal junco
#

will remember, thank you, useful thing for complex growing logic

regal junco
cursive lance
#

you don't need to

#

you can generate a entityquery dynamically

#

and generate the mask from that and pass it into the j ob

regal junco
#

oh ok, but still want to check per chunk

cursive lance
#

you can

regal junco
#

hmm, will check, thank you

cursive lance
#
        [BurstCompile]
        private struct TestJob : IJobChunk
        {
            public EntityQueryMask Mask;

            public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
            {
                if (!Mask.MatchesIgnoreFilter(chunk))
                {
                    return;
                }
            }```
#

state.GetEntityQuery(GetComponentTypes()).GetEntityQueryMask()

#

can use builder etc

regal junco
#

🙏

cursive lance
#

but basically just create a query from components or whatever you want to match

#

you can use None/Any/WithAll etc as well via description

#

you're just checking if the chunk matches the query

regal junco
#

Thank you a lot! One another my issue solved with your advice 🤝