namespace OECS;
///
/// A system that runs on every tick.
/// Implement with the system logic.
/// Call to execute with batching.
///
public interface ISystem
{
///
/// Implement this with the system's logic for this tick.
/// The caller (e.g., ) wraps this
/// in a batching scope so mutations and component accesses
/// are automatically tracked.
///
void RunImpl(World world);
}
///
/// Extension methods for running systems with proper batching.
///
public static class SystemExtensions
{
///
/// Runs a system with a batching scope. Structural mutations are
/// buffered, and calls are
/// auto-tracked for modification until the system returns.
///
public static void Run(this ISystem system, World world)
{
world.BeginBatching();
system.RunImpl(world);
world.EndBatching();
}
///
/// Runs a ticked system with a batching scope.
///
public static void Run(this ITickedSystem system, World world, Tick tick)
{
world.BeginBatching();
system.RunImpl(world, tick);
world.EndBatching();
}
}