mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-07 10:03:59 +00:00
fix belt animation seeming to go 'backwards' on high belt speeds
This commit is contained in:
parent
c844dd4798
commit
d8bf4f9cd8
@ -7,7 +7,7 @@ export const CHANGELOG = [
|
|||||||
"Preparations for the wires update",
|
"Preparations for the wires update",
|
||||||
"Allow clicking on variants to select them",
|
"Allow clicking on variants to select them",
|
||||||
"Add 'copy key' button to shape viewer",
|
"Add 'copy key' button to shape viewer",
|
||||||
"Add more FPS to the belt animation",
|
"Add more FPS to the belt animation and fix belt animation seeming to go 'backwards' on high belt speeds",
|
||||||
"Fix deconstruct sound being played when right clicking hub",
|
"Fix deconstruct sound being played when right clicking hub",
|
||||||
"Allow clicking 'Q' over a shape or color patch to automatically select the miner building (by Gerdon262)",
|
"Allow clicking 'Q' over a shape or color patch to automatically select the miner building (by Gerdon262)",
|
||||||
"Update belt placement performance on huge factories (by Phlosioneer)",
|
"Update belt placement performance on huge factories (by Phlosioneer)",
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import { Math_sqrt } from "../../core/builtins";
|
import { Math_min } from "../../core/builtins";
|
||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
|
import { gMetaBuildingRegistry } from "../../core/global_registries";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { createLogger } from "../../core/logging";
|
import { createLogger } from "../../core/logging";
|
||||||
import { AtlasSprite } from "../../core/sprites";
|
import { AtlasSprite } from "../../core/sprites";
|
||||||
|
import { fastArrayDeleteValue } from "../../core/utils";
|
||||||
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../../core/vector";
|
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../../core/vector";
|
||||||
import { BeltPath } from "../belt_path";
|
import { BeltPath } from "../belt_path";
|
||||||
|
import { arrayBeltVariantToRotation, MetaBeltBaseBuilding } from "../buildings/belt_base";
|
||||||
import { BeltComponent } from "../components/belt";
|
import { BeltComponent } from "../components/belt";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { fastArrayDeleteValue } from "../../core/utils";
|
|
||||||
import { gMetaBuildingRegistry } from "../../core/global_registries";
|
|
||||||
import { MetaBeltBaseBuilding, arrayBeltVariantToRotation } from "../buildings/belt_base";
|
|
||||||
import { defaultBuildingVariant } from "../meta_building";
|
import { defaultBuildingVariant } from "../meta_building";
|
||||||
|
|
||||||
export const BELT_ANIM_COUNT = 28;
|
export const BELT_ANIM_COUNT = 28;
|
||||||
@ -469,12 +469,13 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const speedMultiplier = this.root.hubGoals.getBeltBaseSpeed();
|
// Limit speed to avoid belts going backwards
|
||||||
|
const speedMultiplier = Math_min(this.root.hubGoals.getBeltBaseSpeed(), 10);
|
||||||
|
|
||||||
// SYNC with systems/item_acceptor.js:drawEntityUnderlays!
|
// SYNC with systems/item_acceptor.js:drawEntityUnderlays!
|
||||||
// 126 / 42 is the exact animation speed of the png animation
|
// 126 / 42 is the exact animation speed of the png animation
|
||||||
const animationIndex = Math.floor(
|
const animationIndex = Math.floor(
|
||||||
((this.root.time.now() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
||||||
globalConfig.itemSpacingOnBelts
|
globalConfig.itemSpacingOnBelts
|
||||||
);
|
);
|
||||||
const contents = chunk.contents;
|
const contents = chunk.contents;
|
||||||
|
@ -6,7 +6,7 @@ import { enumDirectionToVector, enumDirectionToAngle } from "../../core/vector";
|
|||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { drawRotatedSprite } from "../../core/draw_utils";
|
import { drawRotatedSprite } from "../../core/draw_utils";
|
||||||
import { Math_radians } from "../../core/builtins";
|
import { Math_radians, Math_min } from "../../core/builtins";
|
||||||
import { BELT_ANIM_COUNT } from "./belt";
|
import { BELT_ANIM_COUNT } from "./belt";
|
||||||
|
|
||||||
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||||
@ -94,6 +94,9 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limit speed to avoid belts going backwards
|
||||||
|
const speedMultiplier = Math_min(this.root.hubGoals.getBeltBaseSpeed(), 10);
|
||||||
|
|
||||||
const underlays = acceptorComp.beltUnderlays;
|
const underlays = acceptorComp.beltUnderlays;
|
||||||
for (let i = 0; i < underlays.length; ++i) {
|
for (let i = 0; i < underlays.length; ++i) {
|
||||||
const { pos, direction } = underlays[i];
|
const { pos, direction } = underlays[i];
|
||||||
@ -103,11 +106,7 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
// SYNC with systems/belt.js:drawSingleEntity!
|
// SYNC with systems/belt.js:drawSingleEntity!
|
||||||
const animationIndex = Math.floor(
|
const animationIndex = Math.floor(
|
||||||
((this.root.time.now() *
|
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
||||||
this.root.hubGoals.getBeltBaseSpeed() *
|
|
||||||
this.underlayBeltSprites.length *
|
|
||||||
126) /
|
|
||||||
42) *
|
|
||||||
globalConfig.itemSpacingOnBelts
|
globalConfig.itemSpacingOnBelts
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user