Observer embryo, Maestro done
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
export const construct = (redisCnx) => {
|
||||
const tickMs = redisCnx.gpsSrv?.getGpsSettings().collisionTickMs ?? 100
|
||||
// Interval always runs; tickArena no-ops until LIVE (see gpsServer.tickArena)
|
||||
setInterval(() => {
|
||||
redisCnx.gpsSrv?.tickArena()
|
||||
}, tickMs)
|
||||
@@ -8,6 +9,24 @@ export const construct = (redisCnx) => {
|
||||
|
||||
export const methods = {
|
||||
|
||||
handleLifecycleEvent(msg) {
|
||||
const srv = this.gpsSrv
|
||||
if(!srv) return
|
||||
|
||||
if(msg.eventType === 'onYourMarks') {
|
||||
srv.onYourMarks(msg.payload ?? {}).catch(err => {
|
||||
console.error(`[${this.redisId}] onYourMarks failed:`, err)
|
||||
srv.publishReadyToStart({ success: false, err: err.message ?? 'onYourMarks failed' })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if(msg.eventType === 'bigBang') {
|
||||
srv.onBigBang(msg.payload ?? {})
|
||||
return
|
||||
}
|
||||
},
|
||||
|
||||
handleAgentEvent(msg) {
|
||||
const agentId = msg.sender
|
||||
if(!agentId || typeof(agentId) !== 'string') {
|
||||
@@ -34,7 +53,12 @@ export const methods = {
|
||||
|
||||
dispatchArenaMessage(msg, chan) {
|
||||
const gps = this.config.gps
|
||||
if(!gps || !this.gpsSrv) return false
|
||||
if(!gps || !this.gpsSrv) return(false)
|
||||
|
||||
if(this.matchesChan(chan, gps.lifecycle?.arenaChannel ?? 'arena:lifecycle')) {
|
||||
this.handleLifecycleEvent(msg)
|
||||
return(true)
|
||||
}
|
||||
|
||||
if(this.matchesChan(chan, gps.agentVectorChangeChannel)) {
|
||||
this.handleAgentEvent(msg)
|
||||
|
||||
Reference in New Issue
Block a user