From 8a2394eaf27792778352b68940b77235e923aa6e Mon Sep 17 00:00:00 2001 From: DJ1TJOO Date: Tue, 2 Mar 2021 14:40:19 +0100 Subject: [PATCH] Fixed wire --- src/js/game/buildings/wire.js | 140 ++++++++++++++++----------------- src/js/game/components/wire.js | 5 +- 2 files changed, 73 insertions(+), 72 deletions(-) diff --git a/src/js/game/buildings/wire.js b/src/js/game/buildings/wire.js index a858f150..c2341c7d 100644 --- a/src/js/game/buildings/wire.js +++ b/src/js/game/buildings/wire.js @@ -13,86 +13,86 @@ export class MetaWireBuilding extends MetaBuilding { super("wire"); } - // /** - // * @param {string} variant - // */ - // getSilhouetteColor(variant) { - // return MetaWireBuilding.silhouetteColors[variant](); - // } + /** + * @param {string} variant + */ + getSilhouetteColor(variant) { + return MetaWireBuilding.silhouetteColors[variant](); + } - // /** - // * @param {GameRoot} root - // */ - // getIsUnlocked(root) { - // return this.getAvailableVariants(root).length > 0; - // } + /** + * @param {GameRoot} root + */ + getIsUnlocked(root) { + return this.getAvailableVariants(root).length > 0; + } - // /** - // * @param {string} variant - // */ - // getIsRemovable(variant) { - // return MetaWireBuilding.isRemovable[variant](); - // } + /** + * @param {string} variant + */ + getIsRemovable(variant) { + return MetaWireBuilding.isRemovable[variant](); + } - // /** - // * @param {string} variant - // */ - // getIsRotateable(variant) { - // return MetaWireBuilding.isRotateable[variant](); - // } + /** + * @param {string} variant + */ + getIsRotateable(variant) { + return MetaWireBuilding.isRotateable[variant](); + } - // /** - // * @param {GameRoot} root - // */ - // getAvailableVariants(root) { - // const variants = MetaWireBuilding.avaibleVariants; + /** + * @param {GameRoot} root + */ + getAvailableVariants(root) { + const variants = MetaWireBuilding.avaibleVariants; - // let available = []; - // for (const variant in variants) { - // if (variants[variant](root)) available.push(variant); - // } + let available = []; + for (const variant in variants) { + if (variants[variant](root)) available.push(variant); + } - // return available; - // } + return available; + } - // /** - // * Returns the edit layer of the building - // * @param {GameRoot} root - // * @param {string} variant - // * @returns {Layer} - // */ - // getLayer(root, variant) { - // // @ts-ignore - // return MetaWireBuilding.layerByVariant[variant](root); - // } + /** + * Returns the edit layer of the building + * @param {GameRoot} root + * @param {string} variant + * @returns {Layer} + */ + getLayer(root, variant) { + // @ts-ignore + return MetaWireBuilding.layerByVariant[variant](root); + } - // /** - // * @param {string} variant - // */ - // getDimensions(variant) { - // return MetaWireBuilding.dimensions[variant](); - // } + /** + * @param {string} variant + */ + getDimensions(variant) { + return MetaWireBuilding.dimensions[variant](); + } - // /** - // * @param {string} variant - // */ - // getShowLayerPreview(variant) { - // return MetaWireBuilding.layerPreview[variant](); - // } + /** + * @param {string} variant + */ + getShowLayerPreview(variant) { + return MetaWireBuilding.layerPreview[variant](); + } - // /** - // * @param {number} rotation - // * @param {number} rotationVariant - // * @param {string} variant - // * @param {Entity} entity - // * @returns {Array|null} - // */ - // getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) { - // let matrices = MetaWireBuilding.overlayMatrices[ - // MetaWireBuilding.rotationVariantToType[rotationVariant] - // ](entity, rotationVariant); - // return matrices ? matrices[rotation] : null; - // } + /** + * @param {number} rotation + * @param {number} rotationVariant + * @param {string} variant + * @param {Entity} entity + * @returns {Array|null} + */ + getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) { + let matrices = MetaWireBuilding.overlayMatrices[ + MetaWireBuilding.rotationVariantToType[rotationVariant] + ](entity, rotationVariant); + return matrices ? matrices[rotation] : null; + } /** * @param {string} variant diff --git a/src/js/game/components/wire.js b/src/js/game/components/wire.js index ee60d733..931c5429 100644 --- a/src/js/game/components/wire.js +++ b/src/js/game/components/wire.js @@ -1,3 +1,4 @@ +import { MetaWireBuilding } from "../buildings/wire"; import { Component } from "../component"; /** @enum {string} */ @@ -16,7 +17,7 @@ export class WireComponent extends Component { /** * @param {object} param0 * @param {enumWireType=} param0.type - * @param {import("../buildings/wire").MetaWireBuilding.wireVariants=} param0.variant + * @param {MetaWireBuilding.wireVariants=} param0.variant */ // @ts-ignore constructor({ type = enumWireType.forward, variant = "first" /*MetaWireBuilding.wireVariants.first*/ }) { @@ -25,7 +26,7 @@ export class WireComponent extends Component { /** * The variant of the wire, different variants do not connect - * @type {import("../buildings/wire").MetaWireBuilding.wireVariants} + * @type {MetaWireBuilding.wireVariants} */ this.variant = variant;