From ddb904432e0819359f97f9f8ec87bc516e12b8e4 Mon Sep 17 00:00:00 2001 From: Bagel03 <70449196+Bagel03@users.noreply.github.com> Date: Sat, 4 Mar 2023 11:39:02 -0500 Subject: [PATCH] Prettier --- src/js/core/stale_area_detector.js | 7 +- src/js/game/hud/parts/building_placer.js | 19 ++--- src/js/game/hud/parts/game_menu.js | 10 +-- .../game/hud/parts/puzzle_editor_settings.js | 5 +- src/js/game/shape_definition_manager.js | 73 ++++++++++--------- src/js/game/systems/belt.js | 18 ++--- src/js/game/systems/item_acceptor.js | 5 +- src/js/game/systems/wire.js | 18 ++--- src/js/mods/mod_signals.js | 10 ++- src/js/webworkers/tsconfig.json | 2 +- 10 files changed, 82 insertions(+), 85 deletions(-) diff --git a/src/js/core/stale_area_detector.js b/src/js/core/stale_area_detector.js index 631d0327..78c69e90 100644 --- a/src/js/core/stale_area_detector.js +++ b/src/js/core/stale_area_detector.js @@ -58,9 +58,10 @@ export class StaleAreaDetector { for (let i = 0; i < componentIds.length; ++i) { if (entity.components[componentIds[i]]) { // Entity is relevant, compute affected area - const area = entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections( - tilesAround - ); + const area = + entity.components.StaticMapEntity.getTileSpaceBounds().expandedInAllDirections( + tilesAround + ); this.invalidate(area); return; } diff --git a/src/js/game/hud/parts/building_placer.js b/src/js/game/hud/parts/building_placer.js index d2904720..e373d4f9 100644 --- a/src/js/game/hud/parts/building_placer.js +++ b/src/js/game/hud/parts/building_placer.js @@ -303,17 +303,14 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { const mouseTile = worldPos.toTileSpace(); // Compute best rotation variant - const { - rotation, - rotationVariant, - connectedEntities, - } = metaBuilding.computeOptimalDirectionAndRotationVariantAtTile({ - root: this.root, - tile: mouseTile, - rotation: this.currentBaseRotation, - variant: this.currentVariant.get(), - layer: metaBuilding.getLayer(), - }); + const { rotation, rotationVariant, connectedEntities } = + metaBuilding.computeOptimalDirectionAndRotationVariantAtTile({ + root: this.root, + tile: mouseTile, + rotation: this.currentBaseRotation, + variant: this.currentVariant.get(), + layer: metaBuilding.getLayer(), + }); // Check if there are connected entities if (connectedEntities) { diff --git a/src/js/game/hud/parts/game_menu.js b/src/js/game/hud/parts/game_menu.js index 2a172ab2..3e0fc33c 100644 --- a/src/js/game/hud/parts/game_menu.js +++ b/src/js/game/hud/parts/game_menu.js @@ -112,14 +112,8 @@ export class HUDGameMenu extends BaseHUDPart { // Check for notifications and badges for (let i = 0; i < this.badgesToUpdate.length; ++i) { - const { - badge, - button, - badgeElement, - lastRenderAmount, - notification, - condition, - } = this.badgesToUpdate[i]; + const { badge, button, badgeElement, lastRenderAmount, notification, condition } = + this.badgesToUpdate[i]; if (condition && !condition()) { // Do not show notifications for invisible buttons diff --git a/src/js/game/hud/parts/puzzle_editor_settings.js b/src/js/game/hud/parts/puzzle_editor_settings.js index bd738198..4a23f005 100644 --- a/src/js/game/hud/parts/puzzle_editor_settings.js +++ b/src/js/game/hud/parts/puzzle_editor_settings.js @@ -150,8 +150,9 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart { } for (const key in building.components) { - /** @type {import("../../../core/global_registries").Component} */ (building - .components[key]).copyAdditionalStateTo(result.components[key]); + /** @type {import("../../../core/global_registries").Component} */ ( + building.components[key] + ).copyAdditionalStateTo(result.components[key]); } } }); diff --git a/src/js/game/shape_definition_manager.js b/src/js/game/shape_definition_manager.js index 89203f1e..c6efadbc 100644 --- a/src/js/game/shape_definition_manager.js +++ b/src/js/game/shape_definition_manager.js @@ -99,10 +99,12 @@ export class ShapeDefinitionManager extends BasicSerializableObject { this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.cutShape, null); - return /** @type {[ShapeDefinition, ShapeDefinition]} */ (this.operationCache[key] = [ - this.registerOrReturnHandle(rightSide), - this.registerOrReturnHandle(leftSide), - ]); + return /** @type {[ShapeDefinition, ShapeDefinition]} */ ( + this.operationCache[key] = [ + this.registerOrReturnHandle(rightSide), + this.registerOrReturnHandle(leftSide), + ] + ); } /** @@ -113,18 +115,19 @@ export class ShapeDefinitionManager extends BasicSerializableObject { shapeActionCutQuad(definition) { const key = "cut-quad/" + definition.getHash(); if (this.operationCache[key]) { - return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (this - .operationCache[key]); + return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ ( + this.operationCache[key] + ); } - return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (this.operationCache[ - key - ] = [ - this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([0])), - this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([1])), - this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([2])), - this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([3])), - ]); + return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ ( + this.operationCache[key] = [ + this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([0])), + this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([1])), + this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([2])), + this.registerOrReturnHandle(definition.cloneFilteredByQuadrants([3])), + ] + ); } /** @@ -142,9 +145,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.rotateShape, null); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - rotated - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(rotated) + ); } /** @@ -160,9 +163,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { const rotated = definition.cloneRotateCCW(); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - rotated - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(rotated) + ); } /** @@ -178,9 +181,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { const rotated = definition.cloneRotate180(); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - rotated - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(rotated) + ); } /** @@ -198,9 +201,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.stackShape, null); const stacked = lowerDefinition.cloneAndStackWith(upperDefinition); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - stacked - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(stacked) + ); } /** @@ -218,9 +221,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.paintShape, null); const colorized = definition.cloneAndPaintWith(color); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - colorized - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(colorized) + ); } /** @@ -235,9 +238,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { return /** @type {ShapeDefinition} */ (this.operationCache[key]); } const colorized = definition.cloneAndPaintWith4Colors(colors); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( - colorized - )); + return /** @type {ShapeDefinition} */ ( + this.operationCache[key] = this.registerOrReturnHandle(colorized) + ); } /** @@ -261,9 +264,9 @@ export class ShapeDefinitionManager extends BasicSerializableObject { * @returns {ShapeDefinition} */ getDefinitionFromSimpleShapes(subShapes, color = enumColors.uncolored) { - const shapeLayer = /** @type {import("./shape_definition").ShapeLayer} */ (subShapes.map( - subShape => ({ subShape, color }) - )); + const shapeLayer = /** @type {import("./shape_definition").ShapeLayer} */ ( + subShapes.map(subShape => ({ subShape, color })) + ); return this.registerOrReturnHandle(new ShapeDefinition({ layers: [shapeLayer] })); } diff --git a/src/js/game/systems/belt.js b/src/js/game/systems/belt.js index 38ac9b0b..e3868bf0 100644 --- a/src/js/game/systems/belt.js +++ b/src/js/game/systems/belt.js @@ -151,16 +151,14 @@ export class BeltSystem extends GameSystem { continue; } - const { - rotation, - rotationVariant, - } = metaBelt.computeOptimalDirectionAndRotationVariantAtTile({ - root: this.root, - tile: new Vector(x, y), - rotation: targetStaticComp.originalRotation, - variant: defaultBuildingVariant, - layer: targetEntity.layer, - }); + const { rotation, rotationVariant } = + metaBelt.computeOptimalDirectionAndRotationVariantAtTile({ + root: this.root, + tile: new Vector(x, y), + rotation: targetStaticComp.originalRotation, + variant: defaultBuildingVariant, + layer: targetEntity.layer, + }); // Compute delta to see if anything changed const newDirection = arrayBeltVariantToRotation[rotationVariant]; diff --git a/src/js/game/systems/item_acceptor.js b/src/js/game/systems/item_acceptor.js index 780b4abd..2af26358 100644 --- a/src/js/game/systems/item_acceptor.js +++ b/src/js/game/systems/item_acceptor.js @@ -76,9 +76,8 @@ export class ItemAcceptorSystem extends GameSystemWithFilter { const staticComp = entity.components.StaticMapEntity; for (let animIndex = 0; animIndex < acceptorComp.itemConsumptionAnimations.length; ++animIndex) { - const { item, slotIndex, animProgress, direction } = acceptorComp.itemConsumptionAnimations[ - animIndex - ]; + const { item, slotIndex, animProgress, direction } = + acceptorComp.itemConsumptionAnimations[animIndex]; const slotData = acceptorComp.slots[slotIndex]; const realSlotPos = staticComp.localTileToWorld(slotData.pos); diff --git a/src/js/game/systems/wire.js b/src/js/game/systems/wire.js index 4a255866..3ecb7336 100644 --- a/src/js/game/systems/wire.js +++ b/src/js/game/systems/wire.js @@ -730,16 +730,14 @@ export class WireSystem extends GameSystem { const variant = targetStaticComp.getVariant(); - const { - rotation, - rotationVariant, - } = metaWire.computeOptimalDirectionAndRotationVariantAtTile({ - root: this.root, - tile: new Vector(x, y), - rotation: targetStaticComp.originalRotation, - variant, - layer: targetEntity.layer, - }); + const { rotation, rotationVariant } = + metaWire.computeOptimalDirectionAndRotationVariantAtTile({ + root: this.root, + tile: new Vector(x, y), + rotation: targetStaticComp.originalRotation, + variant, + layer: targetEntity.layer, + }); // Compute delta to see if anything changed const newType = arrayWireRotationVariantToType[rotationVariant]; diff --git a/src/js/mods/mod_signals.js b/src/js/mods/mod_signals.js index a534dd89..f5824190 100644 --- a/src/js/mods/mod_signals.js +++ b/src/js/mods/mod_signals.js @@ -28,6 +28,12 @@ export const MOD_SIGNALS = { stateEntered: /** @type {TypedSignal<[GameState]>} */ (new Signal()), - gameSerialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()), - gameDeserialized: /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ (new Signal()), + gameSerialized: + /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ ( + new Signal() + ), + gameDeserialized: + /** @type {TypedSignal<[GameRoot, import("../savegame/savegame_typedefs").SerializedGame]>} */ ( + new Signal() + ), }; diff --git a/src/js/webworkers/tsconfig.json b/src/js/webworkers/tsconfig.json index dce06856..3a428cfc 100644 --- a/src/js/webworkers/tsconfig.json +++ b/src/js/webworkers/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["ES2018","WebWorker"] + "lib": ["ES2018", "WebWorker"] }, "exclude": [], "extends": "../tsconfig",