using DCFApixels.DragonECS.Core; using DCFApixels.DragonECS.PoolsCore; namespace DCFApixels.DragonECS { public partial class EcsWorld { internal readonly struct PoolCache : IEcsWorldComponent> where T : IEcsPoolImplementation, new() { public readonly T Instance; public PoolCache(T instance) { Instance = instance; } void IEcsWorldComponent>.Init(ref PoolCache component, EcsWorld world) { component = new PoolCache(world.CreatePool()); } void IEcsWorldComponent>.OnDestroy(ref PoolCache component, EcsWorld world) { component = default; } } internal readonly struct AspectCache : IEcsWorldComponent> where T : EcsAspect, new() { public readonly T Instance; public AspectCache(T instance) { Instance = instance; } void IEcsWorldComponent>.Init(ref AspectCache component, EcsWorld world) { component = new AspectCache(EcsAspect.Builder.New(world)); } void IEcsWorldComponent>.OnDestroy(ref AspectCache component, EcsWorld world) { component = default; } } internal readonly struct WhereQueryCache : IEcsWorldComponent> where TExecutor : MaskQueryExecutor, new() where TAspcet : EcsAspect, new() { public readonly TExecutor Executor; public readonly TAspcet Aspcet; public WhereQueryCache(TExecutor executor, TAspcet aspcet) { Executor = executor; Aspcet = aspcet; } void IEcsWorldComponent>.Init(ref WhereQueryCache component, EcsWorld world) { TAspcet aspect = world.GetAspect(); TExecutor instance = world.GetExecutorForMask(aspect.Mask); instance.Initialize(world, aspect.Mask); component = new WhereQueryCache(instance, aspect); } void IEcsWorldComponent>.OnDestroy(ref WhereQueryCache component, EcsWorld world) { component = default; } } } }