mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Add storage shape ejector pin (#568)
This commit is contained in:
parent
8c39d31c5b
commit
1dab9539bf
@ -9,6 +9,7 @@ import { GameRoot } from "../root";
|
|||||||
import { StorageComponent } from "../components/storage";
|
import { StorageComponent } from "../components/storage";
|
||||||
import { T } from "../../translations";
|
import { T } from "../../translations";
|
||||||
import { formatBigNumber } from "../../core/utils";
|
import { formatBigNumber } from "../../core/utils";
|
||||||
|
import { WiredPinsComponent, enumPinSlotType } from "../components/wired_pins";
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumTrashVariants = { storage: "storage" };
|
export const enumTrashVariants = { storage: "storage" };
|
||||||
@ -117,6 +118,9 @@ export class MetaTrashBuilding extends MetaBuilding {
|
|||||||
if (entity.components.Storage) {
|
if (entity.components.Storage) {
|
||||||
entity.removeComponent(StorageComponent);
|
entity.removeComponent(StorageComponent);
|
||||||
}
|
}
|
||||||
|
if (entity.components.WiredPins) {
|
||||||
|
entity.removeComponent(WiredPinsComponent);
|
||||||
|
}
|
||||||
|
|
||||||
entity.components.ItemAcceptor.setSlots([
|
entity.components.ItemAcceptor.setSlots([
|
||||||
{
|
{
|
||||||
@ -140,6 +144,17 @@ export class MetaTrashBuilding extends MetaBuilding {
|
|||||||
if (!entity.components.Storage) {
|
if (!entity.components.Storage) {
|
||||||
entity.addComponent(new StorageComponent({}));
|
entity.addComponent(new StorageComponent({}));
|
||||||
}
|
}
|
||||||
|
if (!entity.components.WiredPins) {
|
||||||
|
entity.addComponent(new WiredPinsComponent({
|
||||||
|
slots: [
|
||||||
|
{
|
||||||
|
pos: new Vector(1, 1),
|
||||||
|
direction: enumDirection.right,
|
||||||
|
type: enumPinSlotType.logicalEjector
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
entity.components.Storage.maximumStorage = trashSize;
|
entity.components.Storage.maximumStorage = trashSize;
|
||||||
entity.components.ItemAcceptor.setSlots([
|
entity.components.ItemAcceptor.setSlots([
|
||||||
|
@ -17,6 +17,7 @@ export class StorageSystem extends GameSystemWithFilter {
|
|||||||
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 storageComp = entity.components.Storage;
|
const storageComp = entity.components.Storage;
|
||||||
|
const pinsComp = entity.components.WiredPins;
|
||||||
|
|
||||||
// Eject from storage
|
// Eject from storage
|
||||||
if (storageComp.storedItem && storageComp.storedCount > 0) {
|
if (storageComp.storedItem && storageComp.storedCount > 0) {
|
||||||
@ -36,6 +37,8 @@ export class StorageSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
let targetAlpha = storageComp.storedCount > 0 ? 1 : 0;
|
let targetAlpha = storageComp.storedCount > 0 ? 1 : 0;
|
||||||
storageComp.overlayOpacity = lerp(storageComp.overlayOpacity, targetAlpha, 0.05);
|
storageComp.overlayOpacity = lerp(storageComp.overlayOpacity, targetAlpha, 0.05);
|
||||||
|
|
||||||
|
pinsComp.slots[0].value = storageComp.storedItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user