1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00
tobspr_shapez.io/src/js/game/modes/puzzle.js

118 lines
2.7 KiB
JavaScript
Raw Normal View History

/* 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";
2021-04-29 16:27:46 +00:00
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,
2021-04-29 16:27:46 +00:00
[HUDMassSelector.name]: false,
[HUDInteractiveTutorial.name]: false,
[HUDKeybindingOverlay.name]: false,
[HUDPartTutorialHints.name]: false,
[HUDPinnedShapes.name]: false,
[HUDWaypoints.name]: false,
2021-04-29 20:31:06 +00:00
};
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);
}
2021-04-29 20:31:06 +00:00
getCameraBounds() {
return this.createCenteredRectangle(this.zoneWidth + 20, this.zoneHeight + 20);
}
2021-04-29 20:31:06 +00:00
getBuildableZones() {
return [this.createCenteredRectangle(this.zoneWidth, this.zoneHeight)];
}
hasHub() {
return false;
}
hasResources() {
return false;
}
getMinimumZoom() {
return 1;
}
2021-04-30 12:34:11 +00:00
getMaximumZoom() {
return 4;
}
2021-04-29 16:27:46 +00:00
getIsSaveable() {
return false;
}
getSupportsCopyPaste() {
return false;
}
2021-04-29 20:31:06 +00:00
throughputDoesNotMatter() {
return true;
}
getSupportsWires() {
return false;
}
2021-04-30 12:34:11 +00:00
getIsDeterministic() {
return true;
}
getFixedTickrate() {
return 300;
}
/** @returns {boolean} */
getIsFreeplayAvailable() {
return true;
}
}