mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Add MetaBuilding for item buffer
This commit is contained in:
parent
b921bcf205
commit
1a6b64f914
73
src/js/game/buildings/buffer.js
Normal file
73
src/js/game/buildings/buffer.js
Normal file
@ -0,0 +1,73 @@
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { ItemAcceptorComponent, enumItemAcceptorItemFilter } from "../components/item_acceptor";
|
||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||
import { Entity } from "../entity";
|
||||
import { MetaBuilding } from "../meta_building";
|
||||
import { GameRoot } from "../root";
|
||||
|
||||
export class MetaBufferBuilding extends MetaBuilding {
|
||||
constructor() {
|
||||
super("buffer");
|
||||
}
|
||||
|
||||
getSilhouetteColor() {
|
||||
return "#621940";
|
||||
}
|
||||
|
||||
getDimensions() {
|
||||
return new Vector(3, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {GameRoot} root
|
||||
*/
|
||||
getIsUnlocked(root) {
|
||||
// TODO: Add as level reward
|
||||
// return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_stacker);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the entity at the given location
|
||||
* @param {Entity} entity
|
||||
*/
|
||||
setupEntityComponents(entity) {
|
||||
// TODO: Use custom component here to allow for smooth output
|
||||
entity.addComponent(
|
||||
new ItemProcessorComponent({
|
||||
inputsPerCharge: 1,
|
||||
processorType: enumItemProcessorTypes.buffer,
|
||||
})
|
||||
);
|
||||
|
||||
entity.addComponent(
|
||||
new ItemEjectorComponent({
|
||||
slots: [{ pos: new Vector(1, 0), direction: enumDirection.top }],
|
||||
})
|
||||
);
|
||||
|
||||
// TODO: Replace item filters with custom filter to only allow one type of item to be collected.
|
||||
entity.addComponent(
|
||||
new ItemAcceptorComponent({
|
||||
slots: [
|
||||
{
|
||||
pos: new Vector(0, 1),
|
||||
directions: [enumDirection.left],
|
||||
filter: enumItemAcceptorItemFilter.any,
|
||||
},
|
||||
{
|
||||
pos: new Vector(1, 2),
|
||||
directions: [enumDirection.bottom],
|
||||
filter: enumItemAcceptorItemFilter.any,
|
||||
},
|
||||
{
|
||||
pos: new Vector(2, 1),
|
||||
directions: [enumDirection.right],
|
||||
filter: enumItemAcceptorItemFilter.any,
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import { types } from "../../savegame/serialization";
|
||||
export const enumItemAcceptorItemFilter = {
|
||||
shape: "shape",
|
||||
color: "color",
|
||||
any: "any",
|
||||
none: null,
|
||||
};
|
||||
|
||||
@ -20,6 +21,7 @@ export const enumItemAcceptorItemFilter = {
|
||||
* filter?: enumItemAcceptorItemFilter
|
||||
* }} ItemAcceptorSlot */
|
||||
|
||||
// TODO: Make changes in ItemAcceptor to allow buffer to only accept specific items
|
||||
export class ItemAcceptorComponent extends Component {
|
||||
static getId() {
|
||||
return "ItemAcceptor";
|
||||
|
@ -18,6 +18,7 @@ export const enumItemProcessorTypes = {
|
||||
painterDouble: "painterDouble",
|
||||
painterQuad: "painterQuad",
|
||||
hub: "hub",
|
||||
buffer: "buffer",
|
||||
};
|
||||
|
||||
export class ItemProcessorComponent extends Component {
|
||||
|
@ -379,6 +379,7 @@ export class HubGoals extends BasicSerializableObject {
|
||||
switch (processorType) {
|
||||
case enumItemProcessorTypes.trash:
|
||||
case enumItemProcessorTypes.hub:
|
||||
case enumItemProcessorTypes.buffer:
|
||||
return 1e30;
|
||||
case enumItemProcessorTypes.splitter:
|
||||
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
|
||||
|
@ -286,6 +286,11 @@ buildings:
|
||||
name: &trash Destroyed
|
||||
description: Accepts inputs from all sides and destroys them. Forever.
|
||||
|
||||
buffer:
|
||||
name: &buffer Item Buffer
|
||||
description: Stores a large amount of a single type of item.
|
||||
|
||||
|
||||
storyRewards:
|
||||
# Those are the rewards gained from completing the store
|
||||
reward_cutter_and_trash: Cutting Shapes
|
||||
@ -391,6 +396,7 @@ keybindings:
|
||||
mixer: *mixer
|
||||
painter: *painter
|
||||
trash: *trash
|
||||
buffer: *buffer
|
||||
|
||||
abortBuildingPlacement: Abort Placement
|
||||
rotateWhilePlacing: Rotate
|
||||
|
Loading…
Reference in New Issue
Block a user