Server actually ticks
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
// runs the game in a worker without any permissions, the host does files and networking
|
||||
import type { GameServer } from "./game_server.ts";
|
||||
import { TICK_MS } from "./game_server.ts";
|
||||
import { GameLoop } from "./game_loop.ts";
|
||||
import { GameToHost, HostToGame } from "./host_protocol.ts";
|
||||
import { data_url, start_game } from "./load_mods.ts";
|
||||
|
||||
@@ -68,7 +68,10 @@ async function init(message: Extract<HostToGame, { type: "init" }>) {
|
||||
return;
|
||||
}
|
||||
|
||||
setInterval(() => game!.tick(), TICK_MS);
|
||||
const loop = new GameLoop(() => game!.tick());
|
||||
game.loop = loop;
|
||||
loop.start();
|
||||
|
||||
setInterval(() => {
|
||||
if (game!.world.dirty) {
|
||||
post({ type: "save", data: game!.save(), final: false });
|
||||
|
||||
Reference in New Issue
Block a user