1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00

Remove code related to trailer recording

Unlikely to be used and can be replicated with mods in a much better
way.
This commit is contained in:
Даниїл Григор'єв 2025-06-19 20:45:09 +03:00
parent 51c0352079
commit 449ff3cbda
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D
6 changed files with 2 additions and 253 deletions

View File

@ -77,9 +77,6 @@ export default {
// When using fastGameEnter, controls whether a new game is started or the last one is resumed
// resumeGameOnFastEnter: true,
// -----------------------------------------------------------------------------------
// Special option used to render the trailer
// renderForTrailer: true,
// -----------------------------------------------------------------------------------
// Whether to render changes
// renderChanges: true,
// -----------------------------------------------------------------------------------

View File

@ -95,17 +95,6 @@ if (globalConfig.debug.disableMapOverview) {
globalConfig.mapChunkOverviewMinZoom = 0;
}
// Stuff for making the trailer
if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
globalConfig.debug.framePausesBetweenTicks = 32;
// globalConfig.mapChunkOverviewMinZoom = 0.0;
// globalConfig.debug.instantBelts = true;
// globalConfig.debug.instantProcessors = true;
// globalConfig.debug.instantMiners = true;
globalConfig.debug.disableSavegameWrite = true;
// globalConfig.beltSpeedItemsPerSecond *= 2;
}
if (globalConfig.debug.fastGameEnter) {
globalConfig.debug.noArtificialDelays = true;
}

View File

@ -1,6 +1,5 @@
import { GameRoot } from "./root";
import { createLogger } from "../core/logging";
import { globalConfig } from "../core/config";
import { GameRoot } from "./root";
const logger = createLogger("dynamic_tickrate");
@ -29,10 +28,6 @@ export class DynamicTickrate {
this.setTickRate(fixedRate);
} else {
this.setTickRate(this.root.app.settings.getDesiredFps());
if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
this.setTickRate(300);
}
}
}
@ -64,10 +59,6 @@ export class DynamicTickrate {
* Increases the tick rate marginally
*/
increaseTickRate() {
if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
return;
}
const desiredFps = this.root.app.settings.getDesiredFps();
this.setTickRate(Math.round(Math.min(desiredFps, this.currentTickRate * 1.2)));
}
@ -76,10 +67,6 @@ export class DynamicTickrate {
* Decreases the tick rate marginally
*/
decreaseTickRate() {
if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
return;
}
const desiredFps = this.root.app.settings.getDesiredFps();
this.setTickRate(Math.round(Math.max(desiredFps / 2, this.currentTickRate * 0.8)));
}

View File

