Add wire bridges and fix Q on hub crash

This commit is contained in:
tobspr 2020-08-13 21:04:44 +02:00
parent ff02508361
commit efd8ba7ae9
25 changed files with 1064 additions and 898 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 71 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 237 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 KiB

After

Width:  |  Height:  |  Size: 553 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,5 +1,5 @@
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt, wire,
constant_signal, logic_gate, lever, filter;
constant_signal, logic_gate, lever, filter, wire_tunnel;
@each $building in $buildings {
[data-icon="building_icons/#{$building}.png"] {

View File

@ -0,0 +1,43 @@
import { Vector } from "../../core/vector";
import { Entity } from "../entity";
import { MetaBuilding } from "../meta_building";
import { GameRoot, enumLayer } from "../root";
import { WireTunnelComponent } from "../components/wire_tunnel";
export class MetaWireTunnelBuilding extends MetaBuilding {
constructor() {
super("wire_tunnel");
}
getSilhouetteColor() {
return "#25fff2";
}
/**
* @param {GameRoot} root
*/
getIsUnlocked(root) {
// @todo
return true;
}
isRotateable() {
return false;
}
getDimensions() {
return new Vector(1, 1);
}
getLayer() {
return enumLayer.wires;
}
/**
* Creates the entity at the given location
* @param {Entity} entity
*/
setupEntityComponents(entity) {
entity.addComponent(new WireTunnelComponent());
}
}

View File

@ -14,6 +14,7 @@ import { WireComponent } from "./components/wire";
import { ConstantSignalComponent } from "./components/constant_signal";
import { LogicGateComponent } from "./components/logic_gate";
import { LeverComponent } from "./components/lever";
import { WireTunnelComponent } from "./components/wire_tunnel";
export function initComponentRegistry() {
gComponentRegistry.register(StaticMapEntityComponent);
@ -31,6 +32,7 @@ export function initComponentRegistry() {
gComponentRegistry.register(ConstantSignalComponent);
gComponentRegistry.register(LogicGateComponent);
gComponentRegistry.register(LeverComponent);
gComponentRegistry.register(WireTunnelComponent);
// IMPORTANT ^^^^^ UPDATE ENTITY COMPONENT STORAGE AFTERWARDS

View File

@ -0,0 +1,11 @@
import { Component } from "../component";
export class WireTunnelComponent extends Component {
static getId() {
return "WireTunnel";
}
duplicateWithoutContents() {
return new WireTunnelComponent();
}
}

View File

@ -14,6 +14,7 @@ import { WireComponent } from "./components/wire";
import { ConstantSignalComponent } from "./components/constant_signal";
import { LogicGateComponent } from "./components/logic_gate";
import { LeverComponent } from "./components/lever";
import { WireTunnelComponent } from "./components/wire_tunnel";
/* typehints:end */
/**
@ -69,6 +70,9 @@ export class EntityComponentStorage {
/** @type {LeverComponent} */
this.Lever;
/** @type {WireTunnelComponent} */
this.WireTunnel;
/* typehints:end */
}
}

View File

@ -344,6 +344,12 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
const buildingCode = contents.components.StaticMapEntity.code;
const extracted = getBuildingDataFromCode(buildingCode);
if (extracted.metaInstance.getId() === "hub") {
// Disable pipetting the hub
this.currentMetaBuilding.set(null);
return;
}
// If the building we are picking is the same as the one we have, clear the cursor.
if (
this.currentMetaBuilding.get() &&

View File

@ -4,9 +4,11 @@ import { MetaWireBuilding } from "../../buildings/wire";
import { MetaConstantSignalBuilding } from "../../buildings/constant_signal";
import { MetaLogicGateBuilding } from "../../buildings/logic_gate";
import { MetaLeverBuilding } from "../../buildings/lever";
import { MetaWireTunnelBuilding } from "../../buildings/wire_tunnel";
const supportedBuildings = [
MetaWireBuilding,
MetaWireTunnelBuilding,
MetaConstantSignalBuilding,
MetaLogicGateBuilding,
MetaLeverBuilding,

View File

@ -56,10 +56,11 @@ export const KEYMAPPINGS = {
trash: { keyCode: key("0") },
wire: { keyCode: key("1") },
constant_signal: { keyCode: key("2") },
logic_gate: { keyCode: key("3") },
lever: { keyCode: key("4") },
filter: { keyCode: key("5") },
wire_tunnel: { keyCode: key("2") },
constant_signal: { keyCode: key("3") },
logic_gate: { keyCode: key("4") },
lever: { keyCode: key("5") },
filter: { keyCode: key("6") },
},
placement: {

View File

@ -1,16 +1,16 @@
import { createLogger } from "../core/logging";
import { round2Digits, rotateDirectionalObject } from "../core/utils";
import { STOP_PROPAGATION } from "../core/signal";
import { round2Digits } from "../core/utils";
import {
enumDirection,
enumDirectionToVector,
Vector,
enumDirectionToAngle,
enumDirectionToVector,
enumInvertedDirections,
Vector,
} from "../core/vector";
import { Entity } from "./entity";
import { MetaBuilding } from "./meta_building";
import { GameRoot, enumLayer } from "./root";
import { STOP_PROPAGATION } from "../core/signal";
import { enumLayer, GameRoot } from "./root";
const logger = createLogger("ingame/logic");
@ -273,6 +273,12 @@ export class GameLogic {
return enumWireEdgeFlag.empty;
}
// Check if its a crossing
const wireTunnelComp = targetEntity.components.WireTunnel;
if (wireTunnelComp) {
return enumWireEdgeFlag.filled;
}
// Check if its a wire
const wiresComp = targetEntity.components.Wire;
if (!wiresComp) {

View File

@ -19,6 +19,7 @@ import { MetaConstantSignalBuilding } from "./buildings/constant_signal";
import { MetaLogicGateBuilding, enumLogicGateVariants } from "./buildings/logic_gate";
import { MetaLeverBuilding } from "./buildings/lever";
import { MetaFilterBuilding } from "./buildings/filter";
import { MetaWireTunnelBuilding } from "./buildings/wire_tunnel";
const logger = createLogger("building_registry");
@ -39,6 +40,7 @@ export function initMetaBuildingRegistry() {
gMetaBuildingRegistry.register(MetaLogicGateBuilding);
gMetaBuildingRegistry.register(MetaLeverBuilding);
gMetaBuildingRegistry.register(MetaFilterBuilding);
gMetaBuildingRegistry.register(MetaWireTunnelBuilding);
// Belt
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
@ -110,6 +112,9 @@ export function initMetaBuildingRegistry() {
// Filter
registerBuildingVariant(37, MetaFilterBuilding);
// Wire tunnel
registerBuildingVariant(39, MetaWireTunnelBuilding);
// Propagate instances
for (const key in gBuildingVariants) {
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(

View File

@ -365,6 +365,14 @@ export class WireSystem extends GameSystemWithFilter {
});
}
}
// Check if its a tunnel, if so, go to the forwarded item
if (entity.components.WireTunnel) {
const forwardedTile = searchTile.add(offset);
contents.push(
...this.root.map.getLayersContentsMultipleXY(forwardedTile.x, forwardedTile.y)
);
}
}
}

View File

@ -542,13 +542,10 @@ buildings:
name: &wire Wire
description: &wire_desc Allows to connect logical components and can transfer items, colors or boolean signals.
turn:
name: *wire
description: &wire_desc
split:
name: *wire
description: &wire_desc
wire_tunnel:
default:
name: &wire_tunnel Wire Tunnel
description: Allows to cross two wires without connecting them.
constant_signal:
default:
@ -856,6 +853,7 @@ keybindings:
logic_gate: *logic_gate
lever: *lever
filter: *filter
wire_tunnel: *wire_tunnel
# ---
pipette: Pipette