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 = {
|
export const enumItemAcceptorItemFilter = {
|
||||||
shape: "shape",
|
shape: "shape",
|
||||||
color: "color",
|
color: "color",
|
||||||
|
any: "any",
|
||||||
none: null,
|
none: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ export const enumItemAcceptorItemFilter = {
|
|||||||
* filter?: enumItemAcceptorItemFilter
|
* filter?: enumItemAcceptorItemFilter
|
||||||
* }} ItemAcceptorSlot */
|
* }} ItemAcceptorSlot */
|
||||||
|
|
||||||
|
// TODO: Make changes in ItemAcceptor to allow buffer to only accept specific items
|
||||||
export class ItemAcceptorComponent extends Component {
|
export class ItemAcceptorComponent extends Component {
|
||||||
static getId() {
|
static getId() {
|
||||||
return "ItemAcceptor";
|
return "ItemAcceptor";
|
||||||
|
@ -18,6 +18,7 @@ export const enumItemProcessorTypes = {
|
|||||||
painterDouble: "painterDouble",
|
painterDouble: "painterDouble",
|
||||||
painterQuad: "painterQuad",
|
painterQuad: "painterQuad",
|
||||||
hub: "hub",
|
hub: "hub",
|
||||||
|
buffer: "buffer",
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ItemProcessorComponent extends Component {
|
export class ItemProcessorComponent extends Component {
|
||||||
|
@ -379,6 +379,7 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
switch (processorType) {
|
switch (processorType) {
|
||||||
case enumItemProcessorTypes.trash:
|
case enumItemProcessorTypes.trash:
|
||||||
case enumItemProcessorTypes.hub:
|
case enumItemProcessorTypes.hub:
|
||||||
|
case enumItemProcessorTypes.buffer:
|
||||||
return 1e30;
|
return 1e30;
|
||||||
case enumItemProcessorTypes.splitter:
|
case enumItemProcessorTypes.splitter:
|
||||||
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
|
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
|
||||||
|
@ -286,6 +286,11 @@ buildings:
|
|||||||
name: &trash Destroyed
|
name: &trash Destroyed
|
||||||
description: Accepts inputs from all sides and destroys them. Forever.
|
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:
|
storyRewards:
|
||||||
# Those are the rewards gained from completing the store
|
# Those are the rewards gained from completing the store
|
||||||
reward_cutter_and_trash: Cutting Shapes
|
reward_cutter_and_trash: Cutting Shapes
|
||||||
@ -391,6 +396,7 @@ keybindings:
|
|||||||
mixer: *mixer
|
mixer: *mixer
|
||||||
painter: *painter
|
painter: *painter
|
||||||
trash: *trash
|
trash: *trash
|
||||||
|
buffer: *buffer
|
||||||
|
|
||||||
abortBuildingPlacement: Abort Placement
|
abortBuildingPlacement: Abort Placement
|
||||||
rotateWhilePlacing: Rotate
|
rotateWhilePlacing: Rotate
|
||||||
|
Loading…
Reference in New Issue
Block a user