#What am I doing wrong here??

1 messages · Page 1 of 1 (latest)

leaden zodiac
#
public partial struct CrewMemberMovementSystem : ISystem {
    private EntityQuery crewMembersQuery;

    readonly partial struct CrewMemberAspect : IAspect {
        public readonly Entity Self;
        
        public readonly RefRW<PhysicsVelocity> PhysicsVelocity;
        public readonly RefRW<PhysicsMass> PhysicsMass;
    }

    [BurstCompile]
    public void OnCreate(ref SystemState state) {
        state.RequireForUpdate<CrewMember>();

        crewMembersQuery = new EntityQueryBuilder(Allocator.Persistent)
            .WithAll<CrewMemberAspect, CrewMemberInput>()
            .Build(state.EntityManager);
    }

This gives me the attached error text.

#

🤦 of course right after posting I realized my error. In the entity query you have to use .WithAspect for aspects.

low flax
#

I'd generally advise against aspects, as they are meant to be deprecated in 2.0, and imo - they barely provide any benefit in most cases (boilerplate is worse with them)

low flax
leaden zodiac
low flax
#

ref state

leaden zodiac
#

isn't that what I'm using?

#

state.EntityManager

low flax
#

That's EntityManager, not system state

leaden zodiac
#

Build() doesn't like the SystemState itself afaik

low flax
#

It does

leaden zodiac
low flax
#

ref

leaden zodiac
#

Wouldn't that only be for a managed system?

#

oh

#

indeed that works... but I'm confused because that doesn't seem to match either of those suggested candidates from my error

#

Indeed it exists... I feel like Rider did me dirty here

#

what are the bad consequences of using state.EntityManager?

#
        crewMembersQuery = state.GetEntityQuery(new EntityQueryBuilder(Allocator.Persistent)
            .WithAspect<CrewMemberAspect>()
            .WithAll<CrewMemberInput>());```
This looks to work as well. Is this preferred?
low flax
#

EntityQueryBuilder is preferred

#

your API is like what was used in past

#

but got obsolete, except some APi that just reuses EQB now

leaden zodiac
low flax
#

yes, but this whole API is like rudimental

#

either way

#

it's same thing

#

if you just look in code

leaden zodiac
#

ok so new ECB().Blah().Blah().Build(ref state) is the preffered way?

low flax
#

point is: query created by system belongs to system and disposed with it, as well as registers all necessary dependencies

#

query created by EntityManager belongs to world

leaden zodiac
#

I see

low flax
#

latter are mostly used only for debug UI

#

like Entity inspectors and such

leaden zodiac
low flax
#

EntityManager is same across whole world

#

it's like