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

Further progress on the energy generator / wires, fix translations

This commit is contained in:
tobspr
2020-07-01 17:51:11 +02:00
parent 030194f5b8
commit bd899df5fe
53 changed files with 1243 additions and 893 deletions

View File

@@ -0,0 +1,34 @@
import { Component } from "../component";
import { types } from "../../savegame/serialization";
import { Vector } from "../../core/vector";
export class EnergyConsumerComponent extends Component {
static getId() {
return "EnergyConsumer";
}
static getSchema() {
return {
bufferSize: types.uint,
perCharge: types.uint,
stored: types.uint,
batteryPosition: types.vector,
};
}
/**
*
* @param {object} param0
* @param {number} param0.bufferSize How much energy this consumer can store
* @param {number} param0.perCharge How much energy this consumer needs per charge
* @param {Vector} param0.batteryPosition world space render offset of the battery icon
*/
constructor({ bufferSize = 3, perCharge = 1, batteryPosition = new Vector() }) {
super();
this.bufferSize = bufferSize;
this.perCharge = perCharge;
this.batteryPosition = batteryPosition;
this.stored = 0;
}
}

View File

@@ -5,9 +5,6 @@ import { ShapeItem } from "../items/shape_item";
const maxQueueSize = 20;
export const ENERGY_GENERATOR_EJECT_SLOT = 0;
export const ENERGY_GENERATOR_ACCEPT_SLOT = 4;
export class EnergyGeneratorComponent extends Component {
static getId() {
return "EnergyGenerator";
@@ -24,8 +21,9 @@ export class EnergyGeneratorComponent extends Component {
*
* @param {object} param0
* @param {string} param0.requiredKey Which shape this generator needs, can be null if not computed yet
* @param {number} param0.acceptorSlotIndex
*/
constructor({ requiredKey }) {
constructor({ requiredKey, acceptorSlotIndex = 0 }) {
super();
this.requiredKey = requiredKey;
@@ -34,6 +32,12 @@ export class EnergyGeneratorComponent extends Component {
* @type {number}
*/
this.itemsInQueue = 0;
/**
* Stores which slot accepts the waste
* @type {number}
*/
this.acceptorSlotIndex = acceptorSlotIndex;
}
/**
@@ -42,7 +46,7 @@ export class EnergyGeneratorComponent extends Component {
* @param {number} slot
*/
tryTakeItem(item, slot) {
if (slot === ENERGY_GENERATOR_ACCEPT_SLOT) {
if (slot === this.acceptorSlotIndex) {
// this is the acceptor slot on the wires layer
// just destroy it
return true;