feat: broadcast dayNumber in state updates
This commit is contained in:
@@ -33,7 +33,7 @@ export class SocketServer {
|
||||
|
||||
private setupBroadcast(): void {
|
||||
this.gameLoop.setBroadcastHandler(() => {
|
||||
const update = serializeStateUpdate(this.gameLoop.world, this.gameLoop.getTick(), this.gameLoop.getGameTime());
|
||||
const update = serializeStateUpdate(this.gameLoop.world, this.gameLoop.getTick(), this.gameLoop.getGameTime(), this.gameLoop.getDayNumber());
|
||||
this.io.emit('state-update', update);
|
||||
});
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ export function serializeWorldState(world: World, map: GameMap): WorldState {
|
||||
};
|
||||
}
|
||||
|
||||
export function serializeStateUpdate(world: World, tick: number, gameTime: number): StateUpdate {
|
||||
export function serializeStateUpdate(world: World, tick: number, gameTime: number, dayNumber: number): StateUpdate {
|
||||
const entities = world.query('position').map(id => serializeEntity(world, id));
|
||||
return { entities, tick, gameTime };
|
||||
return { entities, tick, gameTime, dayNumber };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user