From 2f872af3e4309628f15212e7891b7ea57dfd5292 Mon Sep 17 00:00:00 2001 From: DJ1TJOO Date: Sun, 14 Mar 2021 17:24:09 +0100 Subject: [PATCH] Revert "Changed building static declarations" This reverts commit c86c635a82394d198110538f01688b399944d83b. --- src/js/game/buildings/analyzer.js | 188 +++---- src/js/game/buildings/balancer.js | 478 +++++++++--------- src/js/game/buildings/belt.js | 155 +++--- src/js/game/buildings/comparator.js | 184 +++---- src/js/game/buildings/constant_signal.js | 132 ++--- src/js/game/buildings/cutter.js | 229 +++++---- src/js/game/buildings/display.js | 128 ++--- src/js/game/buildings/filter.js | 237 +++++---- src/js/game/buildings/hub.js | 450 ++++++++--------- src/js/game/buildings/item_producer.js | 138 ++--- src/js/game/buildings/lever.js | 130 ++--- src/js/game/buildings/logic_gate.js | 338 +++++++------ src/js/game/buildings/miner.js | 165 +++--- src/js/game/buildings/mixer.js | 196 ++++---- src/js/game/buildings/painter.js | 554 ++++++++++----------- src/js/game/buildings/reader.js | 270 +++++----- src/js/game/buildings/rotater.js | 278 +++++------ src/js/game/buildings/stacker.js | 210 ++++---- src/js/game/buildings/storage.js | 282 +++++------ src/js/game/buildings/transistor.js | 187 ++++--- src/js/game/buildings/trash.js | 179 +++---- src/js/game/buildings/underground_belt.js | 273 +++++----- src/js/game/buildings/virtual_processor.js | 410 +++++++-------- src/js/game/buildings/wire.js | 194 ++++---- src/js/game/buildings/wire_tunnel.js | 88 ++-- 25 files changed, 3014 insertions(+), 3059 deletions(-) diff --git a/src/js/game/buildings/analyzer.js b/src/js/game/buildings/analyzer.js index 5955cf1a..5ee45eab 100644 --- a/src/js/game/buildings/analyzer.js +++ b/src/js/game/buildings/analyzer.js @@ -106,98 +106,98 @@ export class MetaAnalyzerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaAnalyzerBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ], - }) - ), - - entity => - entity.addComponent( - new LogicGateComponent({ - type: enumLogicGateType.analyzer, - }) - ), - ]; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#555759", - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 0]), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.analyzer; - }, - }; } + +MetaAnalyzerBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), + + entity => + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.analyzer, + }) + ), +]; + +MetaAnalyzerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#555759", +}; + +MetaAnalyzerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), +}; + +MetaAnalyzerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 0]), +}; + +MetaAnalyzerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaAnalyzerBuilding.renderPins = { + [defaultBuildingVariant]: () => false, +}; + +MetaAnalyzerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", +}; + +MetaAnalyzerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaAnalyzerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaAnalyzerBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaAnalyzerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.analyzer; + }, +}; diff --git a/src/js/game/buildings/balancer.js b/src/js/game/buildings/balancer.js index 95352331..6768bd41 100644 --- a/src/js/game/buildings/balancer.js +++ b/src/js/game/buildings/balancer.js @@ -119,294 +119,282 @@ export class MetaBalancerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaBalancerBuilding.componentVariations[variant](entity, rotationVariant); } +} - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [], // set later - }) - ), +MetaBalancerBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [], // set later + }) + ), - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.balancer, - }) - ), + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.balancer, + }) + ), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [], // set later - renderFloatingItems: false, - }) - ), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [], // set later + renderFloatingItems: false, + }) + ), - entity => entity.addComponent(new BeltUnderlaysComponent({ underlays: [] })), - ]; + entity => entity.addComponent(new BeltUnderlaysComponent({ underlays: [] })), +]; - static variants = { - merger: "merger", - mergerInverse: "merger-inverse", - splitter: "splitter", - splitterInverse: "splitter-inverse", - }; +MetaBalancerBuilding.variants = { + merger: "merger", + mergerInverse: "merger-inverse", + splitter: "splitter", + splitterInverse: "splitter-inverse", +}; - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), - [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), - [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), - [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), - }; +MetaBalancerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, + [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), + [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), + [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), + [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), +}; - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_balancer), - [MetaBalancerBuilding.variants.merger]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger), - [MetaBalancerBuilding.variants.mergerInverse]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger), - [MetaBalancerBuilding.variants.splitter]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_splitter), - [MetaBalancerBuilding.variants.splitterInverse]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_splitter), - }; +MetaBalancerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_balancer), + [MetaBalancerBuilding.variants.merger]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger), + [MetaBalancerBuilding.variants.mergerInverse]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger), + [MetaBalancerBuilding.variants.splitter]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_splitter), + [MetaBalancerBuilding.variants.splitterInverse]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_splitter), +}; - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - [MetaBalancerBuilding.variants.merger]: () => new Vector(1, 1), - [MetaBalancerBuilding.variants.mergerInverse]: () => new Vector(1, 1), - [MetaBalancerBuilding.variants.splitter]: () => new Vector(1, 1), - [MetaBalancerBuilding.variants.splitterInverse]: () => new Vector(1, 1), - }; +MetaBalancerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), + [MetaBalancerBuilding.variants.merger]: () => new Vector(1, 1), + [MetaBalancerBuilding.variants.mergerInverse]: () => new Vector(1, 1), + [MetaBalancerBuilding.variants.splitter]: () => new Vector(1, 1), + [MetaBalancerBuilding.variants.splitterInverse]: () => new Vector(1, 1), +}; - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaBalancerBuilding.variants.merger]: () => true, - [MetaBalancerBuilding.variants.mergerInverse]: () => true, - [MetaBalancerBuilding.variants.splitter]: () => true, - [MetaBalancerBuilding.variants.splitterInverse]: () => true, - }; +MetaBalancerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaBalancerBuilding.variants.merger]: () => true, + [MetaBalancerBuilding.variants.mergerInverse]: () => true, + [MetaBalancerBuilding.variants.splitter]: () => true, + [MetaBalancerBuilding.variants.splitterInverse]: () => true, +}; - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaBalancerBuilding.variants.merger]: () => true, - [MetaBalancerBuilding.variants.mergerInverse]: () => true, - [MetaBalancerBuilding.variants.splitter]: () => true, - [MetaBalancerBuilding.variants.splitterInverse]: () => true, - }; +MetaBalancerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaBalancerBuilding.variants.merger]: () => true, + [MetaBalancerBuilding.variants.mergerInverse]: () => true, + [MetaBalancerBuilding.variants.splitter]: () => true, + [MetaBalancerBuilding.variants.splitterInverse]: () => true, +}; - static renderPins = { - [defaultBuildingVariant]: () => null, - [MetaBalancerBuilding.variants.merger]: () => null, - [MetaBalancerBuilding.variants.mergerInverse]: () => null, - [MetaBalancerBuilding.variants.splitter]: () => null, - [MetaBalancerBuilding.variants.splitterInverse]: () => null, - }; +MetaBalancerBuilding.renderPins = { + [defaultBuildingVariant]: () => null, + [MetaBalancerBuilding.variants.merger]: () => null, + [MetaBalancerBuilding.variants.mergerInverse]: () => null, + [MetaBalancerBuilding.variants.splitter]: () => null, + [MetaBalancerBuilding.variants.splitterInverse]: () => null, +}; - static layerPreview = { - [defaultBuildingVariant]: () => null, - [MetaBalancerBuilding.variants.merger]: () => null, - [MetaBalancerBuilding.variants.mergerInverse]: () => null, - [MetaBalancerBuilding.variants.splitter]: () => null, - [MetaBalancerBuilding.variants.splitterInverse]: () => null, - }; +MetaBalancerBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, + [MetaBalancerBuilding.variants.merger]: () => null, + [MetaBalancerBuilding.variants.mergerInverse]: () => null, + [MetaBalancerBuilding.variants.splitter]: () => null, + [MetaBalancerBuilding.variants.splitterInverse]: () => null, +}; - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaBalancerBuilding.variants.merger]: root => "regular", - [MetaBalancerBuilding.variants.mergerInverse]: root => "regular", - [MetaBalancerBuilding.variants.splitter]: root => "regular", - [MetaBalancerBuilding.variants.splitterInverse]: root => "regular", - }; +MetaBalancerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaBalancerBuilding.variants.merger]: root => "regular", + [MetaBalancerBuilding.variants.mergerInverse]: root => "regular", + [MetaBalancerBuilding.variants.splitter]: root => "regular", + [MetaBalancerBuilding.variants.splitterInverse]: root => "regular", +}; - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer)), - ], +MetaBalancerBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer)), ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaBalancerBuilding.variants.merger]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2 - ), - ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaBalancerBuilding.variants.merger]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2), ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaBalancerBuilding.variants.mergerInverse]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2 - ), - ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaBalancerBuilding.variants.mergerInverse]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2), ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaBalancerBuilding.variants.splitter]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2 - ), - ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaBalancerBuilding.variants.splitter]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2), ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaBalancerBuilding.variants.splitterInverse]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2 - ), - ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaBalancerBuilding.variants.splitterInverse]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) / 2), ], - }; + ], +}; - static silhouetteColors = { - [defaultBuildingVariant]: () => "#555759", - [MetaBalancerBuilding.variants.merger]: () => "#555759", - [MetaBalancerBuilding.variants.mergerInverse]: () => "#555759", - [MetaBalancerBuilding.variants.splitter]: () => "#555759", - [MetaBalancerBuilding.variants.splitterInverse]: () => "#555759", - }; +MetaBalancerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#555759", + [MetaBalancerBuilding.variants.merger]: () => "#555759", + [MetaBalancerBuilding.variants.mergerInverse]: () => "#555759", + [MetaBalancerBuilding.variants.splitter]: () => "#555759", + [MetaBalancerBuilding.variants.splitterInverse]: () => "#555759", +}; - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { +MetaBalancerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + }, + ]); + + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top }, + { pos: new Vector(1, 0), direction: enumDirection.top }, + ]); + + entity.components.BeltUnderlays.underlays = [ + { pos: new Vector(0, 0), direction: enumDirection.top }, + { pos: new Vector(1, 0), direction: enumDirection.top }, + ]; + }, + + [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => { + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + { + pos: new Vector(0, 0), + directions: [enumDirection.right], + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.BeltUnderlays.underlays = [{ pos: new Vector(0, 0), direction: enumDirection.top }]; + }, + + [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => { + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.BeltUnderlays.underlays = [{ pos: new Vector(0, 0), direction: enumDirection.top }]; + }, + + [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => { + { entity.components.ItemAcceptor.setSlots([ { pos: new Vector(0, 0), directions: [enumDirection.bottom], }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - }, ]); entity.components.ItemEjector.setSlots([ - { pos: new Vector(0, 0), direction: enumDirection.top }, - { pos: new Vector(1, 0), direction: enumDirection.top }, + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + }, ]); entity.components.BeltUnderlays.underlays = [ { pos: new Vector(0, 0), direction: enumDirection.top }, - { pos: new Vector(1, 0), direction: enumDirection.top }, ]; - }, + } + }, - [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => { + [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => { + { entity.components.ItemAcceptor.setSlots([ { pos: new Vector(0, 0), directions: [enumDirection.bottom], }, - { - pos: new Vector(0, 0), - directions: [enumDirection.right], - }, ]); - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + }, + ]); entity.components.BeltUnderlays.underlays = [ { pos: new Vector(0, 0), direction: enumDirection.top }, ]; - }, - - [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - }, - ]); - - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - - entity.components.BeltUnderlays.underlays = [ - { pos: new Vector(0, 0), direction: enumDirection.top }, - ]; - }, - - [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => { - { - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ]); - - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - }, - ]); - - entity.components.BeltUnderlays.underlays = [ - { pos: new Vector(0, 0), direction: enumDirection.top }, - ]; - } - }, - - [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => { - { - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ]); - - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - }, - ]); - - entity.components.BeltUnderlays.underlays = [ - { pos: new Vector(0, 0), direction: enumDirection.top }, - ]; - } - }, - }; -} + } + }, +}; diff --git a/src/js/game/buildings/belt.js b/src/js/game/buildings/belt.js index 7c214076..86b557a3 100644 --- a/src/js/game/buildings/belt.js +++ b/src/js/game/buildings/belt.js @@ -281,84 +281,79 @@ export class MetaBeltBuilding extends MetaBuilding { rotationVariant: 0, }; } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new BeltComponent({ - direction: enumDirection.top, // updated later - }) - ), - ]; - static silhouetteColors = { - [defaultBuildingVariant]: () => THEME.map.chunkOverview.beltColor, - }; - - static variantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right]; - - static overlayMatrices = { - [enumDirection.top]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), - [enumDirection.left]: (entity, rotationVariant) => - generateMatrixRotations([0, 0, 0, 1, 1, 0, 0, 1, 0]), - [enumDirection.right]: (entity, rotationVariant) => - generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]), - }; - - static placementSounds = { - [defaultBuildingVariant]: () => SOUNDS.placeBelt, - }; - - static rotationVariants = [0, 1, 2]; - - static avaibleVariants = { - [defaultBuildingVariant]: root => true, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isReplaceable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => null, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.Belt.direction = MetaBeltBuilding.variantToRotation[rotationVariant]; - }, - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed()), - ], - ], - }; } + +MetaBeltBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new BeltComponent({ + direction: enumDirection.top, // updated later + }) + ), +]; + +MetaBeltBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => THEME.map.chunkOverview.beltColor, +}; + +MetaBeltBuilding.variantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right]; + +MetaBeltBuilding.overlayMatrices = { + [enumDirection.top]: (entity, rotationVariant) => generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), + [enumDirection.left]: (entity, rotationVariant) => generateMatrixRotations([0, 0, 0, 1, 1, 0, 0, 1, 0]), + [enumDirection.right]: (entity, rotationVariant) => generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]), +}; + +MetaBeltBuilding.placementSounds = { + [defaultBuildingVariant]: () => SOUNDS.placeBelt, +}; + +MetaBeltBuilding.rotationVariants = [0, 1, 2]; + +MetaBeltBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => true, +}; + +MetaBeltBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaBeltBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaBeltBuilding.isReplaceable = { + [defaultBuildingVariant]: () => true, +}; + +MetaBeltBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaBeltBuilding.renderPins = { + [defaultBuildingVariant]: () => null, +}; + +MetaBeltBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, +}; + +MetaBeltBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaBeltBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.Belt.direction = MetaBeltBuilding.variantToRotation[rotationVariant]; + }, +}; + +MetaBeltBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())], + ], +}; diff --git a/src/js/game/buildings/comparator.js b/src/js/game/buildings/comparator.js index df40b946..8d4de324 100644 --- a/src/js/game/buildings/comparator.js +++ b/src/js/game/buildings/comparator.js @@ -107,96 +107,96 @@ export class MetaComparatorBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaComparatorBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - (entity, rotationVariant) => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ], - }) - ), - (entity, rotationVariant) => - entity.addComponent( - new LogicGateComponent({ - type: enumLogicGateType.compare, - }) - ), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: () => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#823cab", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - }; - - static layerByVariant = { - [defaultBuildingVariant]: () => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.compare; - }, - }; } + +MetaComparatorBuilding.setupEntityComponents = [ + (entity, rotationVariant) => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), + (entity, rotationVariant) => + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.compare, + }) + ), +]; + +MetaComparatorBuilding.overlayMatrices = { + [defaultBuildingVariant]: () => null, +}; + +MetaComparatorBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaComparatorBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#823cab", +}; + +MetaComparatorBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaComparatorBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaComparatorBuilding.renderPins = { + [defaultBuildingVariant]: () => false, +}; + +MetaComparatorBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaComparatorBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), +}; + +MetaComparatorBuilding.layerByVariant = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaComparatorBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.compare; + }, +}; diff --git a/src/js/game/buildings/constant_signal.js b/src/js/game/buildings/constant_signal.js index 2d780ff3..43ee62d9 100644 --- a/src/js/game/buildings/constant_signal.js +++ b/src/js/game/buildings/constant_signal.js @@ -107,70 +107,70 @@ export class MetaConstantSignalBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaConstantSignalBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - ], - }) - ), - entity => entity.addComponent(new ConstantSignalComponent({})), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 1, 1, 1]), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#2b84fd", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_constant_signal), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - ]); - }, - }; } + +MetaConstantSignalBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), + entity => entity.addComponent(new ConstantSignalComponent({})), +]; + +MetaConstantSignalBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 1, 1, 1]), +}; + +MetaConstantSignalBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaConstantSignalBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#2b84fd", +}; + +MetaConstantSignalBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaConstantSignalBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaConstantSignalBuilding.renderPins = { + [defaultBuildingVariant]: () => false, +}; + +MetaConstantSignalBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_constant_signal), +}; + +MetaConstantSignalBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", +}; + +MetaConstantSignalBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaConstantSignalBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/cutter.js b/src/js/game/buildings/cutter.js index 38989180..4a08e0e9 100644 --- a/src/js/game/buildings/cutter.js +++ b/src/js/game/buildings/cutter.js @@ -79,120 +79,117 @@ export class MetaCutterBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaCutterBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.cutter, - }) - ), - entity => entity.addComponent(new ItemEjectorComponent({})), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - ], - }) - ), - ]; - - static variants = { - quad: "quad", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - [MetaCutterBuilding.variants.quad]: (entity, rotationVariant) => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - [MetaCutterBuilding.variants.quad]: () => new Vector(4, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#7dcda2", - [MetaCutterBuilding.variants.quad]: () => "#7dcda2", - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_and_trash), - [MetaCutterBuilding.variants.quad]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_quad), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaCutterBuilding.variants.quad]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - [MetaCutterBuilding.variants.quad]: () => null, - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaCutterBuilding.variants.quad]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaCutterBuilding.variants.quad]: () => true, - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.cutter) / 2), - ], - ], - - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaCutterBuilding.variants.quad]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.cutterQuad) / 2 - ), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemEjector.setSlots([ - { pos: new Vector(0, 0), direction: enumDirection.top }, - { pos: new Vector(1, 0), direction: enumDirection.top }, - ]); - - entity.components.ItemProcessor.type = enumItemProcessorTypes.cutter; - }, - - [MetaCutterBuilding.variants.quad]: (entity, rotationVariant) => { - entity.components.ItemEjector.setSlots([ - { pos: new Vector(0, 0), direction: enumDirection.top }, - { pos: new Vector(1, 0), direction: enumDirection.top }, - { pos: new Vector(2, 0), direction: enumDirection.top }, - { pos: new Vector(3, 0), direction: enumDirection.top }, - ]); - entity.components.ItemProcessor.type = enumItemProcessorTypes.cutterQuad; - }, - }; } +MetaCutterBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.cutter, + }) + ), + entity => entity.addComponent(new ItemEjectorComponent({})), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ), +]; + +MetaCutterBuilding.variants = { + quad: "quad", +}; + +MetaCutterBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, + [MetaCutterBuilding.variants.quad]: (entity, rotationVariant) => null, +}; + +MetaCutterBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), + [MetaCutterBuilding.variants.quad]: () => new Vector(4, 1), +}; + +MetaCutterBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#7dcda2", + [MetaCutterBuilding.variants.quad]: () => "#7dcda2", +}; + +MetaCutterBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_and_trash), + [MetaCutterBuilding.variants.quad]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_quad), +}; + +MetaCutterBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaCutterBuilding.variants.quad]: root => "regular", +}; + +MetaCutterBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, + [MetaCutterBuilding.variants.quad]: () => null, +}; + +MetaCutterBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaCutterBuilding.variants.quad]: () => true, +}; + +MetaCutterBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaCutterBuilding.variants.quad]: () => true, +}; + +MetaCutterBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.cutter) / 2), + ], + ], + + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaCutterBuilding.variants.quad]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.cutterQuad) / 2), + ], + ], +}; + +MetaCutterBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top }, + { pos: new Vector(1, 0), direction: enumDirection.top }, + ]); + + entity.components.ItemProcessor.type = enumItemProcessorTypes.cutter; + }, + + [MetaCutterBuilding.variants.quad]: (entity, rotationVariant) => { + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top }, + { pos: new Vector(1, 0), direction: enumDirection.top }, + { pos: new Vector(2, 0), direction: enumDirection.top }, + { pos: new Vector(3, 0), direction: enumDirection.top }, + ]); + entity.components.ItemProcessor.type = enumItemProcessorTypes.cutterQuad; + }, +}; diff --git a/src/js/game/buildings/display.js b/src/js/game/buildings/display.js index 58a8a5cd..f3a35924 100644 --- a/src/js/game/buildings/display.js +++ b/src/js/game/buildings/display.js @@ -94,68 +94,68 @@ export class MetaDisplayBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaDisplayBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ], - }) - ), - entity => entity.addComponent(new DisplayComponent()), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#aaaaaa", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static renderPins = { - [defaultBuildingVariant]: () => true, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - }, - }; } + +MetaDisplayBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), + entity => entity.addComponent(new DisplayComponent()), +]; + +MetaDisplayBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaDisplayBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaDisplayBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#aaaaaa", +}; + +MetaDisplayBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaDisplayBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaDisplayBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display), +}; + +MetaDisplayBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaDisplayBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaDisplayBuilding.renderPins = { + [defaultBuildingVariant]: () => true, +}; + +MetaDisplayBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/filter.js b/src/js/game/buildings/filter.js index 4dfc57ff..a6a44233 100644 --- a/src/js/game/buildings/filter.js +++ b/src/js/game/buildings/filter.js @@ -119,124 +119,121 @@ export class MetaFilterBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaFilterBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - ], - }) - ), - - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ], - }) - ), - - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(1, 0), - direction: enumDirection.right, - }, - ], - }) - ), - - entity => entity.addComponent(new FilterComponent()), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: () => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#c45c2e", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_filter), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static additionalStatistics = { - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed()), - ], - ], - }; - - static renderPins = { - [defaultBuildingVariant]: () => true, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ]); - - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(1, 0), - direction: enumDirection.right, - }, - ]); - }, - }; } + +MetaFilterBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), + + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ], + }) + ), + + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(1, 0), + direction: enumDirection.right, + }, + ], + }) + ), + + entity => entity.addComponent(new FilterComponent()), +]; + +MetaFilterBuilding.overlayMatrices = { + [defaultBuildingVariant]: () => null, +}; + +MetaFilterBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), +}; + +MetaFilterBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#c45c2e", +}; + +MetaFilterBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaFilterBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaFilterBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_filter), +}; + +MetaFilterBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaFilterBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaFilterBuilding.additionalStatistics = { + [defaultBuildingVariant]: root => [ + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())], + ], +}; + +MetaFilterBuilding.renderPins = { + [defaultBuildingVariant]: () => true, +}; + +MetaFilterBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); + + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(1, 0), + direction: enumDirection.right, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/hub.js b/src/js/game/buildings/hub.js index be7a459b..acfeb4a1 100644 --- a/src/js/game/buildings/hub.js +++ b/src/js/game/buildings/hub.js @@ -108,229 +108,229 @@ export class MetaHubBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaHubBuilding.componentVariations[variant](entity, rotationVariant); } - - static canPipet = () => false; - - static setupEntityComponents = [ - entity => entity.addComponent(new HubComponent()), - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.hub, - }) - ), - - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 2), - type: enumPinSlotType.logicalEjector, - direction: enumDirection.left, - }, - ], - }) - ), - - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.top, enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.top], - filter: "shape", - }, - { - pos: new Vector(2, 0), - directions: [enumDirection.top], - filter: "shape", - }, - { - pos: new Vector(3, 0), - directions: [enumDirection.top, enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(0, 3), - directions: [enumDirection.bottom, enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 3), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(2, 3), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(3, 3), - directions: [enumDirection.bottom, enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(0, 1), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 2), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 3), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(3, 1), - directions: [enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(3, 2), - directions: [enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(3, 3), - directions: [enumDirection.right], - filter: "shape", - }, - ], - }) - ), - ]; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#eb5555", - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(4, 4), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => false, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => false, - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => false, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => false, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemProcessor.inputsPerCharge = 1; - - entity.components.ItemProcessor.type = enumItemProcessorTypes.hub; - - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 2), - type: enumPinSlotType.logicalEjector, - direction: enumDirection.left, - }, - ]); - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.top, enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.top], - filter: "shape", - }, - { - pos: new Vector(2, 0), - directions: [enumDirection.top], - filter: "shape", - }, - { - pos: new Vector(3, 0), - directions: [enumDirection.top, enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(0, 3), - directions: [enumDirection.bottom, enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 3), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(2, 3), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(3, 3), - directions: [enumDirection.bottom, enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(0, 1), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 2), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 3), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(3, 1), - directions: [enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(3, 2), - directions: [enumDirection.right], - filter: "shape", - }, - { - pos: new Vector(3, 3), - directions: [enumDirection.right], - filter: "shape", - }, - ]); - }, - }; } + +MetaHubBuilding.canPipet = () => false; + +MetaHubBuilding.setupEntityComponents = [ + entity => entity.addComponent(new HubComponent()), + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.hub, + }) + ), + + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 2), + type: enumPinSlotType.logicalEjector, + direction: enumDirection.left, + }, + ], + }) + ), + + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.top, enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.top], + filter: "shape", + }, + { + pos: new Vector(2, 0), + directions: [enumDirection.top], + filter: "shape", + }, + { + pos: new Vector(3, 0), + directions: [enumDirection.top, enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(0, 3), + directions: [enumDirection.bottom, enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 3), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(2, 3), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(3, 3), + directions: [enumDirection.bottom, enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(0, 1), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 2), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 3), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(3, 1), + directions: [enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(3, 2), + directions: [enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(3, 3), + directions: [enumDirection.right], + filter: "shape", + }, + ], + }) + ), +]; + +MetaHubBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#eb5555", +}; + +MetaHubBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(4, 4), +}; + +MetaHubBuilding.isRemovable = { + [defaultBuildingVariant]: () => false, +}; + +MetaHubBuilding.isRotateable = { + [defaultBuildingVariant]: () => false, +}; + +MetaHubBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaHubBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => false, +}; + +MetaHubBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaHubBuilding.layerPreview = { + [defaultBuildingVariant]: () => false, +}; + +MetaHubBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemProcessor.inputsPerCharge = 1; + + entity.components.ItemProcessor.type = enumItemProcessorTypes.hub; + + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 2), + type: enumPinSlotType.logicalEjector, + direction: enumDirection.left, + }, + ]); + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.top, enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.top], + filter: "shape", + }, + { + pos: new Vector(2, 0), + directions: [enumDirection.top], + filter: "shape", + }, + { + pos: new Vector(3, 0), + directions: [enumDirection.top, enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(0, 3), + directions: [enumDirection.bottom, enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 3), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(2, 3), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(3, 3), + directions: [enumDirection.bottom, enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(0, 1), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 2), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 3), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(3, 1), + directions: [enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(3, 2), + directions: [enumDirection.right], + filter: "shape", + }, + { + pos: new Vector(3, 3), + directions: [enumDirection.right], + filter: "shape", + }, + ]); + }, +}; diff --git a/src/js/game/buildings/item_producer.js b/src/js/game/buildings/item_producer.js index ba4bd135..a0956ca7 100644 --- a/src/js/game/buildings/item_producer.js +++ b/src/js/game/buildings/item_producer.js @@ -87,73 +87,73 @@ export class MetaItemProducerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaItemProducerBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - type: enumPinSlotType.logicalAcceptor, - direction: enumDirection.bottom, - }, - ], - }) - ), - - entity => entity.addComponent(new ItemProducerComponent()), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#b37dcd", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - type: enumPinSlotType.logicalAcceptor, - direction: enumDirection.bottom, - }, - ]); - }, - }; } + +MetaItemProducerBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + type: enumPinSlotType.logicalAcceptor, + direction: enumDirection.bottom, + }, + ], + }) + ), + + entity => entity.addComponent(new ItemProducerComponent()), +]; + +MetaItemProducerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaItemProducerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaItemProducerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#b37dcd", +}; + +MetaItemProducerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaItemProducerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaItemProducerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => true, +}; + +MetaItemProducerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaItemProducerBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaItemProducerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + type: enumPinSlotType.logicalAcceptor, + direction: enumDirection.bottom, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/lever.js b/src/js/game/buildings/lever.js index 67c24afc..765a715f 100644 --- a/src/js/game/buildings/lever.js +++ b/src/js/game/buildings/lever.js @@ -110,69 +110,69 @@ export class MetaLeverBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaLeverBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - ], - }) - ), - entity => entity.addComponent(new LeverComponent({})), - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#1a678b", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static renderPins = { - [defaultBuildingVariant]: () => true, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - ]); - }, - }; } + +MetaLeverBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), + entity => entity.addComponent(new LeverComponent({})), +]; + +MetaLeverBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaLeverBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaLeverBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#1a678b", +}; + +MetaLeverBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaLeverBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaLeverBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), +}; + +MetaLeverBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaLeverBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaLeverBuilding.renderPins = { + [defaultBuildingVariant]: () => true, +}; + +MetaLeverBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/logic_gate.js b/src/js/game/buildings/logic_gate.js index fafbe5d3..7a9a8ca7 100644 --- a/src/js/game/buildings/logic_gate.js +++ b/src/js/game/buildings/logic_gate.js @@ -107,174 +107,172 @@ export class MetaLogicGateBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaLogicGateBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [], - }) - ), - entity => entity.addComponent(new LogicGateComponent({})), - ]; - - static variants = { - not: "not", - xor: "xor", - or: "or", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), - [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), - [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), - [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), - }; - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaLogicGateBuilding.variants.xor]: () => new Vector(1, 1), - [MetaLogicGateBuilding.variants.or]: () => new Vector(1, 1), - [MetaLogicGateBuilding.variants.not]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#f48d41", - [MetaLogicGateBuilding.variants.xor]: () => "#f4a241", - [MetaLogicGateBuilding.variants.or]: () => "#f4d041", - [MetaLogicGateBuilding.variants.not]: () => "#f44184", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaLogicGateBuilding.variants.xor]: () => true, - [MetaLogicGateBuilding.variants.or]: () => true, - [MetaLogicGateBuilding.variants.not]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaLogicGateBuilding.variants.xor]: () => true, - [MetaLogicGateBuilding.variants.or]: () => true, - [MetaLogicGateBuilding.variants.not]: () => true, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - [MetaLogicGateBuilding.variants.xor]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - [MetaLogicGateBuilding.variants.or]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - [MetaLogicGateBuilding.variants.not]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - [MetaLogicGateBuilding.variants.xor]: root => "wires", - [MetaLogicGateBuilding.variants.or]: root => "wires", - [MetaLogicGateBuilding.variants.not]: root => "wires", - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - [MetaLogicGateBuilding.variants.xor]: () => false, - [MetaLogicGateBuilding.variants.or]: () => false, - [MetaLogicGateBuilding.variants.not]: () => false, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - [MetaLogicGateBuilding.variants.xor]: () => "wires", - [MetaLogicGateBuilding.variants.or]: () => "wires", - [MetaLogicGateBuilding.variants.not]: () => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.and; - }, - - [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.xor; - }, - - [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.or; - }, - [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.not; - }, - }; } +MetaLogicGateBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [], + }) + ), + entity => entity.addComponent(new LogicGateComponent({})), +]; + +MetaLogicGateBuilding.variants = { + not: "not", + xor: "xor", + or: "or", +}; + +MetaLogicGateBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), + [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), + [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 1]), + [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), +}; +MetaLogicGateBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaLogicGateBuilding.variants.xor]: () => new Vector(1, 1), + [MetaLogicGateBuilding.variants.or]: () => new Vector(1, 1), + [MetaLogicGateBuilding.variants.not]: () => new Vector(1, 1), +}; + +MetaLogicGateBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#f48d41", + [MetaLogicGateBuilding.variants.xor]: () => "#f4a241", + [MetaLogicGateBuilding.variants.or]: () => "#f4d041", + [MetaLogicGateBuilding.variants.not]: () => "#f44184", +}; + +MetaLogicGateBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaLogicGateBuilding.variants.xor]: () => true, + [MetaLogicGateBuilding.variants.or]: () => true, + [MetaLogicGateBuilding.variants.not]: () => true, +}; + +MetaLogicGateBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaLogicGateBuilding.variants.xor]: () => true, + [MetaLogicGateBuilding.variants.or]: () => true, + [MetaLogicGateBuilding.variants.not]: () => true, +}; + +MetaLogicGateBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), + [MetaLogicGateBuilding.variants.xor]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), + [MetaLogicGateBuilding.variants.or]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), + [MetaLogicGateBuilding.variants.not]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), +}; + +MetaLogicGateBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", + [MetaLogicGateBuilding.variants.xor]: root => "wires", + [MetaLogicGateBuilding.variants.or]: root => "wires", + [MetaLogicGateBuilding.variants.not]: root => "wires", +}; + +MetaLogicGateBuilding.renderPins = { + [defaultBuildingVariant]: () => false, + [MetaLogicGateBuilding.variants.xor]: () => false, + [MetaLogicGateBuilding.variants.or]: () => false, + [MetaLogicGateBuilding.variants.not]: () => false, +}; + +MetaLogicGateBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", + [MetaLogicGateBuilding.variants.xor]: () => "wires", + [MetaLogicGateBuilding.variants.or]: () => "wires", + [MetaLogicGateBuilding.variants.not]: () => "wires", +}; + +MetaLogicGateBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.and; + }, + + [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.xor; + }, + + [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.or; + }, + [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.not; + }, +}; diff --git a/src/js/game/buildings/miner.js b/src/js/game/buildings/miner.js index 97d64da7..e364a5fc 100644 --- a/src/js/game/buildings/miner.js +++ b/src/js/game/buildings/miner.js @@ -103,90 +103,83 @@ export class MetaMinerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaMinerBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => entity.addComponent(new MinerComponent({})), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), - ]; - - static variants = { - chainable: "chainable", - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#b37dcd", - [MetaMinerBuilding.variants.chainable]: () => "#b37dcd", - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaMinerBuilding.variants.chainable]: () => new Vector(1, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaMinerBuilding.variants.chainable]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaMinerBuilding.variants.chainable]: () => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaMinerBuilding.variants.chainable]: root => "regular", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([1, 1, 1, 1, 0, 1, 1, 1, 1]), - [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 1, 1, 1]), - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - !root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_miner_chainable), - [MetaMinerBuilding.variants.chainable]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_miner_chainable), - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getMinerBaseSpeed()), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaMinerBuilding.variants.chainable]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getMinerBaseSpeed()), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.Miner.chainable = false; - }, - - [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => { - entity.components.Miner.chainable = true; - }, - }; } + +MetaMinerBuilding.setupEntityComponents = [ + entity => entity.addComponent(new MinerComponent({})), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), +]; +MetaMinerBuilding.variants = { + chainable: "chainable", +}; + +MetaMinerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#b37dcd", + [MetaMinerBuilding.variants.chainable]: () => "#b37dcd", +}; + +MetaMinerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaMinerBuilding.variants.chainable]: () => new Vector(1, 1), +}; + +MetaMinerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaMinerBuilding.variants.chainable]: () => true, +}; + +MetaMinerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaMinerBuilding.variants.chainable]: () => true, +}; + +MetaMinerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaMinerBuilding.variants.chainable]: root => "regular", +}; + +MetaMinerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([1, 1, 1, 1, 0, 1, 1, 1, 1]), + [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 1, 1, 1]), +}; + +MetaMinerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + !root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_miner_chainable), + [MetaMinerBuilding.variants.chainable]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_miner_chainable), +}; + +MetaMinerBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getMinerBaseSpeed())], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaMinerBuilding.variants.chainable]: root => [ + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getMinerBaseSpeed())], + ], +}; + +MetaMinerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.Miner.chainable = false; + }, + + [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => { + entity.components.Miner.chainable = true; + }, +}; diff --git a/src/js/game/buildings/mixer.js b/src/js/game/buildings/mixer.js index 4aec6e6d..5c3aad95 100644 --- a/src/js/game/buildings/mixer.js +++ b/src/js/game/buildings/mixer.js @@ -104,102 +104,102 @@ export class MetaMixerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaMixerBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 2, - processorType: enumItemProcessorTypes.mixer, - }) - ), - - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - ], - }) - ), - ]; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#cdbb7d", - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_mixer), - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.mixer)), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemProcessor.inputsPerCharge = 2; - - entity.components.ItemProcessor.type = enumItemProcessorTypes.mixer; - - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - ]); - }, - }; } + +MetaMixerBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 2, + processorType: enumItemProcessorTypes.mixer, + }) + ), + + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + ], + }) + ), +]; + +MetaMixerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#cdbb7d", +}; + +MetaMixerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), +}; + +MetaMixerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaMixerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaMixerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaMixerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaMixerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_mixer), +}; + +MetaMixerBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.mixer)), + ], + ], +}; + +MetaMixerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemProcessor.inputsPerCharge = 2; + + entity.components.ItemProcessor.type = enumItemProcessorTypes.mixer; + + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + ]); + }, +}; diff --git a/src/js/game/buildings/painter.js b/src/js/game/buildings/painter.js index c107ad25..83799ecb 100644 --- a/src/js/game/buildings/painter.js +++ b/src/js/game/buildings/painter.js @@ -109,285 +109,277 @@ export class MetaPainterBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaPainterBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => entity.addComponent(new ItemProcessorComponent({})), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(1, 0), direction: enumDirection.right }], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.top], - filter: "color", - }, - ], - }) - ), - ]; - - static variants = { - mirrored: "mirrored", - double: "double", - quad: "quad", - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#cd9b7d", - [MetaPainterBuilding.variants.mirrored]: () => "#cd9b7d", - [MetaPainterBuilding.variants.double]: () => "#cd9b7d", - [MetaPainterBuilding.variants.quad]: () => "#cd9b7d", - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - [MetaPainterBuilding.variants.mirrored]: () => new Vector(2, 1), - [MetaPainterBuilding.variants.double]: () => new Vector(2, 2), - [MetaPainterBuilding.variants.quad]: () => new Vector(4, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaPainterBuilding.variants.mirrored]: () => true, - [MetaPainterBuilding.variants.double]: () => true, - [MetaPainterBuilding.variants.quad]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaPainterBuilding.variants.mirrored]: () => true, - [MetaPainterBuilding.variants.double]: () => true, - [MetaPainterBuilding.variants.quad]: () => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaPainterBuilding.variants.mirrored]: root => "regular", - [MetaPainterBuilding.variants.double]: root => "regular", - [MetaPainterBuilding.variants.quad]: root => "regular", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - [MetaPainterBuilding.variants.mirrored]: (entity, rotationVariant) => null, - [MetaPainterBuilding.variants.double]: (entity, rotationVariant) => null, - [MetaPainterBuilding.variants.quad]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter), - [MetaPainterBuilding.variants.mirrored]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter), - [MetaPainterBuilding.variants.double]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter_double), - [MetaPainterBuilding.variants.quad]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painter)), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaPainterBuilding.variants.mirrored]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painter)), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaPainterBuilding.variants.double]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond( - root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterDouble) - ), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaPainterBuilding.variants.quad]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterQuad)), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - if (entity.components.WiredPins) { - entity.removeComponent(WiredPinsComponent); - } - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.top], - filter: "color", - }, - ]); - - entity.components.ItemEjector.setSlots([ - { pos: new Vector(1, 0), direction: enumDirection.right }, - ]); - - entity.components.ItemProcessor.type = enumItemProcessorTypes.painter; - entity.components.ItemProcessor.processingRequirement = null; - entity.components.ItemProcessor.inputsPerCharge = 2; - }, - - [MetaPainterBuilding.variants.mirrored]: (entity, rotationVariant) => { - if (entity.components.WiredPins) { - entity.removeComponent(WiredPinsComponent); - } - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - ]); - - entity.components.ItemEjector.setSlots([ - { pos: new Vector(1, 0), direction: enumDirection.right }, - ]); - - entity.components.ItemProcessor.type = enumItemProcessorTypes.painter; - entity.components.ItemProcessor.processingRequirement = null; - entity.components.ItemProcessor.inputsPerCharge = 2; - }, - - [MetaPainterBuilding.variants.double]: (entity, rotationVariant) => { - if (entity.components.WiredPins) { - entity.removeComponent(WiredPinsComponent); - } - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 1), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.top], - filter: "color", - }, - ]); - - entity.components.ItemEjector.setSlots([ - { pos: new Vector(1, 0), direction: enumDirection.right }, - ]); - - entity.components.ItemProcessor.type = enumItemProcessorTypes.painterDouble; - entity.components.ItemProcessor.processingRequirement = null; - entity.components.ItemProcessor.inputsPerCharge = 3; - }, - - [MetaPainterBuilding.variants.quad]: (entity, rotationVariant) => { - if (!entity.components.WiredPins) { - entity.addComponent(new WiredPinsComponent({ slots: [] })); - } - - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(1, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(2, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(3, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.left], - filter: "shape", - }, - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - { - pos: new Vector(2, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - { - pos: new Vector(3, 0), - directions: [enumDirection.bottom], - filter: "color", - }, - ]); - - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - - entity.components.ItemProcessor.type = enumItemProcessorTypes.painterQuad; - entity.components.ItemProcessor.processingRequirement = enumItemProcessorRequirements.painterQuad; - entity.components.ItemProcessor.inputsPerCharge = 5; - }, - }; } + +MetaPainterBuilding.setupEntityComponents = [ + entity => entity.addComponent(new ItemProcessorComponent({})), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(1, 0), direction: enumDirection.right }], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.top], + filter: "color", + }, + ], + }) + ), +]; + +MetaPainterBuilding.variants = { + mirrored: "mirrored", + double: "double", + quad: "quad", +}; + +MetaPainterBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#cd9b7d", + [MetaPainterBuilding.variants.mirrored]: () => "#cd9b7d", + [MetaPainterBuilding.variants.double]: () => "#cd9b7d", + [MetaPainterBuilding.variants.quad]: () => "#cd9b7d", +}; + +MetaPainterBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), + [MetaPainterBuilding.variants.mirrored]: () => new Vector(2, 1), + [MetaPainterBuilding.variants.double]: () => new Vector(2, 2), + [MetaPainterBuilding.variants.quad]: () => new Vector(4, 1), +}; + +MetaPainterBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaPainterBuilding.variants.mirrored]: () => true, + [MetaPainterBuilding.variants.double]: () => true, + [MetaPainterBuilding.variants.quad]: () => true, +}; + +MetaPainterBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaPainterBuilding.variants.mirrored]: () => true, + [MetaPainterBuilding.variants.double]: () => true, + [MetaPainterBuilding.variants.quad]: () => true, +}; + +MetaPainterBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaPainterBuilding.variants.mirrored]: root => "regular", + [MetaPainterBuilding.variants.double]: root => "regular", + [MetaPainterBuilding.variants.quad]: root => "regular", +}; + +MetaPainterBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, + [MetaPainterBuilding.variants.mirrored]: (entity, rotationVariant) => null, + [MetaPainterBuilding.variants.double]: (entity, rotationVariant) => null, + [MetaPainterBuilding.variants.quad]: (entity, rotationVariant) => null, +}; + +MetaPainterBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter), + [MetaPainterBuilding.variants.mirrored]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter), + [MetaPainterBuilding.variants.double]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_painter_double), + [MetaPainterBuilding.variants.quad]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), +}; + +MetaPainterBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painter)), + ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaPainterBuilding.variants.mirrored]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painter)), + ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaPainterBuilding.variants.double]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterDouble)), + ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaPainterBuilding.variants.quad]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterQuad)), + ], + ], +}; + +MetaPainterBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + if (entity.components.WiredPins) { + entity.removeComponent(WiredPinsComponent); + } + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.top], + filter: "color", + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(1, 0), direction: enumDirection.right }]); + + entity.components.ItemProcessor.type = enumItemProcessorTypes.painter; + entity.components.ItemProcessor.processingRequirement = null; + entity.components.ItemProcessor.inputsPerCharge = 2; + }, + + [MetaPainterBuilding.variants.mirrored]: (entity, rotationVariant) => { + if (entity.components.WiredPins) { + entity.removeComponent(WiredPinsComponent); + } + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(1, 0), direction: enumDirection.right }]); + + entity.components.ItemProcessor.type = enumItemProcessorTypes.painter; + entity.components.ItemProcessor.processingRequirement = null; + entity.components.ItemProcessor.inputsPerCharge = 2; + }, + + [MetaPainterBuilding.variants.double]: (entity, rotationVariant) => { + if (entity.components.WiredPins) { + entity.removeComponent(WiredPinsComponent); + } + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 1), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.top], + filter: "color", + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(1, 0), direction: enumDirection.right }]); + + entity.components.ItemProcessor.type = enumItemProcessorTypes.painterDouble; + entity.components.ItemProcessor.processingRequirement = null; + entity.components.ItemProcessor.inputsPerCharge = 3; + }, + + [MetaPainterBuilding.variants.quad]: (entity, rotationVariant) => { + if (!entity.components.WiredPins) { + entity.addComponent(new WiredPinsComponent({ slots: [] })); + } + + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(1, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(2, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(3, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.left], + filter: "shape", + }, + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + { + pos: new Vector(2, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + { + pos: new Vector(3, 0), + directions: [enumDirection.bottom], + filter: "color", + }, + ]); + + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.ItemProcessor.type = enumItemProcessorTypes.painterQuad; + entity.components.ItemProcessor.processingRequirement = enumItemProcessorRequirements.painterQuad; + entity.components.ItemProcessor.inputsPerCharge = 5; + }, +}; diff --git a/src/js/game/buildings/reader.js b/src/js/game/buildings/reader.js index 2f4b63f9..4b4c8fed 100644 --- a/src/js/game/buildings/reader.js +++ b/src/js/game/buildings/reader.js @@ -121,141 +121,137 @@ export class MetaReaderBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaReaderBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - ], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ], - }) - ), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - ], - }) - ), - entity => - entity.addComponent( - new ItemProcessorComponent({ - processorType: enumItemProcessorTypes.reader, - inputsPerCharge: 1, - }) - ), - entity => - entity.addComponent( - new BeltUnderlaysComponent({ - underlays: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - ], - }) - ), - entity => entity.addComponent(new BeltReaderComponent()), - ]; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#25fff2", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static additionalStatistics = { - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed()), - ], - ], - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_belt_reader), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static renderPins = { - [defaultBuildingVariant]: () => true, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ]); - - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - ]); - - entity.components.ItemProcessor.inputsPerCharge = 1; - - entity.components.ItemProcessor.type = enumItemProcessorTypes.reader; - - entity.components.BeltUnderlays.underlays = [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - ]; - }, - }; } + +MetaReaderBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ], + }) + ), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ], + }) + ), + entity => + entity.addComponent( + new ItemProcessorComponent({ + processorType: enumItemProcessorTypes.reader, + inputsPerCharge: 1, + }) + ), + entity => + entity.addComponent( + new BeltUnderlaysComponent({ + underlays: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ], + }) + ), + entity => entity.addComponent(new BeltReaderComponent()), +]; + +MetaReaderBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaReaderBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#25fff2", +}; + +MetaReaderBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaReaderBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaReaderBuilding.additionalStatistics = { + [defaultBuildingVariant]: root => [ + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())], + ], +}; + +MetaReaderBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), +}; + +MetaReaderBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_belt_reader), +}; + +MetaReaderBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaReaderBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaReaderBuilding.renderPins = { + [defaultBuildingVariant]: () => true, +}; + +MetaReaderBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); + + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ]); + + entity.components.ItemProcessor.inputsPerCharge = 1; + + entity.components.ItemProcessor.type = enumItemProcessorTypes.reader; + + entity.components.BeltUnderlays.underlays = [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ]; + }, +}; diff --git a/src/js/game/buildings/rotater.js b/src/js/game/buildings/rotater.js index 17b58047..46c2f70c 100644 --- a/src/js/game/buildings/rotater.js +++ b/src/js/game/buildings/rotater.js @@ -118,143 +118,143 @@ export class MetaRotaterBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaRotaterBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.rotater, - }) - ), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - ], - }) - ), - ]; - - static variants = { - ccw: "ccw", - rotate180: "rotate180", - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaRotaterBuilding.variants.ccw]: () => new Vector(1, 1), - [MetaRotaterBuilding.variants.rotate180]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#7dc6cd", - [MetaRotaterBuilding.variants.ccw]: () => "#7dc6cd", - [MetaRotaterBuilding.variants.rotate180]: () => "#7dc6cd", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 1, 1, 1, 0, 0, 1, 1]), - [MetaRotaterBuilding.variants.ccw]: (entity, rotationVariant) => - generateMatrixRotations([1, 1, 0, 0, 1, 1, 1, 1, 0]), - [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => - generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 1]), - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater), - [MetaRotaterBuilding.variants.ccw]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_ccw), - [MetaRotaterBuilding.variants.rotate180]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_180), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaRotaterBuilding.variants.ccw]: () => true, - [MetaRotaterBuilding.variants.rotate180]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaRotaterBuilding.variants.ccw]: () => true, - [MetaRotaterBuilding.variants.rotate180]: () => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaRotaterBuilding.variants.ccw]: root => "regular", - [MetaRotaterBuilding.variants.rotate180]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - [MetaRotaterBuilding.variants.ccw]: () => null, - [MetaRotaterBuilding.variants.rotate180]: () => null, - }; - - static renderPins = { - [defaultBuildingVariant]: () => null, - [MetaRotaterBuilding.variants.ccw]: () => null, - [MetaRotaterBuilding.variants.rotate180]: () => null, - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater)), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaRotaterBuilding.variants.ccw]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotaterCCW)), - ], - ], - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaRotaterBuilding.variants.rotate180]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater180)), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater; - }, - - [MetaRotaterBuilding.variants.ccw]: (entity, rotationVariant) => { - entity.components.ItemProcessor.type = enumItemProcessorTypes.rotaterCCW; - }, - - [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => { - entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater180; - }, - }; } + +MetaRotaterBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.rotater, + }) + ), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ), +]; + +MetaRotaterBuilding.variants = { + ccw: "ccw", + rotate180: "rotate180", +}; + +MetaRotaterBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaRotaterBuilding.variants.ccw]: () => new Vector(1, 1), + [MetaRotaterBuilding.variants.rotate180]: () => new Vector(1, 1), +}; + +MetaRotaterBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#7dc6cd", + [MetaRotaterBuilding.variants.ccw]: () => "#7dc6cd", + [MetaRotaterBuilding.variants.rotate180]: () => "#7dc6cd", +}; + +MetaRotaterBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 1, 1, 1, 0, 0, 1, 1]), + [MetaRotaterBuilding.variants.ccw]: (entity, rotationVariant) => + generateMatrixRotations([1, 1, 0, 0, 1, 1, 1, 1, 0]), + [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => + generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 1]), +}; + +MetaRotaterBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater), + [MetaRotaterBuilding.variants.ccw]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_ccw), + [MetaRotaterBuilding.variants.rotate180]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_180), +}; + +MetaRotaterBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaRotaterBuilding.variants.ccw]: () => true, + [MetaRotaterBuilding.variants.rotate180]: () => true, +}; + +MetaRotaterBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaRotaterBuilding.variants.ccw]: () => true, + [MetaRotaterBuilding.variants.rotate180]: () => true, +}; + +MetaRotaterBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaRotaterBuilding.variants.ccw]: root => "regular", + [MetaRotaterBuilding.variants.rotate180]: root => "regular", +}; + +MetaRotaterBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, + [MetaRotaterBuilding.variants.ccw]: () => null, + [MetaRotaterBuilding.variants.rotate180]: () => null, +}; + +MetaRotaterBuilding.renderPins = { + [defaultBuildingVariant]: () => null, + [MetaRotaterBuilding.variants.ccw]: () => null, + [MetaRotaterBuilding.variants.rotate180]: () => null, +}; + +MetaRotaterBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater)), + ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaRotaterBuilding.variants.ccw]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotaterCCW)), + ], + ], + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaRotaterBuilding.variants.rotate180]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater180)), + ], + ], +}; + +MetaRotaterBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater; + }, + + [MetaRotaterBuilding.variants.ccw]: (entity, rotationVariant) => { + entity.components.ItemProcessor.type = enumItemProcessorTypes.rotaterCCW; + }, + + [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => { + entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater180; + }, +}; diff --git a/src/js/game/buildings/stacker.js b/src/js/game/buildings/stacker.js index dd5cb03c..08bafedb 100644 --- a/src/js/game/buildings/stacker.js +++ b/src/js/game/buildings/stacker.js @@ -118,109 +118,109 @@ export class MetaStackerBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaStackerBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 2, - processorType: enumItemProcessorTypes.stacker, - }) - ), - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - ], - }) - ), - ]; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#9fcd7d", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_stacker), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - }; - - static renderPins = { - [defaultBuildingVariant]: () => null, - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [ - T.ingame.buildingPlacement.infoTexts.speed, - formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.stacker)), - ], - ], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemProcessor.inputsPerCharge = 2; - - entity.components.ItemProcessor.type = enumItemProcessorTypes.stacker; - - entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - { - pos: new Vector(1, 0), - directions: [enumDirection.bottom], - filter: "shape", - }, - ]); - }, - }; } + +MetaStackerBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 2, + processorType: enumItemProcessorTypes.stacker, + }) + ), + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ), +]; + +MetaStackerBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 1), +}; + +MetaStackerBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#9fcd7d", +}; + +MetaStackerBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaStackerBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_stacker), +}; + +MetaStackerBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaStackerBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaStackerBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaStackerBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, +}; + +MetaStackerBuilding.renderPins = { + [defaultBuildingVariant]: () => null, +}; + +MetaStackerBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [ + T.ingame.buildingPlacement.infoTexts.speed, + formatItemsPerSecond(root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.stacker)), + ], + ], +}; + +MetaStackerBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemProcessor.inputsPerCharge = 2; + + entity.components.ItemProcessor.type = enumItemProcessorTypes.stacker; + + entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); + + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + { + pos: new Vector(1, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ]); + }, +}; diff --git a/src/js/game/buildings/storage.js b/src/js/game/buildings/storage.js index 01d81ee8..597e22a7 100644 --- a/src/js/game/buildings/storage.js +++ b/src/js/game/buildings/storage.js @@ -121,145 +121,145 @@ export class MetaStorageBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaStorageBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - // Required, since the item processor needs this. - entity.addComponent( - new ItemEjectorComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(1, 0), - direction: enumDirection.top, - }, - ], - }) - ), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 1), - directions: [enumDirection.bottom], - }, - { - pos: new Vector(1, 1), - directions: [enumDirection.bottom], - }, - ], - }) - ), - entity => - entity.addComponent( - new StorageComponent({ - maximumStorage: storageSize, - }) - ), - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(1, 1), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 1), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - ], - }) - ), - ]; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(2, 2), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#bbdf6d", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => [ - [T.ingame.buildingPlacement.infoTexts.storage, formatBigNumber(storageSize)], - ], - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_storage), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static renderPins = { - [defaultBuildingVariant]: () => true, - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - { - pos: new Vector(1, 0), - direction: enumDirection.top, - }, - ]); - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 1), - directions: [enumDirection.bottom], - }, - { - pos: new Vector(1, 1), - directions: [enumDirection.bottom], - }, - ]); - entity.components.Storage.maximumStorage = storageSize; - entity.components.WiredPins.setSlots([ - { - pos: new Vector(1, 1), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 1), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - ]); - }, - }; } + +MetaStorageBuilding.setupEntityComponents = [ + entity => + // Required, since the item processor needs this. + entity.addComponent( + new ItemEjectorComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(1, 0), + direction: enumDirection.top, + }, + ], + }) + ), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 1), + directions: [enumDirection.bottom], + }, + { + pos: new Vector(1, 1), + directions: [enumDirection.bottom], + }, + ], + }) + ), + entity => + entity.addComponent( + new StorageComponent({ + maximumStorage: storageSize, + }) + ), + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(1, 1), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 1), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), +]; + +MetaStorageBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(2, 2), +}; + +MetaStorageBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#bbdf6d", +}; + +MetaStorageBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaStorageBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaStorageBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => [ + [T.ingame.buildingPlacement.infoTexts.storage, formatBigNumber(storageSize)], + ], +}; + +MetaStorageBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, +}; + +MetaStorageBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_storage), +}; + +MetaStorageBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaStorageBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaStorageBuilding.renderPins = { + [defaultBuildingVariant]: () => true, +}; + +MetaStorageBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + { + pos: new Vector(1, 0), + direction: enumDirection.top, + }, + ]); + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 1), + directions: [enumDirection.bottom], + }, + { + pos: new Vector(1, 1), + directions: [enumDirection.bottom], + }, + ]); + entity.components.Storage.maximumStorage = storageSize; + entity.components.WiredPins.setSlots([ + { + pos: new Vector(1, 1), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 1), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/transistor.js b/src/js/game/buildings/transistor.js index 820a5a45..14523e78 100644 --- a/src/js/game/buildings/transistor.js +++ b/src/js/game/buildings/transistor.js @@ -107,98 +107,97 @@ export class MetaTransistorBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaTransistorBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ], - }) - ), - entity => - entity.addComponent( - new LogicGateComponent({ - type: enumLogicGateType.transistor, - }) - ), - ]; - - static variants = { - mirrored: "mirrored", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), - [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaTransistorBuilding.variants.mirrored]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#823cab", - [MetaTransistorBuilding.variants.mirrored]: () => "#823cab", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaTransistorBuilding.variants.mirrored]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaTransistorBuilding.variants.mirrored]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - [MetaTransistorBuilding.variants.mirrored]: () => false, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - [MetaTransistorBuilding.variants.mirrored]: () => "wires", - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - [MetaTransistorBuilding.variants.mirrored]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - [MetaTransistorBuilding.variants.mirrored]: root => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.slots[1].direction = enumDirection.left; - }, - - [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => { - entity.components.WiredPins.slots[1].direction = enumDirection.right; - }, - }; } + +MetaTransistorBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), + entity => + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.transistor, + }) + ), +]; + +MetaTransistorBuilding.variants = { + mirrored: "mirrored", +}; + +MetaTransistorBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 0, 0, 1, 0]), + [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 0, 1, 1, 0, 1, 0]), +}; + +MetaTransistorBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaTransistorBuilding.variants.mirrored]: () => new Vector(1, 1), +}; + +MetaTransistorBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#823cab", + [MetaTransistorBuilding.variants.mirrored]: () => "#823cab", +}; + +MetaTransistorBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaTransistorBuilding.variants.mirrored]: () => true, +}; + +MetaTransistorBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaTransistorBuilding.variants.mirrored]: () => true, +}; + +MetaTransistorBuilding.renderPins = { + [defaultBuildingVariant]: () => false, + [MetaTransistorBuilding.variants.mirrored]: () => false, +}; + +MetaTransistorBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", + [MetaTransistorBuilding.variants.mirrored]: () => "wires", +}; + +MetaTransistorBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), + [MetaTransistorBuilding.variants.mirrored]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_logic_gates), +}; + +MetaTransistorBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", + [MetaTransistorBuilding.variants.mirrored]: root => "wires", +}; + +MetaTransistorBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.slots[1].direction = enumDirection.left; + }, + + [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => { + entity.components.WiredPins.slots[1].direction = enumDirection.right; + }, +}; diff --git a/src/js/game/buildings/trash.js b/src/js/game/buildings/trash.js index 418f3fb2..bb5d6794 100644 --- a/src/js/game/buildings/trash.js +++ b/src/js/game/buildings/trash.js @@ -118,7 +118,7 @@ export class MetaTrashBuilding extends MetaBuilding { * @param {Entity} entity */ setupEntityComponents(entity) { - MetaTrashBuilding.setupEntityComponents.forEach(func => func(entity)); + MetaTrashBuilding.setupEntityComponents.forEach(func => func.bind(this)(entity)); } /** @@ -129,92 +129,93 @@ export class MetaTrashBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaTrashBuilding.componentVariations[variant].bind(this)(entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [ - { - pos: new Vector(0, 0), - directions: [ - enumDirection.top, - enumDirection.right, - enumDirection.bottom, - enumDirection.left, - ], - }, - ], - }) - ), - entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.trash, - }) - ), - function (entity) { - // @ts-ignore - this.addAchievementReceiver(entity); - }, - ]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 1]), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#ed1d5d", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_and_trash), - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [ - enumDirection.top, - enumDirection.right, - enumDirection.bottom, - enumDirection.left, - ], - }, - ]); - - entity.components.ItemProcessor.inputsPerCharge = 1; - - entity.components.ItemProcessor.type = enumItemProcessorTypes.trash; - }, - }; } + +MetaTrashBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [ + enumDirection.top, + enumDirection.right, + enumDirection.bottom, + enumDirection.left, + ], + }, + ], + }) + ), + entity => + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.trash, + }) + ), + + function (entity) { + // @ts-ignore + this.addAchievementReceiver(entity); + }, +]; + +MetaTrashBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 1]), +}; + +MetaTrashBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaTrashBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#ed1d5d", +}; + +MetaTrashBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaTrashBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, +}; + +MetaTrashBuilding.renderPins = { + [defaultBuildingVariant]: () => false, +}; + +MetaTrashBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", +}; + +MetaTrashBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, +}; + +MetaTrashBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_and_trash), +}; + +MetaTrashBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [ + enumDirection.top, + enumDirection.right, + enumDirection.bottom, + enumDirection.left, + ], + }, + ]); + + entity.components.ItemProcessor.inputsPerCharge = 1; + + entity.components.ItemProcessor.type = enumItemProcessorTypes.trash; + }, +}; diff --git a/src/js/game/buildings/underground_belt.js b/src/js/game/buildings/underground_belt.js index 86aa7e0c..6c74e653 100644 --- a/src/js/game/buildings/underground_belt.js +++ b/src/js/game/buildings/underground_belt.js @@ -234,139 +234,142 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding { entity.components.UndergroundBelt.tier = MetaUndergroundBeltBuilding.variantToTier[variant]; MetaUndergroundBeltBuilding.componentVariationsByRotation[mode](entity, rotationVariant); } - - static setupEntityComponents = [ - // Required, since the item processor needs this. - entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [], - }) - ), - entity => entity.addComponent(new UndergroundBeltComponent({})), - entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [], - }) - ), - ]; - - static rotationVariants = [0, 1]; - - static variants = { - tier2: "tier2", - }; - - static overlayMatricesByRotation = [ - // Sender - (entity, rotationVariant) => generateMatrixRotations([1, 1, 1, 0, 1, 0, 0, 1, 0]), - // Receiver - (entity, rotationVariant) => generateMatrixRotations([0, 1, 0, 0, 1, 0, 1, 1, 1]), - ]; - - static rotationVariantToMode = [enumUndergroundBeltMode.sender, enumUndergroundBeltMode.receiver]; - - static variantToTier = { - [defaultBuildingVariant]: 0, - [MetaUndergroundBeltBuilding.variants.tier2]: 1, - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaUndergroundBeltBuilding.variants.tier2]: () => new Vector(1, 1), - }; - - static silhouetteColorsByRotation = [() => "#6d9dff", () => "#71ff9c"]; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaUndergroundBeltBuilding.variants.tier2]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaUndergroundBeltBuilding.variants.tier2]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => null, - [MetaUndergroundBeltBuilding.variants.tier2]: () => null, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => null, - [MetaUndergroundBeltBuilding.variants.tier2]: () => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_tunnel), - [MetaUndergroundBeltBuilding.variants.tier2]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_underground_belt_tier_2), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "regular", - [MetaUndergroundBeltBuilding.variants.tier2]: root => "regular", - }; - - static additionalStatistics = { - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [defaultBuildingVariant]: root => { - const rangeTiles = globalConfig.undergroundBeltMaxTilesByTier[0]; - - const beltSpeed = root.hubGoals.getUndergroundBeltBaseSpeed(); - return [ - [ - T.ingame.buildingPlacement.infoTexts.range, - T.ingame.buildingPlacement.infoTexts.tiles.replace("", "" + rangeTiles), - ], - [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)], - ]; - }, - - /** - * @param {*} root - * @returns {Array<[string, string]>} - */ - [MetaUndergroundBeltBuilding.variants.tier2]: root => { - const rangeTiles = globalConfig.undergroundBeltMaxTilesByTier[1]; - - const beltSpeed = root.hubGoals.getUndergroundBeltBaseSpeed(); - return [ - [ - T.ingame.buildingPlacement.infoTexts.range, - T.ingame.buildingPlacement.infoTexts.tiles.replace("", "" + rangeTiles), - ], - [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)], - ]; - }, - }; - - static componentVariationsByRotation = { - [enumUndergroundBeltMode.sender]: (entity, rotationVariant) => { - entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.sender; - entity.components.ItemEjector.setSlots([]); - entity.components.ItemAcceptor.setSlots([ - { - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, - ]); - }, - - [enumUndergroundBeltMode.receiver]: (entity, rotationVariant) => { - entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.receiver; - entity.components.ItemAcceptor.setSlots([]); - entity.components.ItemEjector.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - }, - ]); - }, - }; } + +MetaUndergroundBeltBuilding.setupEntityComponents = [ + // Required, since the item processor needs this. + entity => + entity.addComponent( + new ItemEjectorComponent({ + slots: [], + }) + ), + entity => entity.addComponent(new UndergroundBeltComponent({})), + entity => + entity.addComponent( + new ItemAcceptorComponent({ + slots: [], + }) + ), +]; + +MetaUndergroundBeltBuilding.rotationVariants = [0, 1]; + +MetaUndergroundBeltBuilding.variants = { + tier2: "tier2", +}; + +MetaUndergroundBeltBuilding.overlayMatricesByRotation = [ + // Sender + (entity, rotationVariant) => generateMatrixRotations([1, 1, 1, 0, 1, 0, 0, 1, 0]), + // Receiver + (entity, rotationVariant) => generateMatrixRotations([0, 1, 0, 0, 1, 0, 1, 1, 1]), +]; + +MetaUndergroundBeltBuilding.rotationVariantToMode = [ + enumUndergroundBeltMode.sender, + enumUndergroundBeltMode.receiver, +]; + +MetaUndergroundBeltBuilding.variantToTier = { + [defaultBuildingVariant]: 0, + [MetaUndergroundBeltBuilding.variants.tier2]: 1, +}; + +MetaUndergroundBeltBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaUndergroundBeltBuilding.variants.tier2]: () => new Vector(1, 1), +}; + +MetaUndergroundBeltBuilding.silhouetteColorsByRotation = [() => "#6d9dff", () => "#71ff9c"]; + +MetaUndergroundBeltBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaUndergroundBeltBuilding.variants.tier2]: () => true, +}; + +MetaUndergroundBeltBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaUndergroundBeltBuilding.variants.tier2]: () => true, +}; + +MetaUndergroundBeltBuilding.renderPins = { + [defaultBuildingVariant]: () => null, + [MetaUndergroundBeltBuilding.variants.tier2]: () => null, +}; + +MetaUndergroundBeltBuilding.layerPreview = { + [defaultBuildingVariant]: () => null, + [MetaUndergroundBeltBuilding.variants.tier2]: () => null, +}; + +MetaUndergroundBeltBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_tunnel), + [MetaUndergroundBeltBuilding.variants.tier2]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_underground_belt_tier_2), +}; + +MetaUndergroundBeltBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "regular", + [MetaUndergroundBeltBuilding.variants.tier2]: root => "regular", +}; + +MetaUndergroundBeltBuilding.additionalStatistics = { + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [defaultBuildingVariant]: root => { + const rangeTiles = globalConfig.undergroundBeltMaxTilesByTier[0]; + + const beltSpeed = root.hubGoals.getUndergroundBeltBaseSpeed(); + return [ + [ + T.ingame.buildingPlacement.infoTexts.range, + T.ingame.buildingPlacement.infoTexts.tiles.replace("", "" + rangeTiles), + ], + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)], + ]; + }, + + /** + * @param {*} root + * @returns {Array<[string, string]>} + */ + [MetaUndergroundBeltBuilding.variants.tier2]: root => { + const rangeTiles = globalConfig.undergroundBeltMaxTilesByTier[1]; + + const beltSpeed = root.hubGoals.getUndergroundBeltBaseSpeed(); + return [ + [ + T.ingame.buildingPlacement.infoTexts.range, + T.ingame.buildingPlacement.infoTexts.tiles.replace("", "" + rangeTiles), + ], + [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)], + ]; + }, +}; + +MetaUndergroundBeltBuilding.componentVariationsByRotation = { + [enumUndergroundBeltMode.sender]: (entity, rotationVariant) => { + entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.sender; + entity.components.ItemEjector.setSlots([]); + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); + }, + + [enumUndergroundBeltMode.receiver]: (entity, rotationVariant) => { + entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.receiver; + entity.components.ItemAcceptor.setSlots([]); + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ]); + }, +}; diff --git a/src/js/game/buildings/virtual_processor.js b/src/js/game/buildings/virtual_processor.js index 5bc6c72f..ba4f7e87 100644 --- a/src/js/game/buildings/virtual_processor.js +++ b/src/js/game/buildings/virtual_processor.js @@ -110,209 +110,209 @@ export class MetaVirtualProcessorBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaVirtualProcessorBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [ - entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [], - }) - ), - entity => entity.addComponent(new LogicGateComponent({})), - ]; - - static variants = { - rotater: "rotater", - unstacker: "unstacker", - stacker: "stacker", - painter: "painter", - }; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => null, - [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => null, - [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => null, - [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => null, - [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => null, - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - [MetaVirtualProcessorBuilding.variants.rotater]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - [MetaVirtualProcessorBuilding.variants.unstacker]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - [MetaVirtualProcessorBuilding.variants.stacker]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - [MetaVirtualProcessorBuilding.variants.painter]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaVirtualProcessorBuilding.variants.rotater]: () => new Vector(1, 1), - [MetaVirtualProcessorBuilding.variants.unstacker]: () => new Vector(1, 1), - [MetaVirtualProcessorBuilding.variants.stacker]: () => new Vector(1, 1), - [MetaVirtualProcessorBuilding.variants.painter]: () => new Vector(1, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaVirtualProcessorBuilding.variants.rotater]: () => true, - [MetaVirtualProcessorBuilding.variants.unstacker]: () => true, - [MetaVirtualProcessorBuilding.variants.stacker]: () => true, - [MetaVirtualProcessorBuilding.variants.painter]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaVirtualProcessorBuilding.variants.rotater]: () => true, - [MetaVirtualProcessorBuilding.variants.unstacker]: () => true, - [MetaVirtualProcessorBuilding.variants.stacker]: () => true, - [MetaVirtualProcessorBuilding.variants.painter]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - [MetaVirtualProcessorBuilding.variants.rotater]: () => false, - [MetaVirtualProcessorBuilding.variants.unstacker]: () => false, - [MetaVirtualProcessorBuilding.variants.stacker]: () => false, - [MetaVirtualProcessorBuilding.variants.painter]: () => false, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - [MetaVirtualProcessorBuilding.variants.rotater]: () => "wires", - [MetaVirtualProcessorBuilding.variants.unstacker]: () => "wires", - [MetaVirtualProcessorBuilding.variants.stacker]: () => "wires", - [MetaVirtualProcessorBuilding.variants.painter]: () => "wires", - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - [MetaVirtualProcessorBuilding.variants.rotater]: root => "wires", - [MetaVirtualProcessorBuilding.variants.unstacker]: root => "wires", - [MetaVirtualProcessorBuilding.variants.stacker]: root => "wires", - [MetaVirtualProcessorBuilding.variants.painter]: root => "wires", - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => MetaCutterBuilding.silhouetteColors[defaultBuildingVariant], - [MetaVirtualProcessorBuilding.variants.rotater]: () => - MetaRotaterBuilding.silhouetteColors[defaultBuildingVariant], - [MetaVirtualProcessorBuilding.variants.unstacker]: () => - MetaStackerBuilding.silhouetteColors[defaultBuildingVariant], - [MetaVirtualProcessorBuilding.variants.stacker]: () => - MetaStackerBuilding.silhouetteColors[defaultBuildingVariant], - [MetaVirtualProcessorBuilding.variants.painter]: () => - MetaPainterBuilding.silhouetteColors[defaultBuildingVariant], - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.cutter; - }, - - [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.rotater; - }, - - [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.unstacker; - }, - - [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.stacker; - }, - - [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([ - { - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, - { - pos: new Vector(0, 0), - direction: enumDirection.right, - type: enumPinSlotType.logicalAcceptor, - }, - ]); - - entity.components.LogicGate.type = enumLogicGateType.painter; - }, - }; } + +MetaVirtualProcessorBuilding.setupEntityComponents = [ + entity => + entity.addComponent( + new WiredPinsComponent({ + slots: [], + }) + ), + entity => entity.addComponent(new LogicGateComponent({})), +]; + +MetaVirtualProcessorBuilding.variants = { + rotater: "rotater", + unstacker: "unstacker", + stacker: "stacker", + painter: "painter", +}; + +MetaVirtualProcessorBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => null, + [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => null, + [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => null, + [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => null, + [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => null, +}; + +MetaVirtualProcessorBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), + [MetaVirtualProcessorBuilding.variants.rotater]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), + [MetaVirtualProcessorBuilding.variants.unstacker]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), + [MetaVirtualProcessorBuilding.variants.stacker]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), + [MetaVirtualProcessorBuilding.variants.painter]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_virtual_processing), +}; + +MetaVirtualProcessorBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaVirtualProcessorBuilding.variants.rotater]: () => new Vector(1, 1), + [MetaVirtualProcessorBuilding.variants.unstacker]: () => new Vector(1, 1), + [MetaVirtualProcessorBuilding.variants.stacker]: () => new Vector(1, 1), + [MetaVirtualProcessorBuilding.variants.painter]: () => new Vector(1, 1), +}; + +MetaVirtualProcessorBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaVirtualProcessorBuilding.variants.rotater]: () => true, + [MetaVirtualProcessorBuilding.variants.unstacker]: () => true, + [MetaVirtualProcessorBuilding.variants.stacker]: () => true, + [MetaVirtualProcessorBuilding.variants.painter]: () => true, +}; + +MetaVirtualProcessorBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaVirtualProcessorBuilding.variants.rotater]: () => true, + [MetaVirtualProcessorBuilding.variants.unstacker]: () => true, + [MetaVirtualProcessorBuilding.variants.stacker]: () => true, + [MetaVirtualProcessorBuilding.variants.painter]: () => true, +}; + +MetaVirtualProcessorBuilding.renderPins = { + [defaultBuildingVariant]: () => false, + [MetaVirtualProcessorBuilding.variants.rotater]: () => false, + [MetaVirtualProcessorBuilding.variants.unstacker]: () => false, + [MetaVirtualProcessorBuilding.variants.stacker]: () => false, + [MetaVirtualProcessorBuilding.variants.painter]: () => false, +}; + +MetaVirtualProcessorBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", + [MetaVirtualProcessorBuilding.variants.rotater]: () => "wires", + [MetaVirtualProcessorBuilding.variants.unstacker]: () => "wires", + [MetaVirtualProcessorBuilding.variants.stacker]: () => "wires", + [MetaVirtualProcessorBuilding.variants.painter]: () => "wires", +}; + +MetaVirtualProcessorBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", + [MetaVirtualProcessorBuilding.variants.rotater]: root => "wires", + [MetaVirtualProcessorBuilding.variants.unstacker]: root => "wires", + [MetaVirtualProcessorBuilding.variants.stacker]: root => "wires", + [MetaVirtualProcessorBuilding.variants.painter]: root => "wires", +}; + +MetaVirtualProcessorBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => MetaCutterBuilding.silhouetteColors[defaultBuildingVariant], + [MetaVirtualProcessorBuilding.variants.rotater]: () => + MetaRotaterBuilding.silhouetteColors[defaultBuildingVariant], + [MetaVirtualProcessorBuilding.variants.unstacker]: () => + MetaStackerBuilding.silhouetteColors[defaultBuildingVariant], + [MetaVirtualProcessorBuilding.variants.stacker]: () => + MetaStackerBuilding.silhouetteColors[defaultBuildingVariant], + [MetaVirtualProcessorBuilding.variants.painter]: () => + MetaPainterBuilding.silhouetteColors[defaultBuildingVariant], +}; + +MetaVirtualProcessorBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.cutter; + }, + + [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.rotater; + }, + + [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.left, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.unstacker; + }, + + [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.stacker; + }, + + [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => { + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + { + pos: new Vector(0, 0), + direction: enumDirection.right, + type: enumPinSlotType.logicalAcceptor, + }, + ]); + + entity.components.LogicGate.type = enumLogicGateType.painter; + }, +}; diff --git a/src/js/game/buildings/wire.js b/src/js/game/buildings/wire.js index c2341c7d..5240dde0 100644 --- a/src/js/game/buildings/wire.js +++ b/src/js/game/buildings/wire.js @@ -298,103 +298,99 @@ export class MetaWireBuilding extends MetaBuilding { rotationVariant: MetaWireBuilding.rotationVariantToType.indexOf(targetType), }; } - - static setupEntityComponents = [entity => entity.addComponent(new WireComponent({}))]; - - static variants = { - second: "second", - }; - static wireVariants = { - first: "first", - [MetaWireBuilding.variants.second]: "second", - }; - - static rotationVariants = [0, 1, 2, 3]; - - static placementSounds = { - [defaultBuildingVariant]: SOUNDS.placeBelt, - [MetaWireBuilding.variants.second]: SOUNDS.placeBelt, - }; - - static wireVariantToVariant = { - [defaultBuildingVariant]: "first", - [MetaWireBuilding.variants.second]: "second", - }; - - static rotationVariantToType = [ - enumWireType.forward, - enumWireType.turn, - enumWireType.split, - enumWireType.cross, - ]; - - static overlayMatrices = { - [enumWireType.forward]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), - [enumWireType.split]: (entity, rotationVariant) => - generateMatrixRotations([0, 0, 0, 1, 1, 1, 0, 1, 0]), - [enumWireType.turn]: (entity, rotationVariant) => - generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]), - [enumWireType.cross]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 0]), - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), - [MetaWireBuilding.variants.second]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - [MetaWireBuilding.variants.second]: () => new Vector(1, 1), - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - [MetaWireBuilding.variants.second]: () => true, - }; - - static isReplaceable = { - [defaultBuildingVariant]: () => true, - [MetaWireBuilding.variants.second]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => true, - [MetaWireBuilding.variants.second]: () => true, - }; - - static renderPins = { - [defaultBuildingVariant]: () => null, - [MetaWireBuilding.variants.second]: () => null, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - [MetaWireBuilding.variants.second]: () => "wires", - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - [MetaWireBuilding.variants.second]: root => "wires", - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#61ef6f", - [MetaWireBuilding.variants.second]: () => "#61ef6f", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.Wire.type = MetaWireBuilding.rotationVariantToType[rotationVariant]; - entity.components.Wire.variant = "first"; - }, - - [MetaWireBuilding.variants.second]: (entity, rotationVariant) => { - entity.components.Wire.type = MetaWireBuilding.rotationVariantToType[rotationVariant]; - entity.components.Wire.variant = "second"; - }, - }; } + +MetaWireBuilding.setupEntityComponents = [entity => entity.addComponent(new WireComponent({}))]; + +MetaWireBuilding.variants = { + second: "second", +}; +MetaWireBuilding.wireVariants = { + first: "first", + [MetaWireBuilding.variants.second]: "second", +}; + +MetaWireBuilding.rotationVariants = [0, 1, 2, 3]; + +MetaWireBuilding.placementSounds = { + [defaultBuildingVariant]: SOUNDS.placeBelt, + [MetaWireBuilding.variants.second]: SOUNDS.placeBelt, +}; + +MetaWireBuilding.wireVariantToVariant = { + [defaultBuildingVariant]: "first", + [MetaWireBuilding.variants.second]: "second", +}; + +MetaWireBuilding.rotationVariantToType = [ + enumWireType.forward, + enumWireType.turn, + enumWireType.split, + enumWireType.cross, +]; + +MetaWireBuilding.overlayMatrices = { + [enumWireType.forward]: (entity, rotationVariant) => generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]), + [enumWireType.split]: (entity, rotationVariant) => generateMatrixRotations([0, 0, 0, 1, 1, 1, 0, 1, 0]), + [enumWireType.turn]: (entity, rotationVariant) => generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]), + [enumWireType.cross]: (entity, rotationVariant) => generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 0]), +}; + +MetaWireBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), + [MetaWireBuilding.variants.second]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), +}; + +MetaWireBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), + [MetaWireBuilding.variants.second]: () => new Vector(1, 1), +}; + +MetaWireBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, + [MetaWireBuilding.variants.second]: () => true, +}; + +MetaWireBuilding.isReplaceable = { + [defaultBuildingVariant]: () => true, + [MetaWireBuilding.variants.second]: () => true, +}; + +MetaWireBuilding.isRotateable = { + [defaultBuildingVariant]: () => true, + [MetaWireBuilding.variants.second]: () => true, +}; + +MetaWireBuilding.renderPins = { + [defaultBuildingVariant]: () => null, + [MetaWireBuilding.variants.second]: () => null, +}; + +MetaWireBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", + [MetaWireBuilding.variants.second]: () => "wires", +}; + +MetaWireBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", + [MetaWireBuilding.variants.second]: root => "wires", +}; + +MetaWireBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#61ef6f", + [MetaWireBuilding.variants.second]: () => "#61ef6f", +}; + +MetaWireBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => { + entity.components.Wire.type = MetaWireBuilding.rotationVariantToType[rotationVariant]; + entity.components.Wire.variant = "first"; + }, + + [MetaWireBuilding.variants.second]: (entity, rotationVariant) => { + entity.components.Wire.type = MetaWireBuilding.rotationVariantToType[rotationVariant]; + entity.components.Wire.variant = "second"; + }, +}; diff --git a/src/js/game/buildings/wire_tunnel.js b/src/js/game/buildings/wire_tunnel.js index beb7d2cd..07db9979 100644 --- a/src/js/game/buildings/wire_tunnel.js +++ b/src/js/game/buildings/wire_tunnel.js @@ -106,48 +106,48 @@ export class MetaWireTunnelBuilding extends MetaBuilding { updateVariants(entity, rotationVariant, variant) { MetaWireTunnelBuilding.componentVariations[variant](entity, rotationVariant); } - - static setupEntityComponents = [entity => entity.addComponent(new WireTunnelComponent())]; - - static overlayMatrices = { - [defaultBuildingVariant]: (entity, rotationVariant) => - generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 0]), - }; - - static dimensions = { - [defaultBuildingVariant]: () => new Vector(1, 1), - }; - - static silhouetteColors = { - [defaultBuildingVariant]: () => "#777a86", - }; - - static isRemovable = { - [defaultBuildingVariant]: () => true, - }; - - static isRotateable = { - [defaultBuildingVariant]: () => false, - }; - - static renderPins = { - [defaultBuildingVariant]: () => false, - }; - - static layerPreview = { - [defaultBuildingVariant]: () => "wires", - }; - - static avaibleVariants = { - [defaultBuildingVariant]: root => - root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), - }; - - static layerByVariant = { - [defaultBuildingVariant]: root => "wires", - }; - - static componentVariations = { - [defaultBuildingVariant]: (entity, rotationVariant) => {}, - }; } + +MetaWireTunnelBuilding.setupEntityComponents = [entity => entity.addComponent(new WireTunnelComponent())]; + +MetaWireTunnelBuilding.overlayMatrices = { + [defaultBuildingVariant]: (entity, rotationVariant) => + generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 0]), +}; + +MetaWireTunnelBuilding.dimensions = { + [defaultBuildingVariant]: () => new Vector(1, 1), +}; + +MetaWireTunnelBuilding.silhouetteColors = { + [defaultBuildingVariant]: () => "#777a86", +}; + +MetaWireTunnelBuilding.isRemovable = { + [defaultBuildingVariant]: () => true, +}; + +MetaWireTunnelBuilding.isRotateable = { + [defaultBuildingVariant]: () => false, +}; + +MetaWireTunnelBuilding.renderPins = { + [defaultBuildingVariant]: () => false, +}; + +MetaWireTunnelBuilding.layerPreview = { + [defaultBuildingVariant]: () => "wires", +}; + +MetaWireTunnelBuilding.avaibleVariants = { + [defaultBuildingVariant]: root => + root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_painter_and_levers), +}; + +MetaWireTunnelBuilding.layerByVariant = { + [defaultBuildingVariant]: root => "wires", +}; + +MetaWireTunnelBuilding.componentVariations = { + [defaultBuildingVariant]: (entity, rotationVariant) => {}, +};