@ -8,8 +8,8 @@ import { GameRoot } from "../root";
import { ShapeDefinition } from "../shape_definition";
import { HUDBetaOverlay } from "./parts/beta_overlay";
import { HUDBlueprintPlacer } from "./parts/blueprint_placer";
import { HUDBuildingsToolbar } from "./parts/buildings_toolbar";
import { HUDBuildingPlacer } from "./parts/building_placer";
import { HUDBuildingsToolbar } from "./parts/buildings_toolbar";
import { HUDColorBlindHelper } from "./parts/color_blind_helper";
import { HUDChangesDebugger } from "./parts/debug_changes";
import { HUDDebugInfo } from "./parts/debug_info";
@ -19,7 +19,6 @@ import { enumNotificationType } from "./parts/notifications";
import { HUDSettingsMenu } from "./parts/settings_menu";
import { HUDShapeTooltip } from "./parts/shape_tooltip";
import { HUDVignetteOverlay } from "./parts/vignette_overlay";
import { TrailerMaker } from "./trailer_maker";
export class GameHUD {
/**
@ -107,12 +106,6 @@ export class GameHUD {
}
this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.toggleHud).add(this.toggleUi, this);
/* dev:start */
if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
this.trailerMaker = new TrailerMaker(this.root);
}
/* dev:end*/
}
/**
@ -178,12 +171,6 @@ export class GameHUD {
for (const key in this.parts) {
this.parts[key].update();
}
/* dev:start */
if (this.trailerMaker) {
this.trailerMaker.update();
}
/* dev:end*/
}
/**

View File

@ -1,122 +0,0 @@
import { GameRoot } from "../root";
import { globalConfig } from "../../core/config";
import { Vector, mixVector } from "../../core/vector";
import { lerp } from "../../core/utils";
/* dev:start */
import trailerPoints from "./trailer_points";
const tickrate = 1 / 165;
export class TrailerMaker {
/**
*
* @param {GameRoot} root
*/
constructor(root) {
this.root = root;
this.markers = [];
this.playbackMarkers = null;
this.currentPlaybackOrigin = new Vector();
this.currentPlaybackZoom = 3;
window.addEventListener("keydown", ev => {
if (ev.key === "j") {
console.log("Record");
this.markers.push({
pos: this.root.camera.center.copy(),
zoom: this.root.camera.zoomLevel,
time: 1,
wait: 0,
});
} else if (ev.key === "k") {
console.log("Export");
const json = JSON.stringify(this.markers);
const handle = window.open("about:blank");
handle.document.write(json);
} else if (ev.key === "u") {
if (this.playbackMarkers && this.playbackMarkers.length > 0) {
this.playbackMarkers = [];
return;
}
console.log("Playback");
this.playbackMarkers = trailerPoints.map(p => Object.assign({}, p));
this.playbackMarkers.unshift(this.playbackMarkers[0]);
this.currentPlaybackOrigin = Vector.fromSerializedObject(this.playbackMarkers[0].pos);
this.currentPlaybackZoom = this.playbackMarkers[0].zoom;
this.root.camera.center = this.currentPlaybackOrigin.copy();
this.root.camera.zoomLevel = this.currentPlaybackZoom;
console.log("STart at", this.currentPlaybackOrigin);
// this.root.entityMgr.getAllWithComponent(MinerComponent).forEach(miner => {
// miner.components.Miner.itemChainBuffer = [];
// miner.components.Miner.lastMiningTime = this.root.time.now() + 5;
// miner.components.ItemEjector.slots.forEach(slot => (slot.item = null));
// });
// this.root.logic.tryPlaceBuilding({
// origin: new Vector(-428, -15),
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding),
// originalRotation: 0,
// rotation: 0,
// variant: "default",
// rotationVariant: 0,
// });
// this.root.logic.tryPlaceBuilding({
// origin: new Vector(-427, -15),
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding),
// originalRotation: 0,
// rotation: 0,
// variant: "default",
// rotationVariant: 0,
// });
}
});
}
update() {
if (this.playbackMarkers && this.playbackMarkers.length > 0) {
const nextMarker = this.playbackMarkers[0];
if (!nextMarker.startTime) {
console.log("Starting to approach", nextMarker.pos);
nextMarker.startTime = performance.now() / 1000.0;
}
const speed =
globalConfig.tileSize *
globalConfig.beltSpeedItemsPerSecond *
globalConfig.itemSpacingOnBelts;
// let time =
// this.currentPlaybackOrigin.distance(Vector.fromSerializedObject(nextMarker.pos)) / speed;
const time = nextMarker.time;
const progress = (performance.now() / 1000.0 - nextMarker.startTime) / time;
if (progress > 1.0) {
if (nextMarker.wait > 0) {
nextMarker.wait -= tickrate;
} else {
console.log("Approached");
this.currentPlaybackOrigin = this.root.camera.center.copy();
this.currentPlaybackZoom = this.root.camera.zoomLevel;
this.playbackMarkers.shift();
}
return;
}
const targetPos = Vector.fromSerializedObject(nextMarker.pos);
const targetZoom = nextMarker.zoom;
const pos = mixVector(this.currentPlaybackOrigin, targetPos, progress);
const zoom = lerp(this.currentPlaybackZoom, targetZoom, progress);
this.root.camera.zoomLevel = zoom;
this.root.camera.center = pos;
}
}
}
/* dev:end */

View File

