using System; namespace MoonTools.ECS { public abstract class System : Manipulator { internal MessageDepot MessageDepot => World.MessageDepot; public System(World world) : base(world) { } public abstract void Update(TimeSpan delta); protected ReadOnlySpan ReadMessages() where TMessage : unmanaged { return MessageDepot.All(); } protected TMessage ReadMessage() where TMessage : unmanaged { return MessageDepot.First(); } protected bool SomeMessage() where TMessage : unmanaged { return MessageDepot.Some(); } protected ReverseSpanEnumerator ReadMessagesWithEntity(in Entity entity) where TMessage : unmanaged { return MessageDepot.WithEntity(entity.ID); } protected ref readonly TMessage ReadMessageWithEntity(in Entity entity) where TMessage : unmanaged { return ref MessageDepot.FirstWithEntity(entity.ID); } protected bool SomeMessageWithEntity(in Entity entity) where TMessage : unmanaged { return MessageDepot.SomeWithEntity(entity.ID); } protected void Send(in TMessage message) where TMessage : unmanaged => World.Send(message); protected void Send(in Entity entity, in TMessage message) where TMessage : unmanaged => World.Send(entity, message); } }