mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 02:01:51 +00:00
add acceptor extension option to fix storage
This commit is contained in:
parent
638cdc2733
commit
b2ec3322b8
@ -81,6 +81,7 @@ export class MetaStorageBuilding extends MetaBuilding {
|
||||
direction: enumDirection.bottom,
|
||||
},
|
||||
],
|
||||
lengthMultiplier: 3, // make progress 1.5 to reach the ejector
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@ -44,14 +44,6 @@ import { GameRoot } from "../root";
|
||||
* }} InputCompletedArgs
|
||||
*/
|
||||
|
||||
/** @enum {string} */
|
||||
const enumItemAcceptorTypes = {
|
||||
hub: "hub",
|
||||
storage: "storage",
|
||||
trash: "trash",
|
||||
undergroundBelt: "undergroundBelt",
|
||||
};
|
||||
|
||||
export class ItemAcceptorComponent extends Component {
|
||||
static getId() {
|
||||
return "ItemAcceptor";
|
||||
@ -61,9 +53,9 @@ export class ItemAcceptorComponent extends Component {
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {Array<ItemAcceptorSlotConfig>} param0.slots The slots from which we accept items
|
||||
* @param {enumItemAcceptorTypes=} param0.type Function that gets called when the input of an item is completed
|
||||
* @param {number=} param0.lengthMultiplier Whether the acceptor is double the usual length
|
||||
*/
|
||||
constructor({ slots = [] }) {
|
||||
constructor({ slots = [], lengthMultiplier = 1 }) {
|
||||
super();
|
||||
|
||||
/** @type {ItemAcceptorInputs} */
|
||||
@ -71,6 +63,7 @@ export class ItemAcceptorComponent extends Component {
|
||||
/** @type {ItemAcceptorCompletedInputs} */
|
||||
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
||||
this.setSlots(slots);
|
||||
this.progressLength = 0.5 * lengthMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +103,7 @@ export class ItemAcceptorComponent extends Component {
|
||||
this.inputs.set(slotIndex, {
|
||||
item,
|
||||
direction,
|
||||
animProgress: Math.min(1, startProgress),
|
||||
animProgress: Math.min(this.progressLength, startProgress),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -18,13 +18,12 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||
this.root.dynamicTickrate.deltaSeconds *
|
||||
this.root.hubGoals.getBeltBaseSpeed() *
|
||||
globalConfig.itemSpacingOnBelts;
|
||||
// it's only half a belt
|
||||
const maxProgress = 0.5;
|
||||
|
||||
for (let i = 0; i < this.allEntities.length; ++i) {
|
||||
const entity = this.allEntities[i];
|
||||
const acceptorComp = entity.components.ItemAcceptor;
|
||||
const inputs = acceptorComp.inputs;
|
||||
const maxProgress = acceptorComp.progressLength;
|
||||
|
||||
inputs.forEach((values, index) => {
|
||||
values.animProgress += progressGrowth;
|
||||
|
||||
@ -205,8 +205,13 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
case enumItemProcessorRequirements.painterQuad: {
|
||||
const pinsComp = entity.components.WiredPins;
|
||||
|
||||
const input = acceptorComp.inputs.get(0);
|
||||
if (!input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// First slot is the shape, so if it's not there we can't do anything
|
||||
const shapeItem = /** @type {ShapeItem} */ (acceptorComp.inputs.get(0).item);
|
||||
const shapeItem = /** @type {ShapeItem} */ (input.item);
|
||||
if (!shapeItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user