1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-12 10:59:23 +00:00

added check to prevent downloading empty goal acceptors

This commit is contained in:
Sense101 2021-07-07 15:12:44 +01:00
parent 4de1cebe58
commit bca7440f14

View File

@ -3,6 +3,7 @@ import { ReadWriteProxy } from "../../../core/read_write_proxy";
import { generateFileDownload, makeDiv, startFileChoose, waitNextFrame } from "../../../core/utils";
import { PuzzleSerializer } from "../../../savegame/puzzle_serializer";
import { T } from "../../../translations";
import { GoalAcceptorComponent } from "../../components/goal_acceptor";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { PuzzleGameMode } from "../../modes/puzzle";
import { BaseHUDPart } from "../base_hud_part";
@ -110,6 +111,18 @@ export class HUDPuzzleImportExport extends BaseHUDPart {
}
exportPuzzle() {
// Make sure all acceptors have an item
for (const entity of this.root.entityMgr.getAllWithComponent(GoalAcceptorComponent)) {
const goalComp = entity.components.GoalAcceptor;
if (!goalComp.item) {
this.root.hud.parts.dialogs.showWarning(
T.puzzleMenu.validation.title,
T.puzzleMenu.validation.goalAcceptorNoItem
);
return;
}
}
const serialized = new PuzzleSerializer().generateDumpFromGameRoot(this.root);
const data = ReadWriteProxy.serializeObject(serialized);