1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Fix multiple issues regarding saving / restoring games

This commit is contained in:
tobspr
2020-07-05 16:56:01 +02:00
parent 0b9b35b79e
commit 34ef26b289
12 changed files with 73 additions and 39 deletions

View File

@@ -26,10 +26,6 @@ export class SavegameSerializer {
* @returns {object}
*/
generateDumpFromGameRoot(root, sanityChecks = true) {
// Finalize particles before saving (Like granting destroy indicator rewards)
// root.particleMgr.finalizeBeforeSave();
// root.uiParticleMgr.finalizeBeforeSave();
// Now store generic savegame payload
const data = {
camera: root.camera.serialize(),

View File

@@ -1,15 +1,9 @@
/* typehints:start */
import { GameRoot } from "../game/root";
/* typehints:end */
import { gComponentRegistry } from "../core/global_registries";
import { createLogger } from "../core/logging";
import { Entity } from "../game/entity";
import { enumLayer, GameRoot } from "../game/root";
// Internal serializer methods
export class SerializerInternal {
constructor() {}
/**
* Serializes an array of entities
* @param {Array<Entity>} array
@@ -45,6 +39,11 @@ export class SerializerInternal {
deserializeEntity(root, payload) {
const entity = new Entity(root);
this.deserializeComponents(entity, payload.components);
entity.layer = payload.layer;
if (!enumLayer[payload.layer]) {
assert(false, "Invalid layer: " + payload.layer);
}
root.entityMgr.registerEntity(entity, payload.uid);