mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
|
|
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;
|
||
|
|
}
|
||
|
|
}
|