1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

adjusted how acceptor works to fix macro

This commit is contained in:
Sense101 2021-06-23 20:23:34 +01:00
parent 1046d1d354
commit f16d01365f
4 changed files with 42 additions and 33 deletions

View File

@ -72,8 +72,8 @@ export const globalConfig = {
readerAnalyzeIntervalSeconds: 10,
goalAcceptorMinimumDurationSeconds: 5,
goalAcceptorsPerProducer: 4.5,
goalAcceptorItemsRequired: 10,
goalAcceptorsPerProducer: 5,
puzzleModeSpeed: 3,
puzzleMinBoundsSize: 2,
puzzleMaxBoundsSize: 20,

View File

@ -31,19 +31,19 @@ export class GoalAcceptorComponent extends Component {
clear() {
// the last items we delivered
/** @type {{ item: BaseItem; time: number; }[]} */
this.deliveryHistory = [];
/** @type {{ item: BaseItem; time: number; }} */
this.lastDelivery = null;
this.currentDeliveredItems = 0;
// Used for animations
this.displayPercentage = 0;
}
getRequiredDeliveryHistorySize() {
getRequiredItemsPerSecond() {
return (
(globalConfig.puzzleModeSpeed *
globalConfig.goalAcceptorMinimumDurationSeconds *
globalConfig.beltSpeedItemsPerSecond) /
globalConfig.goalAcceptorsPerProducer
globalConfig.goalAcceptorsPerProducer /
(globalConfig.puzzleModeSpeed * globalConfig.beltSpeedItemsPerSecond)
);
}
}

View File

@ -24,13 +24,22 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
const entity = this.allEntities[i];
const goalComp = entity.components.GoalAcceptor;
// filter the ones which are no longer active, or which are not the same
goalComp.deliveryHistory = goalComp.deliveryHistory.filter(
d =>
now - d.time < globalConfig.goalAcceptorMinimumDurationSeconds && d.item === goalComp.item
);
if (!goalComp.lastDelivery) {
continue;
}
if (goalComp.deliveryHistory.length < goalComp.getRequiredDeliveryHistorySize()) {
if (now - goalComp.lastDelivery.time > goalComp.getRequiredItemsPerSecond()) {
goalComp.lastDelivery = null;
goalComp.currentDeliveredItems = 0;
}
//// filter the ones which are no longer active, or which are not the same
//goalComp.deliveryHistory = goalComp.deliveryHistory.filter(
// d =>
// now - d.time < globalConfig.goalAcceptorMinimumDurationSeconds && d.item === goalComp.item
//);
if (goalComp.currentDeliveredItems < globalConfig.goalAcceptorItemsRequired) {
allAccepted = false;
}
}
@ -64,8 +73,8 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
const staticComp = contents[i].components.StaticMapEntity;
const item = goalComp.item;
const requiredItemsForSuccess = goalComp.getRequiredDeliveryHistorySize();
const percentage = clamp(goalComp.deliveryHistory.length / requiredItemsForSuccess, 0, 1);
const requiredItemsForSuccess = globalConfig.goalAcceptorItemsRequired;
const percentage = clamp(goalComp.currentDeliveredItems / requiredItemsForSuccess, 0, 1);
const center = staticComp.getTileSpaceBounds().getCenter().toWorldSpace();
if (item) {
@ -78,7 +87,7 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
);
}
const isValid = item && goalComp.deliveryHistory.length >= requiredItemsForSuccess;
const isValid = item && goalComp.currentDeliveredItems >= requiredItemsForSuccess;
parameters.context.translate(center.x, center.y);
parameters.context.rotate((staticComp.rotation / 180) * Math.PI);
@ -90,7 +99,7 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
// progress arc
goalComp.displayPercentage = lerp(goalComp.displayPercentage, percentage, 0.3);
goalComp.displayPercentage = lerp(goalComp.displayPercentage, percentage, 0.2);
const startAngle = Math.PI * 0.595;
const maxAngle = Math.PI * 1.82;

View File

@ -1,3 +1,4 @@
import { globalConfig } from "../../core/config";
import { BaseItem } from "../base_item";
import { enumColorMixingResults, enumColors } from "../colors";
import {
@ -572,23 +573,22 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const item = payload.items[0].item;
const now = this.root.time.now();
goalComp.currentDeliveredItems = Math.min(
goalComp.currentDeliveredItems + 1,
globalConfig.goalAcceptorItemsRequired
);
if (this.root.gameMode.getIsEditor()) {
// while playing in editor, assign the item
goalComp.item = payload.items[0].item;
goalComp.deliveryHistory.push({
item,
time: now,
});
} else {
// otherwise, make sure it is the same, otherwise reset
if (item.equals(goalComp.item)) {
goalComp.deliveryHistory.push({
item,
time: now,
});
} else {
goalComp.deliveryHistory = [];
}
} else if (!item.equals(goalComp.item)) {
// if the inputted item isn't the same, clear the acceptor
goalComp.clear();
}
goalComp.lastDelivery = {
item,
time: now,
};
}
}