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:
@@ -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(),
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user