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

finish 4-painer fix

This commit is contained in:
dengr1065 2020-08-18 19:47:31 +03:00
parent 9af135b5ce
commit 3a5aa11b67
2 changed files with 13 additions and 21 deletions

View File

@ -66,10 +66,9 @@ export class ProcessingRequirementComponent extends Component {
if ((netValue == null || !netValue.equals(BOOL_TRUE_SINGLETON)) && currentItem == null) { if ((netValue == null || !netValue.equals(BOOL_TRUE_SINGLETON)) && currentItem == null) {
let quadCount = 0; let quadCount = 0;
const quadNumber = (i + 3) % 4
for (let j = 0; j < 4; ++j) { for (let j = 0; j < 4; ++j) {
const layer = shapeItem.definition.layers[j]; const layer = shapeItem.definition.layers[j];
if (layer && layer[quadNumber]) { if (layer && layer[i]) {
quadCount++; quadCount++;
} }
} }

View File

@ -1,6 +1,6 @@
import { globalConfig } from "../../core/config"; import { globalConfig } from "../../core/config";
import { BaseItem } from "../base_item"; import { BaseItem } from "../base_item";
import { enumColorMixingResults } from "../colors"; import { enumColors, enumColorMixingResults } from "../colors";
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor"; import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
import { Entity } from "../entity"; import { Entity } from "../entity";
import { GameSystemWithFilter } from "../game_system_with_filter"; import { GameSystemWithFilter } from "../game_system_with_filter";
@ -320,7 +320,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
/** @type {Array<ColorItem>} */ /** @type {Array<ColorItem>} */
const colorItems = [].fill(null, 0, 4); const colorItems = [].fill(null, 0, 4);
for (let i = 0; i < colorItems.length; ++i) { for (let i = 0; i < 4; ++i) {
if (itemsBySlot[i + 1]) { if (itemsBySlot[i + 1]) {
colorItems[i] = /** @type {ColorItem} */ (itemsBySlot[i + 1].item); colorItems[i] = /** @type {ColorItem} */ (itemsBySlot[i + 1].item);
assert(colorItems[i] instanceof ColorItem, "Input for painter is not a color"); assert(colorItems[i] instanceof ColorItem, "Input for painter is not a color");
@ -338,7 +338,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
/** @type {Array<boolean>} */ /** @type {Array<boolean>} */
let skipped = []; let skipped = [];
for (let i = 0; i < pinValues.length; ++i) { for (let i = 0; i < 4; ++i) {
skipped[i] = pinValues[i] ? pinValues[i].equals(BOOL_TRUE_SINGLETON) : false; skipped[i] = pinValues[i] ? pinValues[i].equals(BOOL_TRUE_SINGLETON) : false;
} }
@ -355,25 +355,18 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
} }
} }
const colorizedDefinition = this.root.shapeDefinitionMgr.shapeActionPaintWith4Colors( const toColor = [
shapeItem.definition,
[
(!skipped[0] && colorTL) ? colorTL.color : null, (!skipped[0] && colorTL) ? colorTL.color : null,
(!skipped[1] && colorTR) ? colorTR.color : null, (!skipped[1] && colorTR) ? colorTR.color : null,
(!skipped[2] && colorBR) ? colorBR.color : null, (!skipped[2] && colorBR) ? colorBR.color : null,
(!skipped[3] && colorBL) ? colorBL.color : null, (!skipped[3] && colorBL) ? colorBL.color : null,
] ];
); console.table([colorTL, skipped[0], colorTR, skipped[1]]);
// restore items we didn't use const colorizedDefinition = this.root.shapeDefinitionMgr.shapeActionPaintWith4Colors(
for (let i = 0; i < 4; ++i) { shapeItem.definition,
if (skipped[i]) { /** @type {[enumColors, enumColors, enumColors, enumColors]} */(toColor)
processorComp.inputSlots.push({ );
item: colorItems[i],
sourceSlot: i + 1
});
}
}
outItems.push({ outItems.push({
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition), item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition),