mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Enabled paused gamespeed
This commit is contained in:
parent
7ed6a9c7b6
commit
2e344e618a
@ -1,8 +1,10 @@
|
||||
import { RegularGameSpeed } from "./time/regular_game_speed";
|
||||
import { gGameSpeedRegistry } from "../core/global_registries";
|
||||
import { PausedGameSpeed } from "./time/paused_game_speed";
|
||||
|
||||
export function initGameSpeedRegistry() {
|
||||
gGameSpeedRegistry.register(RegularGameSpeed);
|
||||
gGameSpeedRegistry.register(PausedGameSpeed);
|
||||
|
||||
// Others are disabled for now
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ export const KEYMAPPINGS = {
|
||||
toggleHud: { keyCode: 113 }, // F2
|
||||
exportScreenshot: { keyCode: 114 }, // F3PS
|
||||
toggleFPSInfo: { keyCode: 115 }, // F4
|
||||
togglePause: { keyCode: 118 }, // F7
|
||||
|
||||
switchLayers: { keyCode: key("E") },
|
||||
},
|
||||
|
@ -496,10 +496,12 @@ export class BeltSystem extends GameSystemWithFilter {
|
||||
|
||||
// SYNC with systems/item_acceptor.js:drawEntityUnderlays!
|
||||
// 126 / 42 is the exact animation speed of the png animation
|
||||
const animationIndex = Math.floor(
|
||||
let animationIndex = Math.floor(
|
||||
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
||||
globalConfig.itemSpacingOnBelts
|
||||
);
|
||||
if (this.root.time.getIsPaused()) animationIndex = 0;
|
||||
|
||||
const contents = chunk.containedEntitiesByLayer.regular;
|
||||
|
||||
if (this.root.app.settings.getAllSettings().simplifiedBelts) {
|
||||
|
@ -9,6 +9,7 @@ import { PausedGameSpeed } from "./paused_game_speed";
|
||||
import { gGameSpeedRegistry } from "../../core/global_registries";
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { createLogger } from "../../core/logging";
|
||||
import { KEYMAPPINGS } from "../key_action_mapper";
|
||||
|
||||
const logger = createLogger("game_time");
|
||||
|
||||
@ -31,9 +32,13 @@ export class GameTime extends BasicSerializableObject {
|
||||
|
||||
/** @type {BaseGameSpeed} */
|
||||
this.speed = new RegularGameSpeed(this.root);
|
||||
/** @type {BaseGameSpeed} */
|
||||
this.previousSpeed = null;
|
||||
|
||||
// Store how much time we have in bucket
|
||||
this.logicTimeBudget = 0;
|
||||
|
||||
this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.togglePause).add(this.togglePause, this);
|
||||
}
|
||||
|
||||
static getId() {
|
||||
@ -185,6 +190,19 @@ export class GameTime extends BasicSerializableObject {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
togglePause() {
|
||||
if (this.getIsPaused()) {
|
||||
if (!this.previousSpeed) this.setSpeed(new RegularGameSpeed(this.root));
|
||||
else {
|
||||
this.setSpeed(this.previousSpeed);
|
||||
this.previousSpeed = null;
|
||||
}
|
||||
} else {
|
||||
this.previousSpeed = this.speed;
|
||||
this.setSpeed(new PausedGameSpeed(this.root));
|
||||
}
|
||||
}
|
||||
|
||||
deserialize(data) {
|
||||
const errorCode = super.deserialize(data);
|
||||
if (errorCode) {
|
||||
|
@ -1100,6 +1100,7 @@ keybindings:
|
||||
|
||||
toggleHud: Toggle HUD
|
||||
toggleFPSInfo: Toggle FPS and Debug Info
|
||||
togglePause: Toggle all the processes
|
||||
switchLayers: Switch layers
|
||||
exportScreenshot: Export whole Base as Image
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user