Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/app/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/** @import { SystemFunc } from '../ecs/index.js' */
/** @import { SystemConfig, SystemGroupConfig } from '../schedule/index.js' */
/** @import { Constructor,TypeId } from '../type/index.js'*/

import { World, ComponentHooks } from '../ecs/index.js'
import { Scheduler, SchedulerBuilder, Executable } from '../schedule/index.js'
import { Scheduler, SchedulerBuilder } from '../schedule/index.js'
import { assert } from '../logger/index.js'
import { typeid } from '../type/index.js'

Expand Down Expand Up @@ -84,12 +83,6 @@ export class App {
*/
initialized = false

/**
* @private
* @type {SchedulerBuilder}
*/
systemBuilder = new SchedulerBuilder()

/**
* Return the world of the app.
*
Expand All @@ -103,7 +96,7 @@ export class App {
* @param {{label: import('../type/index.js').Constructor, delay?: number, repeat?: boolean, errorHandler?: (error: Error, world: World) => void, defaultSystemGroup?: import('../type/index.js').Constructor}} config
*/
createSchedule(config) {
this.scheduler.set(new Executable(config))
SchedulerBuilder.Instance.addSchedule(config)

return this
}
Expand All @@ -127,7 +120,7 @@ export class App {
run() {
this.plugins.register(this)

this.systemBuilder.pushToScheduler(this.scheduler)
SchedulerBuilder.Instance.pushToScheduler(this.scheduler)
assert(this.runner, 'App runner is not set. Call `app.setRunner(...)` before `app.run()`.')
this.runner(this.scheduler, this.world)
this.initialized = true
Expand Down Expand Up @@ -155,7 +148,7 @@ export class App {
* @param {SystemConfig} config
*/
registerSystem(config) {
this.systemBuilder.add(config)
SchedulerBuilder.Instance.add(config)

return this
}
Expand All @@ -164,7 +157,7 @@ export class App {
* @param {SystemGroupConfig} config
*/
registerSystemGroup(config) {
this.systemBuilder.addGroup(config)
SchedulerBuilder.Instance.addGroup(config)

return this
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, Plugin } from '../app/index.js'
import { AppSchedule, CoreSystems, defaultRunner } from './core/index.js'
import { SchedulerBuilder } from '../schedule/index.js'
import { registerCoreTypes } from './systems/index.js'

export class CorePlugin extends Plugin {
Expand All @@ -9,6 +10,7 @@ export class CorePlugin extends Plugin {
*/
register(app) {
app
.setResource(SchedulerBuilder.Instance)
.setRunner(defaultRunner)
.createSchedule({
label: AppSchedule.Startup,
Expand Down
2 changes: 1 addition & 1 deletion src/schedule/core/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './schedule.js'
export * from './scheduler.js'
export * from './executable.js'
export * from './systembuilder.js'
export * from './schedulerbuilder.js'
export * from './systemconfig.js'
export * from './runner.js'
Loading
Loading