/* typehints:start */ import { GameRoot } from "../root"; /* typehints:end */ import { Rectangle } from "../../core/rectangle"; import { types } from "../../savegame/serialization"; import { enumGameModeTypes, GameMode } from "../game_mode"; import { HUDGameMenu } from "../hud/parts/game_menu"; import { HUDInteractiveTutorial } from "../hud/parts/interactive_tutorial"; import { HUDKeybindingOverlay } from "../hud/parts/keybinding_overlay"; import { HUDPartTutorialHints } from "../hud/parts/tutorial_hints"; import { HUDPinnedShapes } from "../hud/parts/pinned_shapes"; import { HUDWaypoints } from "../hud/parts/waypoints"; import { HUDMassSelector } from "../hud/parts/mass_selector"; export class PuzzleGameMode extends GameMode { static getType() { return enumGameModeTypes.puzzle; } /** @returns {object} */ static getSchema() { return { zoneHeight: types.uint, zoneWidth: types.uint, }; } /** @param {GameRoot} root */ constructor(root) { super(root); const data = this.getSaveData(); this.hiddenHudParts = { [HUDGameMenu.name]: false, [HUDMassSelector.name]: false, [HUDInteractiveTutorial.name]: false, [HUDKeybindingOverlay.name]: false, [HUDPartTutorialHints.name]: false, [HUDPinnedShapes.name]: false, [HUDWaypoints.name]: false, }; this.setDimensions(data.zoneWidth, data.zoneHeight); } setDimensions(w = 16, h = 9) { this.zoneWidth = w < 2 ? 2 : w; this.zoneHeight = h < 2 ? 2 : h; } getSaveData() { const save = this.root.savegame.getCurrentDump(); if (!save) { return {}; } return save.gameMode.data; } createCenteredRectangle(width, height) { return new Rectangle(-Math.ceil(width / 2), -Math.ceil(height / 2), width, height); } getCameraBounds() { return this.createCenteredRectangle(this.zoneWidth + 20, this.zoneHeight + 20); } getBuildableZones() { return [this.createCenteredRectangle(this.zoneWidth, this.zoneHeight)]; } hasHub() { return false; } hasResources() { return false; } getMinimumZoom() { return 1; } getMaximumZoom() { return 4; } getIsSaveable() { return false; } getSupportsCopyPaste() { return false; } throughputDoesNotMatter() { return true; } getSupportsWires() { return false; } getIsDeterministic() { return true; } getFixedTickrate() { return 300; } /** @returns {boolean} */ getIsFreeplayAvailable() { return true; } }