namespace MoonTools.ECS; public abstract class System : EntityComponentReader { internal MessageDepot MessageDepot; public FilterBuilder FilterBuilder => new FilterBuilder(ComponentDepot); public System(World world) { world.AddSystem(this); } internal void RegisterMessageDepot(MessageDepot messageDepot) { MessageDepot = messageDepot; } public abstract void Update(TimeSpan delta); protected Entity CreateEntity() { return EntityStorage.Create(); } protected void Set(in Entity entity, in TComponent component) where TComponent : struct { ComponentDepot.Set(entity.ID, component); } protected void Remove(in Entity entity) where TComponent : struct { ComponentDepot.Remove(entity.ID); } protected ReadOnlySpan ReadMessages() where TMessage : struct { return MessageDepot.Read(); } protected bool SomeMessage() where TMessage : struct { return MessageDepot.Some(); } protected void Destroy(in Entity entity) { ComponentDepot.OnEntityDestroy(entity.ID); EntityStorage.Destroy(entity); } }