Further take on logic wires
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 1003 KiB After Width: | Height: | Size: 1001 KiB |
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 204 KiB |
Before Width: | Height: | Size: 479 KiB After Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 913 KiB After Width: | Height: | Size: 933 KiB |
@ -256,6 +256,8 @@
|
|||||||
<key type="filename">sprites/buildings/rotater.png</key>
|
<key type="filename">sprites/buildings/rotater.png</key>
|
||||||
<key type="filename">sprites/buildings/trash.png</key>
|
<key type="filename">sprites/buildings/trash.png</key>
|
||||||
<key type="filename">sprites/misc/wires_overlay_tile.png</key>
|
<key type="filename">sprites/misc/wires_overlay_tile.png</key>
|
||||||
|
<key type="filename">sprites/wires/logical_acceptor.png</key>
|
||||||
|
<key type="filename">sprites/wires/logical_ejector.png</key>
|
||||||
<struct type="IndividualSpriteSettings">
|
<struct type="IndividualSpriteSettings">
|
||||||
<key>pivotPoint</key>
|
<key>pivotPoint</key>
|
||||||
<point_f>0.5,0.5</point_f>
|
<point_f>0.5,0.5</point_f>
|
||||||
@ -354,9 +356,15 @@
|
|||||||
<key type="filename">sprites/blueprints/belt_left.png</key>
|
<key type="filename">sprites/blueprints/belt_left.png</key>
|
||||||
<key type="filename">sprites/blueprints/belt_right.png</key>
|
<key type="filename">sprites/blueprints/belt_right.png</key>
|
||||||
<key type="filename">sprites/blueprints/belt_top.png</key>
|
<key type="filename">sprites/blueprints/belt_top.png</key>
|
||||||
|
<key type="filename">sprites/blueprints/wire-split.png</key>
|
||||||
|
<key type="filename">sprites/blueprints/wire-turn.png</key>
|
||||||
|
<key type="filename">sprites/blueprints/wire.png</key>
|
||||||
<key type="filename">sprites/buildings/belt_left.png</key>
|
<key type="filename">sprites/buildings/belt_left.png</key>
|
||||||
<key type="filename">sprites/buildings/belt_right.png</key>
|
<key type="filename">sprites/buildings/belt_right.png</key>
|
||||||
<key type="filename">sprites/buildings/belt_top.png</key>
|
<key type="filename">sprites/buildings/belt_top.png</key>
|
||||||
|
<key type="filename">sprites/buildings/wire-split.png</key>
|
||||||
|
<key type="filename">sprites/buildings/wire-turn.png</key>
|
||||||
|
<key type="filename">sprites/buildings/wire.png</key>
|
||||||
<struct type="IndividualSpriteSettings">
|
<struct type="IndividualSpriteSettings">
|
||||||
<key>pivotPoint</key>
|
<key>pivotPoint</key>
|
||||||
<point_f>0.5,0.5</point_f>
|
<point_f>0.5,0.5</point_f>
|
||||||
@ -513,9 +521,6 @@
|
|||||||
</struct>
|
</struct>
|
||||||
<key type="filename">sprites/debug/acceptor_slot.png</key>
|
<key type="filename">sprites/debug/acceptor_slot.png</key>
|
||||||
<key type="filename">sprites/debug/ejector_slot.png</key>
|
<key type="filename">sprites/debug/ejector_slot.png</key>
|
||||||
<key type="filename">sprites/map_overview/belt_forward.png</key>
|
|
||||||
<key type="filename">sprites/map_overview/belt_left.png</key>
|
|
||||||
<key type="filename">sprites/map_overview/belt_right.png</key>
|
|
||||||
<key type="filename">sprites/misc/hub_direction_indicator.png</key>
|
<key type="filename">sprites/misc/hub_direction_indicator.png</key>
|
||||||
<key type="filename">sprites/misc/waypoint.png</key>
|
<key type="filename">sprites/misc/waypoint.png</key>
|
||||||
<struct type="IndividualSpriteSettings">
|
<struct type="IndividualSpriteSettings">
|
||||||
|
BIN
res_raw/sprites/blueprints/wire-split.png
Normal file
After Width: | Height: | Size: 558 B |
BIN
res_raw/sprites/blueprints/wire-turn.png
Normal file
After Width: | Height: | Size: 506 B |
BIN
res_raw/sprites/blueprints/wire.png
Normal file
After Width: | Height: | Size: 421 B |
BIN
res_raw/sprites/buildings/wire-split.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
res_raw/sprites/buildings/wire-turn.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
res_raw/sprites/buildings/wire.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB |
BIN
res_raw/sprites/wires/logical_acceptor.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
res_raw/sprites/wires/logical_ejector.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
@ -1,4 +1,4 @@
|
|||||||
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt;
|
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt, wire;
|
||||||
|
|
||||||
@each $building in $buildings {
|
@each $building in $buildings {
|
||||||
[data-icon="building_icons/#{$building}.png"] {
|
[data-icon="building_icons/#{$building}.png"] {
|
||||||
|
@ -9,7 +9,7 @@ import { GameRoot } from "../root";
|
|||||||
|
|
||||||
export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right];
|
export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right];
|
||||||
|
|
||||||
const overlayMatrices = {
|
export const beltOverlayMatrices = {
|
||||||
[enumDirection.top]: {
|
[enumDirection.top]: {
|
||||||
0: [0, 1, 0, 0, 1, 0, 0, 1, 0],
|
0: [0, 1, 0, 0, 1, 0, 0, 1, 0],
|
||||||
90: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
90: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
||||||
@ -75,7 +75,7 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
|||||||
* @param {Entity} entity
|
* @param {Entity} entity
|
||||||
*/
|
*/
|
||||||
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
|
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
|
||||||
return overlayMatrices[entity.components.Belt.direction][rotation];
|
return beltOverlayMatrices[entity.components.Belt.direction][rotation];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ export class MetaHubBuilding extends MetaBuilding {
|
|||||||
new WiredPinsComponent({
|
new WiredPinsComponent({
|
||||||
slots: [
|
slots: [
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(3, 0),
|
||||||
type: enumPinSlotType.logicalEjector,
|
type: enumPinSlotType.logicalEjector,
|
||||||
direction: enumDirection.top,
|
direction: enumDirection.top,
|
||||||
},
|
},
|
||||||
|
@ -29,17 +29,17 @@ const overlayMatrices = [
|
|||||||
// Sender
|
// Sender
|
||||||
{
|
{
|
||||||
0: [1, 1, 1, 0, 1, 0, 0, 1, 0],
|
0: [1, 1, 1, 0, 1, 0, 0, 1, 0],
|
||||||
90: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
90: [0, 0, 1, 1, 1, 1, 0, 0, 1],
|
||||||
180: [0, 1, 0, 0, 1, 0, 0, 1, 0],
|
180: [0, 1, 0, 0, 1, 0, 1, 1, 1],
|
||||||
270: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
270: [1, 0, 0, 1, 1, 1, 1, 0, 0],
|
||||||
},
|
},
|
||||||
|
|
||||||
// Receiver
|
// Receiver
|
||||||
{
|
{
|
||||||
0: [0, 1, 0, 0, 1, 0, 1, 1, 1],
|
0: [0, 1, 0, 0, 1, 0, 1, 1, 1],
|
||||||
90: [0, 1, 0, 1, 1, 0, 0, 0, 0],
|
90: [1, 0, 0, 1, 1, 1, 1, 0, 0],
|
||||||
180: [0, 1, 0, 0, 1, 1, 0, 0, 0],
|
180: [1, 1, 1, 0, 1, 0, 0, 1, 0],
|
||||||
270: [0, 0, 0, 0, 1, 1, 0, 1, 0],
|
270: [0, 0, 1, 1, 1, 1, 0, 0, 1],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
111
src/js/game/buildings/wire.js
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
import { Vector } from "../../core/vector";
|
||||||
|
import { SOUNDS } from "../../platform/sound";
|
||||||
|
import { enumWireType, WireComponent } from "../components/wire";
|
||||||
|
import { Entity } from "../entity";
|
||||||
|
import { MetaBuilding } from "../meta_building";
|
||||||
|
import { enumLayer, GameRoot } from "../root";
|
||||||
|
import { beltOverlayMatrices } from "./belt_base";
|
||||||
|
|
||||||
|
export const arrayWireRotationVariantToType = [enumWireType.regular, enumWireType.turn, enumWireType.split];
|
||||||
|
|
||||||
|
export const wireOverlayMatrices = {
|
||||||
|
[enumWireType.regular]: {
|
||||||
|
0: [0, 1, 0, 0, 1, 0, 0, 1, 0],
|
||||||
|
90: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
||||||
|
180: [0, 1, 0, 0, 1, 0, 0, 1, 0],
|
||||||
|
270: [0, 0, 0, 1, 1, 1, 0, 0, 0],
|
||||||
|
},
|
||||||
|
|
||||||
|
[enumWireType.split]: {
|
||||||
|
0: [0, 0, 0, 1, 1, 1, 0, 1, 0],
|
||||||
|
90: [0, 1, 0, 1, 1, 0, 0, 1, 0],
|
||||||
|
180: [0, 1, 0, 1, 1, 1, 0, 0, 0],
|
||||||
|
270: [0, 1, 0, 0, 1, 1, 0, 1, 0],
|
||||||
|
},
|
||||||
|
|
||||||
|
[enumWireType.turn]: {
|
||||||
|
0: [0, 0, 0, 0, 1, 1, 0, 1, 0],
|
||||||
|
90: [0, 0, 0, 1, 1, 0, 0, 1, 0],
|
||||||
|
180: [0, 1, 0, 1, 1, 0, 0, 0, 0],
|
||||||
|
270: [0, 1, 0, 0, 1, 1, 0, 0, 0],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export class MetaWireBuilding extends MetaBuilding {
|
||||||
|
constructor() {
|
||||||
|
super("wire");
|
||||||
|
}
|
||||||
|
|
||||||
|
getHasDirectionLockAvailable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSilhouetteColor() {
|
||||||
|
return "#25fff2";
|
||||||
|
}
|
||||||
|
|
||||||
|
getDimensions() {
|
||||||
|
return new Vector(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStayInPlacementMode() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlacementSound() {
|
||||||
|
return SOUNDS.placeBelt;
|
||||||
|
}
|
||||||
|
|
||||||
|
getRotateAutomaticallyWhilePlacing() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLayer() {
|
||||||
|
return enumLayer.wires;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprite() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsReplaceable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {GameRoot} root
|
||||||
|
*/
|
||||||
|
getIsUnlocked(root) {
|
||||||
|
// @todo
|
||||||
|
return G_IS_DEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the entity at the given location
|
||||||
|
* @param {Entity} entity
|
||||||
|
*/
|
||||||
|
setupEntityComponents(entity) {
|
||||||
|
// @todo
|
||||||
|
entity.addComponent(new WireComponent({}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Entity} entity
|
||||||
|
* @param {number} rotationVariant
|
||||||
|
*/
|
||||||
|
updateVariants(entity, rotationVariant) {
|
||||||
|
entity.components.Wire.type = arrayWireRotationVariantToType[rotationVariant];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {number} rotation
|
||||||
|
* @param {number} rotationVariant
|
||||||
|
* @param {string} variant
|
||||||
|
* @param {Entity} entity
|
||||||
|
*/
|
||||||
|
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
|
||||||
|
return wireOverlayMatrices[entity.components.Wire.type][rotation];
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import { HubComponent } from "./components/hub";
|
|||||||
import { StorageComponent } from "./components/storage";
|
import { StorageComponent } from "./components/storage";
|
||||||
import { WiredPinsComponent } from "./components/wired_pins";
|
import { WiredPinsComponent } from "./components/wired_pins";
|
||||||
import { BeltUnderlaysComponent } from "./components/belt_underlays";
|
import { BeltUnderlaysComponent } from "./components/belt_underlays";
|
||||||
|
import { WireComponent } from "./components/wire";
|
||||||
|
|
||||||
export function initComponentRegistry() {
|
export function initComponentRegistry() {
|
||||||
gComponentRegistry.register(StaticMapEntityComponent);
|
gComponentRegistry.register(StaticMapEntityComponent);
|
||||||
@ -23,6 +24,7 @@ export function initComponentRegistry() {
|
|||||||
gComponentRegistry.register(StorageComponent);
|
gComponentRegistry.register(StorageComponent);
|
||||||
gComponentRegistry.register(WiredPinsComponent);
|
gComponentRegistry.register(WiredPinsComponent);
|
||||||
gComponentRegistry.register(BeltUnderlaysComponent);
|
gComponentRegistry.register(BeltUnderlaysComponent);
|
||||||
|
gComponentRegistry.register(WireComponent);
|
||||||
|
|
||||||
// IMPORTANT ^^^^^ UPDATE ENTITY COMPONENT STORAGE AFTERWARDS
|
// IMPORTANT ^^^^^ UPDATE ENTITY COMPONENT STORAGE AFTERWARDS
|
||||||
|
|
||||||
|
27
src/js/game/components/wire.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Component } from "../component";
|
||||||
|
|
||||||
|
/** @enum {string} */
|
||||||
|
export const enumWireType = {
|
||||||
|
regular: "regular",
|
||||||
|
turn: "turn",
|
||||||
|
split: "split",
|
||||||
|
};
|
||||||
|
|
||||||
|
export class WireComponent extends Component {
|
||||||
|
static getId() {
|
||||||
|
return "Wire";
|
||||||
|
}
|
||||||
|
|
||||||
|
duplicateWithoutContents() {
|
||||||
|
return new WireComponent({ type: this.type });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {object} param0
|
||||||
|
* @param {enumWireType?} param0.type
|
||||||
|
*/
|
||||||
|
constructor({ type = enumWireType.regular }) {
|
||||||
|
super();
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,6 @@ import { types } from "../../savegame/serialization";
|
|||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumPinSlotType = {
|
export const enumPinSlotType = {
|
||||||
positiveEnergyEjector: "positiveEnergyEjector",
|
|
||||||
negativeEnergyEjector: "negativeEnergyEjector",
|
|
||||||
positiveEnergyAcceptor: "positiveEnergyAcceptor",
|
|
||||||
negativeEnergyAcceptor: "negativeEnergyAcceptor",
|
|
||||||
logicalEjector: "logicalEjector",
|
logicalEjector: "logicalEjector",
|
||||||
logicalAcceptor: "logicalAcceptor",
|
logicalAcceptor: "logicalAcceptor",
|
||||||
};
|
};
|
||||||
|
@ -394,8 +394,10 @@ export class GameCore {
|
|||||||
// Main rendering order
|
// Main rendering order
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
// BG / Map Resources / Belt Backgrounds
|
if (this.root.camera.getIsMapOverlayActive()) {
|
||||||
if (!this.root.camera.getIsMapOverlayActive()) {
|
// Map overview
|
||||||
|
root.map.drawOverlay(params);
|
||||||
|
} else {
|
||||||
root.map.drawBackground(params);
|
root.map.drawBackground(params);
|
||||||
|
|
||||||
// Underlays for splitters / balancers
|
// Underlays for splitters / balancers
|
||||||
@ -419,17 +421,15 @@ export class GameCore {
|
|||||||
|
|
||||||
// Green wires overlay
|
// Green wires overlay
|
||||||
root.hud.parts.wiresOverlay.draw(params);
|
root.hud.parts.wiresOverlay.draw(params);
|
||||||
} else {
|
|
||||||
root.map.drawOverlay(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.root.currentLayer === enumLayer.wires && !this.root.camera.getIsMapOverlayActive()) {
|
if (this.root.currentLayer === enumLayer.wires) {
|
||||||
// Static map entities
|
// Static map entities
|
||||||
root.map.drawWiresForegroundLayer(params);
|
root.map.drawWiresForegroundLayer(params);
|
||||||
|
|
||||||
// pins
|
// pins
|
||||||
systems.wiredPins.draw(params);
|
systems.wiredPins.draw(params);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (G_IS_DEV) {
|
if (G_IS_DEV) {
|
||||||
root.map.drawStaticEntityDebugOverlays(params);
|
root.map.drawStaticEntityDebugOverlays(params);
|
||||||
|
@ -10,6 +10,7 @@ import { StaticMapEntityComponent } from "./components/static_map_entity";
|
|||||||
import { StorageComponent } from "./components/storage";
|
import { StorageComponent } from "./components/storage";
|
||||||
import { UndergroundBeltComponent } from "./components/underground_belt";
|
import { UndergroundBeltComponent } from "./components/underground_belt";
|
||||||
import { WiredPinsComponent } from "./components/wired_pins";
|
import { WiredPinsComponent } from "./components/wired_pins";
|
||||||
|
import { WireComponent } from "./components/wire";
|
||||||
/* typehints:end */
|
/* typehints:end */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +54,9 @@ export class EntityComponentStorage {
|
|||||||
/** @type {BeltUnderlaysComponent} */
|
/** @type {BeltUnderlaysComponent} */
|
||||||
this.BeltUnderlays;
|
this.BeltUnderlays;
|
||||||
|
|
||||||
|
/** @type {WireComponent} */
|
||||||
|
this.Wire;
|
||||||
|
|
||||||
/* typehints:end */
|
/* typehints:end */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import { ItemAcceptorSystem } from "./systems/item_acceptor";
|
|||||||
import { StorageSystem } from "./systems/storage";
|
import { StorageSystem } from "./systems/storage";
|
||||||
import { WiredPinsSystem } from "./systems/wired_pins";
|
import { WiredPinsSystem } from "./systems/wired_pins";
|
||||||
import { BeltUnderlaysSystem } from "./systems/belt_underlays";
|
import { BeltUnderlaysSystem } from "./systems/belt_underlays";
|
||||||
|
import { WireSystem } from "./systems/wire";
|
||||||
|
|
||||||
const logger = createLogger("game_system_manager");
|
const logger = createLogger("game_system_manager");
|
||||||
|
|
||||||
@ -64,6 +65,9 @@ export class GameSystemManager {
|
|||||||
/** @type {BeltUnderlaysSystem} */
|
/** @type {BeltUnderlaysSystem} */
|
||||||
beltUnderlays: null,
|
beltUnderlays: null,
|
||||||
|
|
||||||
|
/** @type {WireSystem} */
|
||||||
|
wire: null,
|
||||||
|
|
||||||
/* typehints:end */
|
/* typehints:end */
|
||||||
};
|
};
|
||||||
this.systemUpdateOrder = [];
|
this.systemUpdateOrder = [];
|
||||||
@ -109,6 +113,8 @@ export class GameSystemManager {
|
|||||||
// then would be invalid
|
// then would be invalid
|
||||||
add("itemAcceptor", ItemAcceptorSystem);
|
add("itemAcceptor", ItemAcceptorSystem);
|
||||||
|
|
||||||
|
add("wire", WireSystem);
|
||||||
|
|
||||||
logger.log("📦 There are", this.systemUpdateOrder.length, "game systems");
|
logger.log("📦 There are", this.systemUpdateOrder.length, "game systems");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { enumLayer } from "../../root";
|
import { enumLayer } from "../../root";
|
||||||
import { HUDBaseToolbar } from "./base_toolbar";
|
import { HUDBaseToolbar } from "./base_toolbar";
|
||||||
|
import { MetaWireBuilding } from "../../buildings/wire";
|
||||||
|
|
||||||
const supportedBuildings = [];
|
const supportedBuildings = [MetaWireBuilding];
|
||||||
|
|
||||||
export class HUDWiresToolbar extends HUDBaseToolbar {
|
export class HUDWiresToolbar extends HUDBaseToolbar {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
|
@ -54,6 +54,8 @@ export const KEYMAPPINGS = {
|
|||||||
mixer: { keyCode: key("8") },
|
mixer: { keyCode: key("8") },
|
||||||
painter: { keyCode: key("9") },
|
painter: { keyCode: key("9") },
|
||||||
trash: { keyCode: key("0") },
|
trash: { keyCode: key("0") },
|
||||||
|
|
||||||
|
wire: { keyCode: key("1") },
|
||||||
},
|
},
|
||||||
|
|
||||||
placement: {
|
placement: {
|
||||||
|
@ -75,6 +75,7 @@ export class MapChunkView extends MapChunk {
|
|||||||
parameters.context.drawImage(sprite, this.x * dims, this.y * dims, dims, dims);
|
parameters.context.drawImage(sprite, this.x * dims, this.y * dims, dims, dims);
|
||||||
parameters.context.imageSmoothingEnabled = true;
|
parameters.context.imageSmoothingEnabled = true;
|
||||||
|
|
||||||
|
if (this.root.currentLayer === enumLayer.regular) {
|
||||||
for (let i = 0; i < this.patches.length; ++i) {
|
for (let i = 0; i < this.patches.length; ++i) {
|
||||||
const patch = this.patches[i];
|
const patch = this.patches[i];
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ export class MapChunkView extends MapChunk {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -179,6 +181,54 @@ export class MapChunkView extends MapChunk {
|
|||||||
|
|
||||||
context.fillStyle = THEME.map.wires.overlayColor;
|
context.fillStyle = THEME.map.wires.overlayColor;
|
||||||
context.fillRect(0, 0, w, h);
|
context.fillRect(0, 0, w, h);
|
||||||
|
|
||||||
|
for (let x = 0; x < globalConfig.mapChunkSize; ++x) {
|
||||||
|
const wiresArray = this.wireContents[x];
|
||||||
|
for (let y = 0; y < globalConfig.mapChunkSize; ++y) {
|
||||||
|
const content = wiresArray[y];
|
||||||
|
if (!content) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const staticComp = content.components.StaticMapEntity;
|
||||||
|
const data = getBuildingDataFromCode(staticComp.code);
|
||||||
|
const metaBuilding = data.metaInstance;
|
||||||
|
|
||||||
|
const overlayMatrix = metaBuilding.getSpecialOverlayRenderMatrix(
|
||||||
|
staticComp.rotation,
|
||||||
|
data.rotationVariant,
|
||||||
|
data.variant,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
|
||||||
|
context.fillStyle = metaBuilding.getSilhouetteColor();
|
||||||
|
if (overlayMatrix) {
|
||||||
|
for (let dx = 0; dx < 3; ++dx) {
|
||||||
|
for (let dy = 0; dy < 3; ++dy) {
|
||||||
|
const isFilled = overlayMatrix[dx + dy * 3];
|
||||||
|
if (isFilled) {
|
||||||
|
context.fillRect(
|
||||||
|
x * CHUNK_OVERLAY_RES + dx,
|
||||||
|
y * CHUNK_OVERLAY_RES + dy,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
context.fillRect(
|
||||||
|
x * CHUNK_OVERLAY_RES,
|
||||||
|
y * CHUNK_OVERLAY_RES,
|
||||||
|
CHUNK_OVERLAY_RES,
|
||||||
|
CHUNK_OVERLAY_RES
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,6 +238,7 @@ export class MapChunkView extends MapChunk {
|
|||||||
*/
|
*/
|
||||||
drawWiresForegroundLayer(parameters) {
|
drawWiresForegroundLayer(parameters) {
|
||||||
const systems = this.root.systemMgr.systems;
|
const systems = this.root.systemMgr.systems;
|
||||||
|
systems.wire.drawChunk(parameters, this);
|
||||||
systems.staticMapEntities.drawWiresChunk(parameters, this);
|
systems.staticMapEntities.drawWiresChunk(parameters, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import { enumSplitterVariants, MetaSplitterBuilding } from "./buildings/splitter
|
|||||||
import { MetaStackerBuilding } from "./buildings/stacker";
|
import { MetaStackerBuilding } from "./buildings/stacker";
|
||||||
import { enumTrashVariants, MetaTrashBuilding } from "./buildings/trash";
|
import { enumTrashVariants, MetaTrashBuilding } from "./buildings/trash";
|
||||||
import { enumUndergroundBeltVariants, MetaUndergroundBeltBuilding } from "./buildings/underground_belt";
|
import { enumUndergroundBeltVariants, MetaUndergroundBeltBuilding } from "./buildings/underground_belt";
|
||||||
|
import { MetaWireBuilding } from "./buildings/wire";
|
||||||
import { gBuildingVariants, registerBuildingVariant } from "./building_codes";
|
import { gBuildingVariants, registerBuildingVariant } from "./building_codes";
|
||||||
import { defaultBuildingVariant } from "./meta_building";
|
import { defaultBuildingVariant } from "./meta_building";
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ export function initMetaBuildingRegistry() {
|
|||||||
gMetaBuildingRegistry.register(MetaBeltBuilding);
|
gMetaBuildingRegistry.register(MetaBeltBuilding);
|
||||||
gMetaBuildingRegistry.register(MetaUndergroundBeltBuilding);
|
gMetaBuildingRegistry.register(MetaUndergroundBeltBuilding);
|
||||||
gMetaBuildingRegistry.register(MetaHubBuilding);
|
gMetaBuildingRegistry.register(MetaHubBuilding);
|
||||||
|
gMetaBuildingRegistry.register(MetaWireBuilding);
|
||||||
|
|
||||||
// Belt
|
// Belt
|
||||||
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
|
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
|
||||||
@ -78,6 +80,11 @@ export function initMetaBuildingRegistry() {
|
|||||||
// Hub
|
// Hub
|
||||||
registerBuildingVariant(26, MetaHubBuilding);
|
registerBuildingVariant(26, MetaHubBuilding);
|
||||||
|
|
||||||
|
// Wire
|
||||||
|
registerBuildingVariant(27, MetaWireBuilding, defaultBuildingVariant, 0);
|
||||||
|
registerBuildingVariant(28, MetaWireBuilding, defaultBuildingVariant, 1);
|
||||||
|
registerBuildingVariant(29, MetaWireBuilding, defaultBuildingVariant, 2);
|
||||||
|
|
||||||
// Propagate instances
|
// Propagate instances
|
||||||
for (const key in gBuildingVariants) {
|
for (const key in gBuildingVariants) {
|
||||||
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(
|
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(
|
||||||
|
@ -33,15 +33,6 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
[enumDirection.right]: Loader.getSprite("sprites/belt/right_0.png"),
|
[enumDirection.right]: Loader.getSprite("sprites/belt/right_0.png"),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<enumDirection, Array<AtlasSprite>>}
|
|
||||||
*/
|
|
||||||
this.wireSprites = {
|
|
||||||
[enumDirection.top]: Loader.getSprite("sprites/buildings/wire_top.png"),
|
|
||||||
[enumDirection.left]: Loader.getSprite("sprites/buildings/wire_left.png"),
|
|
||||||
[enumDirection.right]: Loader.getSprite("sprites/buildings/wire_right.png"),
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<enumDirection, Array<AtlasSprite>>}
|
* @type {Object.<enumDirection, Array<AtlasSprite>>}
|
||||||
*/
|
*/
|
||||||
@ -485,10 +476,6 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
* @param {MapChunkView} chunk
|
* @param {MapChunkView} chunk
|
||||||
*/
|
*/
|
||||||
drawChunk(parameters, chunk) {
|
drawChunk(parameters, chunk) {
|
||||||
if (parameters.zoomLevel < globalConfig.mapChunkOverviewMinZoom) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limit speed to avoid belts going backwards
|
// Limit speed to avoid belts going backwards
|
||||||
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(), 10);
|
const speedMultiplier = Math.min(this.root.hubGoals.getBeltBaseSpeed(), 10);
|
||||||
|
|
||||||
@ -511,7 +498,6 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,8 +10,6 @@ export class MapResourcesSystem extends GameSystem {
|
|||||||
* @param {MapChunkView} chunk
|
* @param {MapChunkView} chunk
|
||||||
*/
|
*/
|
||||||
drawChunk(parameters, chunk) {
|
drawChunk(parameters, chunk) {
|
||||||
const renderItems = parameters.zoomLevel >= globalConfig.mapChunkOverviewMinZoom;
|
|
||||||
|
|
||||||
parameters.context.globalAlpha = 0.5;
|
parameters.context.globalAlpha = 0.5;
|
||||||
|
|
||||||
const layer = chunk.lowerLayer;
|
const layer = chunk.lowerLayer;
|
||||||
@ -37,7 +35,6 @@ export class MapResourcesSystem extends GameSystem {
|
|||||||
|
|
||||||
parameters.context.fillStyle = lowerItem.getBackgroundColorAsResource();
|
parameters.context.fillStyle = lowerItem.getBackgroundColorAsResource();
|
||||||
parameters.context.fillRect(worldX, worldY, globalConfig.tileSize, globalConfig.tileSize);
|
parameters.context.fillRect(worldX, worldY, globalConfig.tileSize, globalConfig.tileSize);
|
||||||
if (renderItems) {
|
|
||||||
lowerItem.draw(
|
lowerItem.draw(
|
||||||
worldX + globalConfig.halfTileSize,
|
worldX + globalConfig.halfTileSize,
|
||||||
worldY + globalConfig.halfTileSize,
|
worldY + globalConfig.halfTileSize,
|
||||||
@ -46,22 +43,6 @@ export class MapResourcesSystem extends GameSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
parameters.context.globalAlpha = 1;
|
parameters.context.globalAlpha = 1;
|
||||||
|
|
||||||
if (!renderItems) {
|
|
||||||
// Render patches instead
|
|
||||||
const patches = chunk.patches;
|
|
||||||
for (let i = 0; i < patches.length; ++i) {
|
|
||||||
const { pos, item, size } = patches[i];
|
|
||||||
|
|
||||||
item.draw(
|
|
||||||
(chunk.tileX + pos.x + 0.5) * globalConfig.tileSize,
|
|
||||||
(chunk.tileY + pos.y + 0.5) * globalConfig.tileSize,
|
|
||||||
parameters,
|
|
||||||
80
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { Loader } from "../../core/loader";
|
|
||||||
import { enumDirection } from "../../core/vector";
|
|
||||||
import { GameSystem } from "../game_system";
|
import { GameSystem } from "../game_system";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
|
||||||
export class StaticMapEntitySystem extends GameSystem {
|
export class StaticMapEntitySystem extends GameSystem {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root);
|
super(root);
|
||||||
|
|
||||||
this.beltOverviewSprites = {
|
|
||||||
[enumDirection.top]: Loader.getSprite("sprites/map_overview/belt_forward.png"),
|
|
||||||
[enumDirection.right]: Loader.getSprite("sprites/map_overview/belt_right.png"),
|
|
||||||
[enumDirection.left]: Loader.getSprite("sprites/map_overview/belt_left.png"),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,8 +18,6 @@ export class StaticMapEntitySystem extends GameSystem {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawOutlinesOnly = parameters.zoomLevel < globalConfig.mapChunkOverviewMinZoom;
|
|
||||||
|
|
||||||
const drawnUids = new Set();
|
const drawnUids = new Set();
|
||||||
|
|
||||||
const contents = chunk.contents;
|
const contents = chunk.contents;
|
||||||
@ -41,22 +31,7 @@ export class StaticMapEntitySystem extends GameSystem {
|
|||||||
}
|
}
|
||||||
drawnUids.add(entity.uid);
|
drawnUids.add(entity.uid);
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
if (drawOutlinesOnly) {
|
|
||||||
const rect = staticComp.getTileSpaceBounds();
|
|
||||||
parameters.context.fillStyle = staticComp.getSilhouetteColor() || "#aaa";
|
|
||||||
const beltComp = entity.components.Belt;
|
|
||||||
if (beltComp) {
|
|
||||||
const sprite = this.beltOverviewSprites[beltComp.direction];
|
|
||||||
staticComp.drawSpriteOnFullEntityBounds(parameters, sprite, 0);
|
|
||||||
} else {
|
|
||||||
parameters.context.fillRect(
|
|
||||||
rect.x * globalConfig.tileSize,
|
|
||||||
rect.y * globalConfig.tileSize,
|
|
||||||
rect.w * globalConfig.tileSize,
|
|
||||||
rect.h * globalConfig.tileSize
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const sprite = staticComp.getSprite();
|
const sprite = staticComp.getSprite();
|
||||||
if (sprite) {
|
if (sprite) {
|
||||||
staticComp.drawSpriteOnFullEntityBounds(parameters, sprite, 2);
|
staticComp.drawSpriteOnFullEntityBounds(parameters, sprite, 2);
|
||||||
@ -65,7 +40,6 @@ export class StaticMapEntitySystem extends GameSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the static wire entities
|
* Draws the static wire entities
|
||||||
|
36
src/js/game/systems/wire.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
|
import { WireComponent, enumWireType } from "../components/wire";
|
||||||
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
import { globalConfig } from "../../core/config";
|
||||||
|
import { Loader } from "../../core/loader";
|
||||||
|
|
||||||
|
export class WireSystem extends GameSystemWithFilter {
|
||||||
|
constructor(root) {
|
||||||
|
super(root, [WireComponent]);
|
||||||
|
|
||||||
|
this.wireSprites = {
|
||||||
|
[enumWireType.regular]: Loader.getSprite("sprites/buildings/wire.png"),
|
||||||
|
[enumWireType.turn]: Loader.getSprite("sprites/buildings/wire-turn.png"),
|
||||||
|
[enumWireType.split]: Loader.getSprite("sprites/buildings/wire-split.png"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a given chunk
|
||||||
|
* @param {import("../../core/draw_utils").DrawParameters} parameters
|
||||||
|
* @param {MapChunkView} chunk
|
||||||
|
*/
|
||||||
|
drawChunk(parameters, chunk) {
|
||||||
|
const contents = chunk.wireContents;
|
||||||
|
for (let y = 0; y < globalConfig.mapChunkSize; ++y) {
|
||||||
|
for (let x = 0; x < globalConfig.mapChunkSize; ++x) {
|
||||||
|
const entity = contents[x][y];
|
||||||
|
if (entity && entity.components.Wire) {
|
||||||
|
const wireType = entity.components.Wire.type;
|
||||||
|
const sprite = this.wireSprites[wireType];
|
||||||
|
entity.components.StaticMapEntity.drawSpriteOnFullEntityBounds(parameters, sprite, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,8 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
|||||||
super(root, [WiredPinsComponent]);
|
super(root, [WiredPinsComponent]);
|
||||||
|
|
||||||
this.pinSprites = {
|
this.pinSprites = {
|
||||||
[enumPinSlotType.logicalEjector]: Loader.getSprite("sprites/wires/pin_negative_eject.png"),
|
[enumPinSlotType.logicalEjector]: Loader.getSprite("sprites/wires/logical_ejector.png"),
|
||||||
[enumPinSlotType.logicalAcceptor]: Loader.getSprite("sprites/wires/pin_negative_accept.png"),
|
[enumPinSlotType.logicalAcceptor]: Loader.getSprite("sprites/wires/logical_acceptor.png"),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.root.signals.prePlacementCheck.add(this.prePlacementCheck, this);
|
this.root.signals.prePlacementCheck.add(this.prePlacementCheck, this);
|
||||||
|
@ -537,6 +537,19 @@ buildings:
|
|||||||
name: Storage
|
name: Storage
|
||||||
description: Stores excess items, up to a given capacity. Can be used as an overflow gate.
|
description: Stores excess items, up to a given capacity. Can be used as an overflow gate.
|
||||||
|
|
||||||
|
wire:
|
||||||
|
default:
|
||||||
|
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
|
||||||
|
|
||||||
storyRewards:
|
storyRewards:
|
||||||
# Those are the rewards gained from completing the store
|
# Those are the rewards gained from completing the store
|
||||||
reward_cutter_and_trash:
|
reward_cutter_and_trash:
|
||||||
@ -802,6 +815,7 @@ keybindings:
|
|||||||
mixer: *mixer
|
mixer: *mixer
|
||||||
painter: *painter
|
painter: *painter
|
||||||
trash: *trash
|
trash: *trash
|
||||||
|
wire: *wire
|
||||||
|
|
||||||
pipette: Pipette
|
pipette: Pipette
|
||||||
rotateWhilePlacing: Rotate
|
rotateWhilePlacing: Rotate
|
||||||
|