2023-12-20 23:21:10 +08:00
|
|
|
|
namespace DCFApixels.DragonECS
|
2023-06-27 05:09:41 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
public partial class EcsWorld
|
2023-06-27 05:09:41 +08:00
|
|
|
|
{
|
2023-06-27 05:30:45 +08:00
|
|
|
|
internal readonly struct PoolCache<T> : IEcsWorldComponent<PoolCache<T>>
|
|
|
|
|
where T : IEcsPoolImplementation, new()
|
2023-06-27 05:09:41 +08:00
|
|
|
|
{
|
2023-06-27 05:30:45 +08:00
|
|
|
|
public readonly T instance;
|
|
|
|
|
public PoolCache(T instance) => this.instance = instance;
|
|
|
|
|
void IEcsWorldComponent<PoolCache<T>>.Init(ref PoolCache<T> component, EcsWorld world)
|
2023-06-27 05:09:41 +08:00
|
|
|
|
{
|
2023-06-27 05:30:45 +08:00
|
|
|
|
component = new PoolCache<T>(world.CreatePool<T>());
|
2023-06-27 05:09:41 +08:00
|
|
|
|
}
|
2023-06-27 05:30:45 +08:00
|
|
|
|
void IEcsWorldComponent<PoolCache<T>>.OnDestroy(ref PoolCache<T> component, EcsWorld world)
|
2023-06-27 05:09:41 +08:00
|
|
|
|
{
|
|
|
|
|
component = default;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-27 05:30:45 +08:00
|
|
|
|
internal readonly struct AspectCache<T> : IEcsWorldComponent<AspectCache<T>>
|
|
|
|
|
where T : EcsAspect
|
|
|
|
|
{
|
|
|
|
|
public readonly T instance;
|
|
|
|
|
public AspectCache(T instance) => this.instance = instance;
|
|
|
|
|
void IEcsWorldComponent<AspectCache<T>>.Init(ref AspectCache<T> component, EcsWorld world)
|
|
|
|
|
{
|
2024-01-07 19:32:16 +08:00
|
|
|
|
component = new AspectCache<T>(EcsAspect.Builder.New<T>(world));
|
2023-06-27 05:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
void IEcsWorldComponent<AspectCache<T>>.OnDestroy(ref AspectCache<T> component, EcsWorld world)
|
|
|
|
|
{
|
|
|
|
|
component = default;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
internal readonly struct ExcecutorCache<T> : IEcsWorldComponent<ExcecutorCache<T>>
|
|
|
|
|
where T : EcsQueryExecutor, new()
|
|
|
|
|
{
|
|
|
|
|
public readonly T instance;
|
|
|
|
|
public ExcecutorCache(T instance) => this.instance = instance;
|
|
|
|
|
void IEcsWorldComponent<ExcecutorCache<T>>.Init(ref ExcecutorCache<T> component, EcsWorld world)
|
|
|
|
|
{
|
|
|
|
|
T instance = new T();
|
|
|
|
|
instance.Initialize(world);
|
|
|
|
|
component = new ExcecutorCache<T>(instance);
|
|
|
|
|
}
|
|
|
|
|
void IEcsWorldComponent<ExcecutorCache<T>>.OnDestroy(ref ExcecutorCache<T> component, EcsWorld world)
|
|
|
|
|
{
|
|
|
|
|
component = default;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-27 05:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|