Fix factory not working at full spped at high tick rate

This commit is contained in:
ducdat0507 2022-12-24 13:13:23 +07:00
parent 53e8669061
commit 97774bc319

View file

@ -101,9 +101,6 @@ const toyGoal = 750;
const advancedToyGoal = 1500; const advancedToyGoal = 1500;
const presentsGoal = 8e9; const presentsGoal = 8e9;
// 20x20 block size
// TODO: unhardcode stuff
function roundDownTo(num: number, multiple: number) { function roundDownTo(num: number, multiple: number) {
return Math.floor((num + multiple / 2) / multiple) * multiple; return Math.floor((num + multiple / 2) / multiple) * multiple;
} }
@ -1641,6 +1638,7 @@ const factory = createLayer(id, () => {
const compData = _compData as FactoryInternalProcessor; const compData = _compData as FactoryInternalProcessor;
// factory part // factory part
// PRODUCTION // PRODUCTION
data.ticksDone += factoryTicks;
if (data.ticksDone >= factoryData.tick) { if (data.ticksDone >= factoryData.tick) {
if (compData.canProduce.value) { if (compData.canProduce.value) {
const cyclesDone = Math.floor(data.ticksDone / factoryData.tick); const cyclesDone = Math.floor(data.ticksDone / factoryData.tick);
@ -1678,8 +1676,6 @@ const factory = createLayer(id, () => {
if (compData.lastProdTimes.length > 10) compData.lastProdTimes.shift(); if (compData.lastProdTimes.length > 10) compData.lastProdTimes.shift();
compData.lastFactoryProd = now; compData.lastFactoryProd = now;
} }
} else {
data.ticksDone += factoryTicks;
} }
// now look at each component direction and see if it accepts items coming in // now look at each component direction and see if it accepts items coming in
// components are 1x1 so simple math for now // components are 1x1 so simple math for now