@ -1,89 +0,0 @@
export default [
// // initial
// { pos: { x: -13665, y: -434 }, zoom: 6, time: 1, wait: 8 },
// // Go up to first curve
// { pos: { x: -13665, y: -580 }, zoom: 6, time: 1, wait: 0 },
// // To balancers
// { pos: { x: -13450, y: -580 }, zoom: 6, time: 1, wait: 0 },
// // To cutters
// { pos: { x: -13350, y: -580 }, zoom: 3, time: 1, wait: 2 },
// // To initial cutters
// { pos: { x: -12713, y: -580 }, zoom: 3, time: 1, wait: 2.5 },
// // To rotators 3,2,1,0
// { pos: { x: -12402, y: -580 }, zoom: 3, time: 1, wait: 0 },
// // Zoom in further to stackers
// { pos: { x: -12045, y: -580 }, zoom: 6, time: 1, wait: 4 },
// // Focus on painter
// { pos: { x: -11700, y: -660 }, zoom: 6, time: 1, wait: 3.5 },
// // Zoom in to mixers
// { pos: { x: -11463, y: -520 }, zoom: 6, time: 1, wait: 3.8 },
// // Focus to second painter
// { pos: { x: -11290, y: -610 }, zoom: 6, time: 1, wait: 1 },
// // Second stacker
// { pos: { x: -11022, y: -610 }, zoom: 6, time: 1, wait: 0 },
// // Go right until first curve
// { pos: { x: -10859, y: -650 }, zoom: 6, time: 1, wait: 0 },
// // Go up to stacker
// { pos: { x: -10859, y: -1120 }, zoom: 6, time: 1, wait: 0 },
// // Go further up
// { pos: { x: -10859, y: -1260 }, zoom: 6, time: 1, wait: 0 },
// // Go left
// { pos: { x: -11235, y: -1260 }, zoom: 6, time: 1, wait: 1 },
// OWO Savegames
// { pos: { x: -4939.356940622392, y: 71.76431237675517 }, zoom: 5.06640625, time: 1, wait: 1 },
// { pos: { x: -4275.441641063683, y: 26.3603982512193 }, zoom: 0.45, time: 32, wait: 0 },
// Eve
// { pos: { x: -277.22574043554704, y: 2151.1873666983033 }, zoom: 3.1, time: 0, wait: 2 },
// { pos: { x: -43.64015426578788, y: 1577.5520572108883 }, zoom: 1.4, time: 16, wait: 0 },
// { pos: { x: 133.22735227708466, y: 957.2211413984563 }, zoom: 1.4, time: 8, wait: 0 },
// { pos: { x: 480.20365842184424, y: -313.5485044644265 }, zoom: 1.4, time: 8, wait: 0 },
// {
// pos: { x: 452.56528647804333, y: -1341.6422407571154 },
// zoom: 1.4,
// time: 8,
// wait: 0,
// },
// D
{ pos: { x: -7506.562977380196, y: 1777.6671860680613 }, zoom: 2.3764616075569833, time: 0, wait: 1 },
{ pos: { x: -7506.562977380196, y: 1777.6671860680613 }, zoom: 2.3764616075569833, time: 1, wait: 0 },
{ pos: { x: -6592.471896026158, y: 1841.974816890533 }, zoom: 1.4594444847409322, time: 24, wait: 0 },
{ pos: { x: -7274.384090342281, y: 729.3783696229457 }, zoom: 1.4594444847409322, time: 24, wait: 0 },
{ pos: { x: -6048.006011617565, y: 764.6297752493597 }, zoom: 1.1853320776932916, time: 24, wait: 0 },
{
pos: { x: -3674.7204249483366, y: 658.6366426023269 },
zoom: 0.25332031250000003,
time: 24,
wait: 0,
},
{
pos: { x: -1213.9916574596728, y: -1387.1496772071198 },
zoom: 0.443058809814453,
time: 24,
wait: 0,
},
{
pos: { x: 1722.5210292405573, y: -2457.2072755163636 },
zoom: 0.6313986260996299,
time: 24,
wait: 0,
},
{ pos: { x: 3533.263459106946, y: -1806.6756300805193 }, zoom: 1.551908182277415, time: 24, wait: 0 },
];