using System.Collections.Generic; namespace DCFApixels.DragonECS { [DebugHide, DebugColor(DebugColor.Black)] public class SystemsBlockMarkerSystem : IEcsSystem { public readonly string name; public SystemsBlockMarkerSystem(string name) { this.name = name; } } [DebugHide, DebugColor(DebugColor.Grey)] public class DeleteEmptyEntitesSystem : IEcsRunProcess, IEcsPreInject { private List _worlds = new List(); public void PreInject(object obj) { if (obj is EcsWorld world) _worlds.Add(world); } public void Run(EcsPipeline pipeline) { foreach (var world in _worlds) world.DeleteEmptyEntites(); } } [DebugHide, DebugColor(DebugColor.Grey)] public class DeleteOneFrameComponentSystem : IEcsRunProcess, IEcsInject where TWorld : EcsWorld where TComponent : struct, IEcsComponent { private TWorld _world; public void Inject(TWorld obj) => _world = obj; private sealed class Subject : EcsSubject { public EcsPool pool; public Subject(Builder b) { pool = b.Include(); } } public void Run(EcsPipeline pipeline) { foreach (var e in _world.Where(out Subject s)) s.pool.Del(e); } } public static class DeleteOneFrameComponentSystemExt { private const string AUTO_DEL_LAYER = nameof(AUTO_DEL_LAYER); public static EcsPipeline.Builder AutoDel(this EcsPipeline.Builder b) where TWorld : EcsWorld where TComponent : struct, IEcsComponent { b.Layers.Insert(EcsConsts.POST_END_LAYER, AUTO_DEL_LAYER); b.AddUnique(new DeleteOneFrameComponentSystem(), AUTO_DEL_LAYER); return b; } /// for EcsDefaultWorld public static EcsPipeline.Builder AutoDel(this EcsPipeline.Builder b) where TComponent : struct, IEcsComponent { b.Layers.Insert(EcsConsts.POST_END_LAYER, AUTO_DEL_LAYER); b.AddUnique(new DeleteOneFrameComponentSystem(), AUTO_DEL_LAYER); return b; } } }