ECSOptions Class
Definition
Namespace: Brine2D.ECS
Configuration for the hybrid ECS: entity capacity, parallelism, and fixed-timestep tuning.
Inheritance System.Object → ECSOptions
| Properties | |
|---|---|
| EnableMultiThreading | When true, cached query iteration runs in parallel across worker threads for queries that exceed ParallelEntityThreshold. |
| FixedTimeStepMs | Fixed timestep in milliseconds for IFixedUpdateSystem and FixedUpdate\(GameTime\). Default \(~16\.667ms\) gives 60 steps/s. |
| InitialEntityCapacity | Pre-allocated entity slot count. Avoids resizing during gameplay. |
| MaxFixedStepsPerFrame | Maximum fixed steps per frame. Caps the catch-up loop after long frames \(debugger pauses, heavy loads\) so the game doesn't freeze. Excess time is discarded. |
| OnExceptionSwallowed | Optional callback invoked when an exception is swallowed because PropagateExceptions is false. Use this to route errors to a crash reporter or telemetry service in release builds without forcing the exception to propagate and crash the game loop. |
| OnFixedStepsDiscarded | Optional callback invoked when the fixed-update accumulator is clamped because a frame took longer than MaxFixedStepsPerFrame × FixedTimeStepMs. The argument is the number of milliseconds of simulation time that were discarded. |
| ParallelEntityThreshold | Entity count below which parallel processing falls back to sequential. Lower = more aggressive parallelism \(good for CPU\-heavy logic\); higher = less thread overhead \(good for lightweight components\). |
| PropagateExceptions | When true, exceptions thrown by systems or behaviors are re-thrown after logging instead of being swallowed. Defaults to true in DEBUG builds and false in release so that a single faulting system does not crash the game in production, but crashes are surfaced immediately during development. |
| WorkerThreadCount | Worker thread count for parallel execution. null \(default\) uses System.Environment.ProcessorCount. Only applies when EnableMultiThreading is true. |
| Methods | |
|---|---|
| GetParallelOptions() | Returns a cached System.Threading.Tasks.ParallelOptions instance derived from WorkerThreadCount. The cached instance is automatically invalidated when WorkerThreadCount changes. |