mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Added portable hub building
Just need artwork + Smol optimization in systems\item_processor.js cuz my ide said so
This commit is contained in:
parent
e1587ce816
commit
5b35c2e49d
BIN
res/ui/building_icons/portable_hub.png
Normal file
BIN
res/ui/building_icons/portable_hub.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
BIN
res/ui/building_tutorials/portable_hub.png
Normal file
BIN
res/ui/building_tutorials/portable_hub.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
@ -1,6 +1,5 @@
|
||||
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt, wire,
|
||||
constant_signal, logic_gate, lever, filter, wire_tunnel, display, virtual_processor, reader;
|
||||
|
||||
constant_signal, logic_gate, lever, filter, wire_tunnel, display, virtual_processor, reader, portable_hub;
|
||||
@each $building in $buildings {
|
||||
[data-icon="building_icons/#{$building}.png"] {
|
||||
background-image: uiResource("res/ui/building_icons/#{$building}.png") !important;
|
||||
@ -9,7 +8,7 @@ $buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, tra
|
||||
|
||||
$buildingsAndVariants: belt, splitter, splitter-compact, splitter-compact-inverse, underground_belt,
|
||||
underground_belt-tier2, miner, miner-chainable, cutter, cutter-quad, rotater, rotater-ccw, rotater-fl,
|
||||
stacker, mixer, painter, painter-double, painter-quad, trash, trash-storage;
|
||||
stacker, mixer, painter, painter-double, painter-quad, trash, trash-storage, portable_hub;
|
||||
@each $building in $buildingsAndVariants {
|
||||
[data-icon="building_tutorials/#{$building}.png"] {
|
||||
background-image: uiResource("res/ui/building_tutorials/#{$building}.png") !important;
|
||||
|
56
src/js/game/buildings/portable_hub.js
Normal file
56
src/js/game/buildings/portable_hub.js
Normal file
@ -0,0 +1,56 @@
|
||||
import { MetaBuilding } from "../meta_building";
|
||||
import {ItemAcceptorComponent} from "../components/item_acceptor";
|
||||
import {enumDirection, Vector} from "../../core/vector";
|
||||
import {enumItemProcessorTypes, ItemProcessorComponent} from "../components/item_processor";
|
||||
import {enumPinSlotType, WiredPinsComponent} from "../components/wired_pins";
|
||||
|
||||
export class MetaPortableHubBuilding extends MetaBuilding {
|
||||
constructor() {
|
||||
super("portable_hub");
|
||||
}
|
||||
|
||||
getIsRotateable(variant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getSilhouetteColor() {
|
||||
return "#eb5555";
|
||||
}
|
||||
|
||||
setupEntityComponents(entity, root) {
|
||||
entity.addComponent(
|
||||
new ItemAcceptorComponent({
|
||||
slots: [
|
||||
{
|
||||
pos: new Vector(0, 0),
|
||||
directions: [
|
||||
enumDirection.top,
|
||||
enumDirection.right,
|
||||
enumDirection.bottom,
|
||||
enumDirection.left,
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
entity.addComponent(
|
||||
new WiredPinsComponent({
|
||||
slots: [
|
||||
{
|
||||
pos: new Vector(0, 0),
|
||||
type: enumPinSlotType.logicalEjector,
|
||||
direction: enumDirection.left,
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
entity.addComponent(
|
||||
new ItemProcessorComponent({
|
||||
inputsPerCharge: 1,
|
||||
processorType: enumItemProcessorTypes.hub,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { typeItemSingleton } from "../item_resolver";
|
||||
|
||||
/** @enum {string} */
|
||||
export const enumItemProcessorTypes = {
|
||||
|
@ -13,6 +13,7 @@ import { MetaLeverBuilding } from "../../buildings/lever";
|
||||
import { MetaFilterBuilding } from "../../buildings/filter";
|
||||
import { MetaDisplayBuilding } from "../../buildings/display";
|
||||
import { MetaReaderBuilding } from "../../buildings/reader";
|
||||
import {MetaPortableHubBuilding} from "../../buildings/portable_hub";
|
||||
|
||||
const supportedBuildings = [
|
||||
MetaBeltBaseBuilding,
|
||||
@ -29,6 +30,7 @@ const supportedBuildings = [
|
||||
MetaFilterBuilding,
|
||||
MetaDisplayBuilding,
|
||||
MetaReaderBuilding,
|
||||
MetaPortableHubBuilding,
|
||||
];
|
||||
|
||||
export class HUDBuildingsToolbar extends HUDBaseToolbar {
|
||||
|
@ -65,6 +65,8 @@ export const KEYMAPPINGS = {
|
||||
constant_signal: { keyCode: key("3") },
|
||||
logic_gate: { keyCode: key("4") },
|
||||
virtual_processor: { keyCode: key("5") },
|
||||
|
||||
portable_hub: { keyCode: key("P") },
|
||||
},
|
||||
|
||||
placement: {
|
||||
|
@ -23,6 +23,7 @@ import { MetaWireTunnelBuilding, enumWireTunnelVariants } from "./buildings/wire
|
||||
import { MetaDisplayBuilding } from "./buildings/display";
|
||||
import { MetaVirtualProcessorBuilding, enumVirtualProcessorVariants } from "./buildings/virtual_processor";
|
||||
import { MetaReaderBuilding } from "./buildings/reader";
|
||||
import {MetaPortableHubBuilding} from "./buildings/portable_hub";
|
||||
|
||||
const logger = createLogger("building_registry");
|
||||
|
||||
@ -47,6 +48,7 @@ export function initMetaBuildingRegistry() {
|
||||
gMetaBuildingRegistry.register(MetaDisplayBuilding);
|
||||
gMetaBuildingRegistry.register(MetaVirtualProcessorBuilding);
|
||||
gMetaBuildingRegistry.register(MetaReaderBuilding);
|
||||
gMetaBuildingRegistry.register(MetaPortableHubBuilding);
|
||||
|
||||
// Belt
|
||||
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
|
||||
@ -137,6 +139,9 @@ export function initMetaBuildingRegistry() {
|
||||
// Reader
|
||||
registerBuildingVariant(49, MetaReaderBuilding);
|
||||
|
||||
// Portable hub
|
||||
registerBuildingVariant(50, MetaPortableHubBuilding);
|
||||
|
||||
// Propagate instances
|
||||
for (const key in gBuildingVariants) {
|
||||
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(
|
||||
|
@ -116,10 +116,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
// Check the network value at the given slot
|
||||
const network = pinsComp.slots[slotIndex - 1].linkedNetwork;
|
||||
const slotIsEnabled = network && isTruthyItem(network.currentValue);
|
||||
if (!slotIsEnabled) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return slotIsEnabled;
|
||||
|
||||
}
|
||||
|
||||
case enumItemProcessorRequirements.filter: {
|
||||
@ -524,9 +522,6 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
case enumItemProcessorTypes.hub: {
|
||||
trackProduction = false;
|
||||
|
||||
const hubComponent = entity.components.Hub;
|
||||
assert(hubComponent, "Hub item processor has no hub component");
|
||||
|
||||
for (let i = 0; i < items.length; ++i) {
|
||||
const item = /** @type {ShapeItem} */ (items[i].item);
|
||||
this.root.hubGoals.handleDefinitionDelivered(item.definition);
|
||||
|
@ -637,6 +637,11 @@ buildings:
|
||||
name: Compare
|
||||
description: Returns true if both items are exactly equal. Can compare shapes, items and booleans.
|
||||
|
||||
portable_hub:
|
||||
default:
|
||||
name: &portable_hub Portable hub
|
||||
description: Like the hub but mini
|
||||
|
||||
storyRewards:
|
||||
# Those are the rewards gained from completing the store
|
||||
reward_cutter_and_trash:
|
||||
@ -956,6 +961,7 @@ keybindings:
|
||||
wire_tunnel: *wire_tunnel
|
||||
display: *display
|
||||
reader: *reader
|
||||
portable_hub: *portable_hub
|
||||
# ---
|
||||
|
||||
pipette: Pipette
|
||||
|
Loading…
Reference in New Issue
Block a user