mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 10:11:50 +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,
|
direction: enumDirection.bottom,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
lengthMultiplier: 3, // make progress 1.5 to reach the ejector
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -44,14 +44,6 @@ import { GameRoot } from "../root";
|
|||||||
* }} InputCompletedArgs
|
* }} InputCompletedArgs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @enum {string} */
|
|
||||||
const enumItemAcceptorTypes = {
|
|
||||||
hub: "hub",
|
|
||||||
storage: "storage",
|
|
||||||
trash: "trash",
|
|
||||||
undergroundBelt: "undergroundBelt",
|
|
||||||
};
|
|
||||||
|
|
||||||
export class ItemAcceptorComponent extends Component {
|
export class ItemAcceptorComponent extends Component {
|
||||||
static getId() {
|
static getId() {
|
||||||
return "ItemAcceptor";
|
return "ItemAcceptor";
|
||||||
@ -61,9 +53,9 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
*
|
*
|
||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {Array<ItemAcceptorSlotConfig>} param0.slots The slots from which we accept items
|
* @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();
|
super();
|
||||||
|
|
||||||
/** @type {ItemAcceptorInputs} */
|
/** @type {ItemAcceptorInputs} */
|
||||||
@ -71,6 +63,7 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
/** @type {ItemAcceptorCompletedInputs} */
|
/** @type {ItemAcceptorCompletedInputs} */
|
||||||
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
this.completedInputs = new Map(); // @SENSETODO does this need to be saved?
|
||||||
this.setSlots(slots);
|
this.setSlots(slots);
|
||||||
|
this.progressLength = 0.5 * lengthMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +103,7 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
this.inputs.set(slotIndex, {
|
this.inputs.set(slotIndex, {
|
||||||
item,
|
item,
|
||||||
direction,
|
direction,
|
||||||
animProgress: Math.min(1, startProgress),
|
animProgress: Math.min(this.progressLength, startProgress),
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,13 +18,12 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
|
|||||||
this.root.dynamicTickrate.deltaSeconds *
|
this.root.dynamicTickrate.deltaSeconds *
|
||||||
this.root.hubGoals.getBeltBaseSpeed() *
|
this.root.hubGoals.getBeltBaseSpeed() *
|
||||||
globalConfig.itemSpacingOnBelts;
|
globalConfig.itemSpacingOnBelts;
|
||||||
// it's only half a belt
|
|
||||||
const maxProgress = 0.5;
|
|
||||||
|
|
||||||
for (let i = 0; i < this.allEntities.length; ++i) {
|
for (let i = 0; i < this.allEntities.length; ++i) {
|
||||||
const entity = this.allEntities[i];
|
const entity = this.allEntities[i];
|
||||||
const acceptorComp = entity.components.ItemAcceptor;
|
const acceptorComp = entity.components.ItemAcceptor;
|
||||||
const inputs = acceptorComp.inputs;
|
const inputs = acceptorComp.inputs;
|
||||||
|
const maxProgress = acceptorComp.progressLength;
|
||||||
|
|
||||||
inputs.forEach((values, index) => {
|
inputs.forEach((values, index) => {
|
||||||
values.animProgress += progressGrowth;
|
values.animProgress += progressGrowth;
|
||||||
|
|||||||
@ -205,8 +205,13 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
case enumItemProcessorRequirements.painterQuad: {
|
case enumItemProcessorRequirements.painterQuad: {
|
||||||
const pinsComp = entity.components.WiredPins;
|
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
|
// 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) {
|
if (!shapeItem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user