dev: bit nicer HMR

This commit is contained in:
cha0s 2024-06-29 09:52:35 -05:00
parent bcbef693cc
commit aa586a98e5

View File

@ -57,8 +57,14 @@ onmessage = async (event) => {
})(); })();
if (import.meta.hot) { if (import.meta.hot) {
import.meta.hot.accept('../engine/engine.js', async () => { import.meta.hot.accept('../../engine.js', async ({default: Engine}) => {
await engine.disconnectPlayer(0, 0); await engine.disconnectPlayer(0);
if (Engine.prototype.createHomestead.toString() !== engine.createHomestead.toString()) {
delete engine.ecses['homesteads/0'];
await engine.server.removeData('homesteads/0');
const newEngine = new Engine(WorkerServer);
await newEngine.createHomestead(0);
}
postMessage(encode({type: 'ConnectionStatus', payload: 'aborted'})); postMessage(encode({type: 'ConnectionStatus', payload: 'aborted'}));
close(); close();
}); });