mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Update storage to also return if its full or not
This commit is contained in:
parent
1dab9539bf
commit
349657bafc
@ -1,15 +1,15 @@
|
|||||||
|
import { formatBigNumber } from "../../core/utils";
|
||||||
import { enumDirection, Vector } from "../../core/vector";
|
import { enumDirection, Vector } from "../../core/vector";
|
||||||
|
import { T } from "../../translations";
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
import { Entity } from "../entity";
|
|
||||||
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
|
||||||
import { GameRoot } from "../root";
|
|
||||||
import { StorageComponent } from "../components/storage";
|
import { StorageComponent } from "../components/storage";
|
||||||
import { T } from "../../translations";
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
import { formatBigNumber } from "../../core/utils";
|
import { Entity } from "../entity";
|
||||||
import { WiredPinsComponent, enumPinSlotType } from "../components/wired_pins";
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||||
|
import { GameRoot } from "../root";
|
||||||
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumTrashVariants = { storage: "storage" };
|
export const enumTrashVariants = { storage: "storage" };
|
||||||
@ -145,15 +145,22 @@ export class MetaTrashBuilding extends MetaBuilding {
|
|||||||
entity.addComponent(new StorageComponent({}));
|
entity.addComponent(new StorageComponent({}));
|
||||||
}
|
}
|
||||||
if (!entity.components.WiredPins) {
|
if (!entity.components.WiredPins) {
|
||||||
entity.addComponent(new WiredPinsComponent({
|
entity.addComponent(
|
||||||
slots: [
|
new WiredPinsComponent({
|
||||||
{
|
slots: [
|
||||||
pos: new Vector(1, 1),
|
{
|
||||||
direction: enumDirection.right,
|
pos: new Vector(1, 1),
|
||||||
type: enumPinSlotType.logicalEjector
|
direction: enumDirection.right,
|
||||||
}
|
type: enumPinSlotType.logicalEjector,
|
||||||
]
|
},
|
||||||
}));
|
{
|
||||||
|
pos: new Vector(0, 1),
|
||||||
|
direction: enumDirection.left,
|
||||||
|
type: enumPinSlotType.logicalEjector,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.components.Storage.maximumStorage = trashSize;
|
entity.components.Storage.maximumStorage = trashSize;
|
||||||
|
@ -2,6 +2,8 @@ import { types } from "../../savegame/serialization";
|
|||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem, enumItemType } from "../base_item";
|
||||||
import { Component } from "../component";
|
import { Component } from "../component";
|
||||||
import { typeItemSingleton } from "../item_resolver";
|
import { typeItemSingleton } from "../item_resolver";
|
||||||
|
import { ColorItem } from "../items/color_item";
|
||||||
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
|
||||||
export class StorageComponent extends Component {
|
export class StorageComponent extends Component {
|
||||||
static getId() {
|
static getId() {
|
||||||
@ -76,6 +78,14 @@ export class StorageComponent extends Component {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the storage is full
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
getIsFull() {
|
||||||
|
return this.storedCount >= this.maximumStorage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {BaseItem} item
|
* @param {BaseItem} item
|
||||||
*/
|
*/
|
||||||
|
@ -4,7 +4,7 @@ import { Entity } from "../entity";
|
|||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { formatBigNumber, lerp } from "../../core/utils";
|
import { formatBigNumber, lerp } from "../../core/utils";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { enumLayer } from "../root";
|
import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON } from "../items/boolean_item";
|
||||||
|
|
||||||
export class StorageSystem extends GameSystemWithFilter {
|
export class StorageSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
@ -39,6 +39,7 @@ export class StorageSystem extends GameSystemWithFilter {
|
|||||||
storageComp.overlayOpacity = lerp(storageComp.overlayOpacity, targetAlpha, 0.05);
|
storageComp.overlayOpacity = lerp(storageComp.overlayOpacity, targetAlpha, 0.05);
|
||||||
|
|
||||||
pinsComp.slots[0].value = storageComp.storedItem;
|
pinsComp.slots[0].value = storageComp.storedItem;
|
||||||
|
pinsComp.slots[1].value = storageComp.getIsFull() ? BOOL_TRUE_SINGLETON : BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user