2022-03-05 02:01:44 +00:00
|
|
|
|
namespace MoonTools.ECS;
|
|
|
|
|
|
|
|
|
|
public abstract class System : EntityComponentReader
|
|
|
|
|
{
|
|
|
|
|
public abstract void Update(TimeSpan delta);
|
|
|
|
|
|
2022-03-06 06:13:44 +00:00
|
|
|
|
public FilterBuilder FilterBuilder => new FilterBuilder(ComponentDepot);
|
|
|
|
|
|
2022-03-06 06:12:27 +00:00
|
|
|
|
public System(World world)
|
|
|
|
|
{
|
|
|
|
|
world.AddSystem(this);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-05 02:01:44 +00:00
|
|
|
|
protected Entity CreateEntity()
|
|
|
|
|
{
|
|
|
|
|
return EntityStorage.Create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Set<TComponent>(in Entity entity, in TComponent component) where TComponent : struct
|
|
|
|
|
{
|
|
|
|
|
ComponentDepot.Set<TComponent>(entity.ID, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Remove<TComponent>(in Entity entity) where TComponent : struct
|
|
|
|
|
{
|
|
|
|
|
ComponentDepot.Remove<TComponent>(entity.ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Destroy(in Entity entity)
|
|
|
|
|
{
|
|
|
|
|
ComponentDepot.OnEntityDestroy(entity.ID);
|
|
|
|
|
EntityStorage.Destroy(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|