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,
|
readerAnalyzeIntervalSeconds: 10,
|
||||||
|
|
||||||
goalAcceptorMinimumDurationSeconds: 5,
|
goalAcceptorItemsRequired: 10,
|
||||||
goalAcceptorsPerProducer: 4.5,
|
goalAcceptorsPerProducer: 5,
|
||||||
puzzleModeSpeed: 3,
|
puzzleModeSpeed: 3,
|
||||||
puzzleMinBoundsSize: 2,
|
puzzleMinBoundsSize: 2,
|
||||||
puzzleMaxBoundsSize: 20,
|
puzzleMaxBoundsSize: 20,
|
||||||
|
|
|
@ -31,19 +31,26 @@ export class GoalAcceptorComponent extends Component {
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
// the last items we delivered
|
// the last items we delivered
|
||||||
/** @type {{ item: BaseItem; time: number; }[]} */
|
/** @type {{ item: BaseItem; time: number; }} */
|
||||||
this.deliveryHistory = [];
|
this.lastDelivery = null;
|
||||||
|
|
||||||
|
this.currentDeliveredItems = 0;
|
||||||
|
|
||||||
// Used for animations
|
// Used for animations
|
||||||
this.displayPercentage = 0;
|
this.displayPercentage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRequiredDeliveryHistorySize() {
|
// clears items but doesn't instantly reset the progress bar
|
||||||
|
clearItems() {
|
||||||
|
this.lastDelivery = null;
|
||||||
|
|
||||||
|
this.currentDeliveredItems = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
getRequiredSecondsPerItem() {
|
||||||
return (
|
return (
|
||||||
(globalConfig.puzzleModeSpeed *
|
globalConfig.goalAcceptorsPerProducer /
|
||||||
globalConfig.goalAcceptorMinimumDurationSeconds *
|
(globalConfig.puzzleModeSpeed * globalConfig.beltSpeedItemsPerSecond)
|
||||||
globalConfig.beltSpeedItemsPerSecond) /
|
|
||||||
globalConfig.goalAcceptorsPerProducer
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,8 +216,8 @@ export class HUDPuzzleEditorReview extends BaseHUDPart {
|
||||||
if (!goalComp.item) {
|
if (!goalComp.item) {
|
||||||
return T.puzzleMenu.validation.goalAcceptorNoItem;
|
return T.puzzleMenu.validation.goalAcceptorNoItem;
|
||||||
}
|
}
|
||||||
const required = goalComp.getRequiredDeliveryHistorySize();
|
const required = globalConfig.goalAcceptorItemsRequired;
|
||||||
if (goalComp.deliveryHistory.length < required) {
|
if (goalComp.currentDeliveredItems < required) {
|
||||||
return T.puzzleMenu.validation.goalAcceptorRateNotMet;
|
return T.puzzleMenu.validation.goalAcceptorRateNotMet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,15 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||||
const entity = this.allEntities[i];
|
const entity = this.allEntities[i];
|
||||||
const goalComp = entity.components.GoalAcceptor;
|
const goalComp = entity.components.GoalAcceptor;
|
||||||
|
|
||||||
// filter the ones which are no longer active, or which are not the same
|
if (!goalComp.lastDelivery) {
|
||||||
goalComp.deliveryHistory = goalComp.deliveryHistory.filter(
|
continue;
|
||||||
d =>
|
}
|
||||||
now - d.time < globalConfig.goalAcceptorMinimumDurationSeconds && d.item === goalComp.item
|
|
||||||
);
|
|
||||||
|
|
||||||
if (goalComp.deliveryHistory.length < goalComp.getRequiredDeliveryHistorySize()) {
|
if (now - goalComp.lastDelivery.time > goalComp.getRequiredSecondsPerItem()) {
|
||||||
|
goalComp.clearItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goalComp.currentDeliveredItems < globalConfig.goalAcceptorItemsRequired) {
|
||||||
allAccepted = false;
|
allAccepted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,8 +66,8 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||||
const staticComp = contents[i].components.StaticMapEntity;
|
const staticComp = contents[i].components.StaticMapEntity;
|
||||||
const item = goalComp.item;
|
const item = goalComp.item;
|
||||||
|
|
||||||
const requiredItemsForSuccess = goalComp.getRequiredDeliveryHistorySize();
|
const requiredItemsForSuccess = globalConfig.goalAcceptorItemsRequired;
|
||||||
const percentage = clamp(goalComp.deliveryHistory.length / requiredItemsForSuccess, 0, 1);
|
const percentage = clamp(goalComp.currentDeliveredItems / requiredItemsForSuccess, 0, 1);
|
||||||
|
|
||||||
const center = staticComp.getTileSpaceBounds().getCenter().toWorldSpace();
|
const center = staticComp.getTileSpaceBounds().getCenter().toWorldSpace();
|
||||||
if (item) {
|
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.translate(center.x, center.y);
|
||||||
parameters.context.rotate((staticComp.rotation / 180) * Math.PI);
|
parameters.context.rotate((staticComp.rotation / 180) * Math.PI);
|
||||||
|
@ -90,7 +92,7 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||||
|
|
||||||
// progress arc
|
// 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 startAngle = Math.PI * 0.595;
|
||||||
const maxAngle = Math.PI * 1.82;
|
const maxAngle = Math.PI * 1.82;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { globalConfig } from "../../core/config";
|
||||||
import { BaseItem } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumColorMixingResults, enumColors } from "../colors";
|
import { enumColorMixingResults, enumColors } from "../colors";
|
||||||
import {
|
import {
|
||||||
|
@ -572,23 +573,23 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||||
const item = payload.items[0].item;
|
const item = payload.items[0].item;
|
||||||
const now = this.root.time.now();
|
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()) {
|
if (this.root.gameMode.getIsEditor()) {
|
||||||
// while playing in editor, assign the item
|
// while playing in editor, assign the item
|
||||||
goalComp.item = payload.items[0].item;
|
goalComp.item = payload.items[0].item;
|
||||||
goalComp.deliveryHistory.push({
|
}
|
||||||
|
|
||||||
|
goalComp.lastDelivery = {
|
||||||
item,
|
item,
|
||||||
time: now,
|
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 = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue