1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Add support for different building variants

This commit is contained in:
tobspr
2020-05-16 22:45:40 +02:00
parent 436f700606
commit 5e3c28c150
66 changed files with 1196 additions and 466 deletions

View File

@@ -13,6 +13,7 @@ export const enumItemProcessorTypes = {
trash: "trash",
mixer: "mixer",
painter: "painter",
painterDouble: "painterDouble",
hub: "hub",
};
@@ -60,12 +61,16 @@ export class ItemProcessorComponent extends Component {
/**
*
* @param {object} param0
* @param {enumItemProcessorTypes} param0.processorType Which type of processor this is
* @param {number} param0.inputsPerCharge How many items this machine needs until it can start working
* @param {enumItemProcessorTypes=} param0.processorType Which type of processor this is
* @param {number=} param0.inputsPerCharge How many items this machine needs until it can start working
* @param {Array<{pos: Vector, direction: enumDirection}>=} param0.beltUnderlays Where to render belt underlays
*
*/
constructor({ processorType = enumItemProcessorTypes.splitter, inputsPerCharge, beltUnderlays = [] }) {
constructor({
processorType = enumItemProcessorTypes.splitter,
inputsPerCharge = 1,
beltUnderlays = [],
}) {
super();
// Which slot to emit next, this is only a preference and if it can't emit

View File

@@ -1,6 +1,10 @@
import { globalConfig } from "../../core/config";
import { types } from "../../savegame/serialization";
import { Component } from "../component";
import { BaseItem } from "../base_item";
import { gItemRegistry } from "../../core/global_registries";
const chainBufferSize = 10;
export class MinerComponent extends Component {
static getId() {
@@ -10,13 +14,37 @@ export class MinerComponent extends Component {
static getSchema() {
return {
lastMiningTime: types.ufloat,
chainable: types.bool,
itemChainBuffer: types.array(types.obj(gItemRegistry)),
};
}
/**
*/
constructor() {
constructor({ chainable = false }) {
super();
this.lastMiningTime = 0;
this.chainable = chainable;
/**
* Stores items from other miners which were chained to this
* miner.
* @type {Array<BaseItem>}
*/
this.itemChainBuffer = [];
}
/**
*
* @param {BaseItem} item
*/
tryAcceptChainedItem(item) {
if (this.itemChainBuffer.length > chainBufferSize) {
// Well, this one is full
return false;
}
this.itemChainBuffer.push(item);
return true;
}
}