#Aspect, what is the point ?

1 messages · Page 1 of 1 (latest)

hexed silo
#

All in the question. What is the actual point of aspect ?

I keep seeing that it's powerfull but no real example of how I can leverage it in my codebase.

Any ideas ?

woeful widget
#

basically saves time as you can implement logic in your aspect, use it (in IJobEntity jobs) without needing to get a whole bunch of components and do double work

#

you can also nest them

hexed silo
#

Could that replace a static helper class so instead of :

public static void UpdateSomething(
            Entity entity,
            ref A a,
            ref B b,
            ref C c,
            ref D d,
            ref E e,
            ref F f,
            ref SystemState state) {
            // Do something with abcdef
        }

This could be done :

public readonly partial struct FactoryStateAspect : IAspect
    {
        public readonly RefRW<A> A;
        public readonly RefRW<B> B;
        public readonly RefRW<c> C;
        public readonly RefRW<D> D;
        public readonly RefRW<E> E;
        public readonly RefRW<F> F;

        public void DoSomething()
        {
            // Do something with abcdef ?
        }

        public readonly Entity Self;
    }
#

Or am I getting it wrong here ?

#

and is it burst compatible ?

woeful widget
#

yeah burst compat
then you just have a job like

[BurstCompile]
partial struct MyCoalFactoryProducingJob : IJobEntity 
{
    public void Execute(FactoryStateAspect factoryAspect, ref LocalTransform transform)
    {
        //etc
    }
woven quartz
#

I personally see aspects as something that never should have been introduced

#

Their benefit is that you can make helper methods for combination of components, but that just goes against ecs

#

My only real use case is that they allow avoiding some bugs with codegen 😅

wooden gyro
#

i only have 1 aspect and it's just grouping 2 dynamic buffers to save myself writing code

#

i would find them more useful if they fixed some of their limitations

#

(buffers could be optional, marked [readonly] etc)

hexed silo
#

that's what I thought too , thanks for confirming