A mechanism to specify whether a system or group of systems should run at all would be nice. You can kind of do this with an early return, but you may have to access data you otherwise don't care about to do this, which isn't great. Also maybe better optimization potential if they exist external to systems.
Describe the solution you'd like to see
For the API, a run condition is a function that returns a boolean - true if the system(s) should run, false if they should not. It will be supplied as the third argument for World.p.addSystems (Schedule addSystem unknown).
The function can either be a system, or a function that accepts the world instance. If the getSystemParameters property exists on the function, it will be treated as a system and its arguments will be parsed. If not, it will be supplied the world.
Example usage:
type RunCondition = (...args: any[]) => boolean;
class World {
addSystems(
scheduleType: ScheduleType,
systems: System | System[],
condition: RunCondition
): this
}
// In use
const world = await new World()
.addSystems(Schedule, mySystem, world => world.getResource(SomeResource).someProperty)
.prepare()
Open Questions
When should this be evaluated?
a. Every runSchedule() call
b. When prepare() is called
c. A third API, included in prepare() but called separately?
Describe the problem this feature solves
A mechanism to specify whether a system or group of systems should run at all would be nice. You can kind of do this with an early return, but you may have to access data you otherwise don't care about to do this, which isn't great. Also maybe better optimization potential if they exist external to systems.
Describe the solution you'd like to see
For the API, a run condition is a function that returns a boolean - true if the system(s) should run, false if they should not. It will be supplied as the third argument for
World.p.addSystems
(Schedule addSystem unknown). The function can either be a system, or a function that accepts theworld
instance. If thegetSystemParameters
property exists on the function, it will be treated as a system and its arguments will be parsed. If not, it will be supplied theworld
.Example usage:
Open Questions
runSchedule()
call b. Whenprepare()
is called c. A third API, included in prepare() but called separately?