Fix for cheating puzzles by quickly switching belts (#1226)
* added the new splitter * Update base-en.yaml * adjusted how acceptor works to fix macro * fixed a minor bug * applied changes to the puzzle-editor-review script * minor cleanups
This commit is contained in:
parent
68f208181d
commit
6efbdc6ad1
|
@ -72,8 +72,8 @@ export const globalConfig = {
|
|||
|
||||
readerAnalyzeIntervalSeconds: 10,
|
||||
|
||||
goalAcceptorMinimumDurationSeconds: 5,
|
||||
goalAcceptorsPerProducer: 4.5,
|
||||
goalAcceptorItemsRequired: 10,
|
||||
goalAcceptorsPerProducer: 5,
|
||||
puzzleModeSpeed: 3,
|
||||
puzzleMinBoundsSize: 2,
|
||||
puzzleMaxBoundsSize: 20,
|
||||
|
|
|
@ -31,19 +31,26 @@ 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() {
|
||||
// clears items but doesn't instantly reset the progress bar
|
||||
clearItems() {
|
||||
this.lastDelivery = null;
|
||||
|
||||
this.currentDeliveredItems = 0;
|
||||
}
|
||||
|
||||
getRequiredSecondsPerItem() {
|
||||
return (
|
||||
(globalConfig.puzzleModeSpeed *
|
||||
globalConfig.goalAcceptorMinimumDurationSeconds *
|
||||
globalConfig.beltSpeedItemsPerSecond) /
|
||||
globalConfig.goalAcceptorsPerProducer
|
||||
globalConfig.goalAcceptorsPerProducer /
|
||||
(globalConfig.puzzleModeSpeed * globalConfig.beltSpeedItemsPerSecond)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,8 +216,8 @@ export class HUDPuzzleEditorReview extends BaseHUDPart {
|
|||
if (!goalComp.item) {
|
||||
return T.puzzleMenu.validation.goalAcceptorNoItem;
|
||||
}
|
||||
const required = goalComp.getRequiredDeliveryHistorySize();
|
||||
if (goalComp.deliveryHistory.length < required) {
|
||||
const required = globalConfig.goalAcceptorItemsRequired;
|
||||
if (goalComp.currentDeliveredItems < required) {
|
||||
return T.puzzleMenu.validation.goalAcceptorRateNotMet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,15 @@ 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.getRequiredSecondsPerItem()) {
|
||||
goalComp.clearItems();
|
||||
}
|
||||
|
||||
if (goalComp.currentDeliveredItems < globalConfig.goalAcceptorItemsRequired) {
|
||||
allAccepted = false;
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +66,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 +80,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 +92,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;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { globalConfig } from "../../core/config";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { enumColorMixingResults, enumColors } from "../colors";
|
||||
import {
|
||||
|
@ -572,23 +573,23 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||
const item = payload.items[0].item;
|
||||
const now = this.root.time.now();
|
||||
|
||||
if (goalComp.item && !item.equals(goalComp.item)) {
|
||||
goalComp.clearItems();
|
||||
} else {
|
||||
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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
goalComp.lastDelivery = {
|
||||
item,
|
||||
time: now,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue