Files
P42_godDaemons/GPS/handlers/arena/lifecycle.js
T
2026-06-21 21:08:46 +00:00

37 lines
1.2 KiB
JavaScript

export function construct(redisCnx) {
const tickMs = redisCnx.gpsSrv?.getGpsSettings().collisionTickMs ?? 100
setInterval(() => {
redisCnx.gpsSrv?.tickArena()
}, tickMs)
}
export const eventHandlers = {
'arena:lifecycle': {
onYourMarks(msg, chan) {
const srv = this.gpsSrv
if(!srv) return
srv.onYourMarks(msg.payload ?? {}).catch(err => {
console.error(`[${this.redisId}] onYourMarks failed:`, err)
srv.publishReadyToStart({ success: false, err: err.message ?? 'onYourMarks failed' })
})
},
bigBang(msg, chan) {
this.gpsSrv?.onBigBang(msg.payload ?? {})
},
simulationPaused(msg, chan) {
this.gpsSrv?.onSimulationPaused(msg.payload ?? {})
},
simulationResumed(msg, chan) {
this.gpsSrv?.onSimulationResumed(msg.payload ?? {})
},
simulationStopped(msg, chan) {
const srv = this.gpsSrv
if(!srv) return
srv.onSimulationStopped(msg.payload ?? {}).catch(err => {
console.error(`[${this.redisId}] simulationStopped failed:`, err)
})
},
},
}