mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Changed to consider floating point error in the process of subtracting time
This commit is contained in:
parent
27921e9d0e
commit
65ced2e44d
@ -8,6 +8,7 @@ import { ItemEjectorComponent } from "../components/item_ejector";
|
|||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { enumLayer } from "../root";
|
import { enumLayer } from "../root";
|
||||||
|
import { quantizeFloat } from "../../core/utils";
|
||||||
|
|
||||||
const logger = createLogger("systems/ejector");
|
const logger = createLogger("systems/ejector");
|
||||||
|
|
||||||
@ -225,7 +226,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check if we are still in the process of ejecting, can't proceed then
|
// Check if we are still in the process of ejecting, can't proceed then
|
||||||
if (sourceSlot.progress < 1.0) {
|
if (quantizeFloat(sourceSlot.progress) < 1.0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { Entity } from "../entity";
|
|||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { ColorItem } from "../items/color_item";
|
import { ColorItem } from "../items/color_item";
|
||||||
import { ShapeItem } from "../items/shape_item";
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
import { quantizeFloat } from "../../core/utils";
|
||||||
|
|
||||||
export class ItemProcessorSystem extends GameSystemWithFilter {
|
export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
@ -31,7 +32,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
// Check if we have any finished items we can eject
|
// Check if we have any finished items we can eject
|
||||||
if (
|
if (
|
||||||
processorComp.secondsUntilEject === 0 && // it was processed in time
|
quantizeFloat(processorComp.secondsUntilEject) == 0 && // it was processed in time
|
||||||
processorComp.itemsToEject.length > 0 // we have some items left to eject
|
processorComp.itemsToEject.length > 0 // we have some items left to eject
|
||||||
) {
|
) {
|
||||||
for (let itemIndex = 0; itemIndex < processorComp.itemsToEject.length; ++itemIndex) {
|
for (let itemIndex = 0; itemIndex < processorComp.itemsToEject.length; ++itemIndex) {
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components/underground_belt";
|
import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components/underground_belt";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { fastArrayDelete } from "../../core/utils";
|
import { fastArrayDelete, quantizeFloat } from "../../core/utils";
|
||||||
import { enumLayer } from "../root";
|
import { enumLayer } from "../root";
|
||||||
|
|
||||||
const logger = createLogger("tunnels");
|
const logger = createLogger("tunnels");
|
||||||
@ -362,7 +362,7 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
|
|||||||
const nextItem = nextItemAndDuration[0];
|
const nextItem = nextItemAndDuration[0];
|
||||||
|
|
||||||
// Check if the item is ready to be emitted
|
// Check if the item is ready to be emitted
|
||||||
if (remainingTime === 0) {
|
if (quantizeFloat(remainingTime) == 0) {
|
||||||
// Check if the receiver can accept it
|
// Check if the receiver can accept it
|
||||||
if (
|
if (
|
||||||
receiver.entity.components.UndergroundBelt.tryAcceptTunneledItem(
|
receiver.entity.components.UndergroundBelt.tryAcceptTunneledItem(
|
||||||
@ -392,7 +392,7 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
|
|||||||
const remainingTime = nextItemAndDuration[1];
|
const remainingTime = nextItemAndDuration[1];
|
||||||
const nextItem = nextItemAndDuration[0];
|
const nextItem = nextItemAndDuration[0];
|
||||||
|
|
||||||
if (remainingTime <= 0) {
|
if (quantizeFloat(remainingTime) == 0) {
|
||||||
const ejectorComp = entity.components.ItemEjector;
|
const ejectorComp = entity.components.ItemEjector;
|
||||||
|
|
||||||
const nextSlotIndex = ejectorComp.getFirstFreeSlot(entity.layer);
|
const nextSlotIndex = ejectorComp.getFirstFreeSlot(entity.layer);
|
||||||
|
Loading…
Reference in New Issue
Block a user