diff --git a/res/logo.png b/res/logo.png index 02f3e540..75dd3a35 100644 Binary files a/res/logo.png and b/res/logo.png differ diff --git a/res/logo_orgiginal.png b/res/logo_orgiginal.png deleted file mode 100644 index 75dd3a35..00000000 Binary files a/res/logo_orgiginal.png and /dev/null differ diff --git a/src/css/dynamic_ui.scss b/src/css/dynamic_ui.scss index 9b7374fa..f5d81baf 100644 --- a/src/css/dynamic_ui.scss +++ b/src/css/dynamic_ui.scss @@ -1,6 +1,6 @@ // Removes the unit (px, %, etc) from a value @function strip-unit($number) { - @if type-of($number)=="number" and not unitless($number) { + @if type-of($number) == "number" and not unitless($number) { @return $number / ($number * 0 + 1); } @return $number; @@ -25,14 +25,14 @@ $impSuffix: "!important"; } $v1: D($v1); - @if $v2 !="" { + @if $v2 != "" { $v2: D($v2); } - @if $v3 !="" { + @if $v3 != "" { $v3: D($v3); } - @if $v4 !="" { + @if $v4 != "" { $v4: D($v4); } #{$propName}: #{$v1} #{$v2} #{$v3} #{$v4} #{$impSuffix}; -} \ No newline at end of file +} diff --git a/src/css/resources.scss b/src/css/resources.scss index 8b24db98..93f4092d 100644 --- a/src/css/resources.scss +++ b/src/css/resources.scss @@ -1,27 +1,6 @@ -$buildings: belt, -cutter, -miner, -mixer, -painter, -rotater, -balancer, -stacker, -trash, -underground_belt, -wire, -constant_signal, -logic_gate, -lever, -filter, -wire_tunnel, -display, -virtual_processor, -reader, -storage, -transistor, -analyzer, -comparator, -item_producer; +$buildings: belt, cutter, miner, mixer, painter, rotater, balancer, stacker, trash, underground_belt, wire, + constant_signal, logic_gate, lever, filter, wire_tunnel, display, virtual_processor, reader, storage, + transistor, analyzer, comparator, item_producer; @each $building in $buildings { [data-icon="building_icons/#{$building}.png"] { /* @load-async */ @@ -29,41 +8,11 @@ item_producer; } } -$buildingsAndVariants: belt, -balancer, -underground_belt, -underground_belt-tier2, -miner, -miner-chainable, -cutter, -cutter-quad, -rotater, -rotater-ccw, -stacker, -mixer, -painter-double, -painter-quad, -trash, -storage, -reader, -rotater-rotate180, -display, -constant_signal, -wire, -wire_tunnel, -logic_gate-or, -logic_gate-not, -logic_gate-xor, -analyzer, -virtual_processor-rotater, -virtual_processor-unstacker, -item_producer, -virtual_processor-stacker, -virtual_processor-painter, -wire-second, -painter, -painter-mirrored, -comparator; +$buildingsAndVariants: belt, balancer, underground_belt, underground_belt-tier2, miner, miner-chainable, + cutter, cutter-quad, rotater, rotater-ccw, stacker, mixer, painter-double, painter-quad, trash, storage, + reader, rotater-rotate180, display, constant_signal, wire, wire_tunnel, logic_gate-or, logic_gate-not, + logic_gate-xor, analyzer, virtual_processor-rotater, virtual_processor-unstacker, item_producer, + virtual_processor-stacker, virtual_processor-painter, wire-second, painter, painter-mirrored, comparator; @each $building in $buildingsAndVariants { [data-icon="building_tutorials/#{$building}.png"] { /* @load-async */ @@ -108,9 +57,7 @@ comparator; background-image: uiResource("res/ui/building_tutorials/virtual_processor-cutter.png") !important; } -$icons: notification_saved, -notification_success, -notification_upgrade; +$icons: notification_saved, notification_success, notification_upgrade; @each $icon in $icons { [data-icon="icons/#{$icon}.png"] { /* @load-async */ @@ -118,34 +65,8 @@ notification_upgrade; } } -$languages: en, -de, -cs, -da, -et, -es-419, -fr, -it, -pt-BR, -sv, -tr, -el, -ru, -uk, -zh-TW, -zh-CN, -nb, -mt-MT, -ar, -nl, -vi, -th, -hu, -pl, -ja, -kor, -no, -pt-PT; +$languages: en, de, cs, da, et, es-419, fr, it, pt-BR, sv, tr, el, ru, uk, zh-TW, zh-CN, nb, mt-MT, ar, nl, vi, + th, hu, pl, ja, kor, no, pt-PT; @each $language in $languages { [data-languageicon="#{$language}"] { /* @load-async */ @@ -153,7 +74,6 @@ pt-PT; } } - /* PRICE */ @@ -166,4 +86,4 @@ PRICE .steam_2_npr { /* @load-async */ background-image: uiResource("get_on_steam.png") !important; -} \ No newline at end of file +} diff --git a/src/css/states/main_menu.scss b/src/css/states/main_menu.scss index 821e6587..929025b9 100644 --- a/src/css/states/main_menu.scss +++ b/src/css/states/main_menu.scss @@ -277,7 +277,7 @@ grid-row: 2 / 3; @include SuperSmallText; opacity: 0.5; - >span { + > span { display: inline-flex; @include S(max-width, 140px); overflow: hidden; @@ -290,7 +290,7 @@ @include PlainText; display: inline-flex; align-items: center; - >span { + > span { display: inline-flex; @include S(max-width, 140px); overflow: hidden; @@ -429,7 +429,7 @@ $linkBg: #fdfdff; $linkBgHover: darken($linkBg, 2); $linkColor: #55586a; - >.boxLink { + > .boxLink { display: grid; align-items: center; grid-template-columns: 1fr auto; @@ -470,14 +470,14 @@ } } } - >.sidelinks { + > .sidelinks { display: grid; align-items: flex-start; justify-content: flex-start; grid-template-rows: 1fr 1fr 1fr; @include S(grid-gap, 3px); @include S(height, 60px); - >a { + > a { color: $linkColor; background: $linkBg; height: 100%; @@ -524,8 +524,8 @@ } } .footer { - >a, - .sidelinks>a { + > a, + .sidelinks > a { background-color: $darkModeControlsBackground; color: #eee; &:hover { @@ -534,7 +534,7 @@ } .author { color: #bdbdbd; - >a { + > a { color: white; } } @@ -543,4 +543,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/html/index.html b/src/html/index.html index 03b08899..b1d89377 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -1,36 +1,46 @@ + + shapez.io - Build automated factories to build, combine and color shapes! - - shapez.io - Build automated factories to build, combine and color shapes! + + + + + + + - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + - - - - - - - - - - \ No newline at end of file + + diff --git a/src/js/application.js b/src/js/application.js index eb3e4c7d..cc2a0716 100644 --- a/src/js/application.js +++ b/src/js/application.js @@ -411,4 +411,4 @@ Application.states = { KeybindingsState, AboutState, ChangelogState, -}; \ No newline at end of file +}; diff --git a/src/js/changelog.js b/src/js/changelog.js index 1b194f8e..60e3861e 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -1,7 +1,8 @@ /** * @type {Array<{version: string, date: string, entries: Array}>} changelog */ -export const CHANGELOG = [{ +export const CHANGELOG = [ + { version: "1.2.3", date: "unreleased", entries: [ @@ -314,4 +315,4 @@ export const CHANGELOG = [{ date: "21.05.2020", entries: ["Initial release!"], }, -]; \ No newline at end of file +]; diff --git a/src/js/core/animation_frame.js b/src/js/core/animation_frame.js index 52fd42f2..edda0412 100644 --- a/src/js/core/animation_frame.js +++ b/src/js/core/animation_frame.js @@ -77,4 +77,4 @@ export class AnimationFrame { window.requestAnimationFrame(this.boundMethod); } -} \ No newline at end of file +} diff --git a/src/js/core/assert.js b/src/js/core/assert.js index 059c0061..1d80d2aa 100644 --- a/src/js/core/assert.js +++ b/src/js/core/assert.js @@ -20,7 +20,7 @@ function initAssert() { * @param {Boolean} condition * @param {...String} failureMessage */ - window.assert = function(condition, ...failureMessage) { + window.assert = function (condition, ...failureMessage) { if (!condition) { logger.error("assertion failed:", ...failureMessage); if (!assertionErrorShown) { @@ -32,4 +32,4 @@ function initAssert() { }; } -initAssert(); \ No newline at end of file +initAssert(); diff --git a/src/js/core/async_compression.js b/src/js/core/async_compression.js index 1aa5cb8d..1ad5af0f 100644 --- a/src/js/core/async_compression.js +++ b/src/js/core/async_compression.js @@ -118,4 +118,4 @@ class AsynCompression { } } -export const asyncCompressor = new AsynCompression(); \ No newline at end of file +export const asyncCompressor = new AsynCompression(); diff --git a/src/js/core/atlas_definitions.js b/src/js/core/atlas_definitions.js index eda778c1..38d36b59 100644 --- a/src/js/core/atlas_definitions.js +++ b/src/js/core/atlas_definitions.js @@ -47,4 +47,4 @@ export const atlasFiles = require .keys() .map(f => f.replace(/^\.\//gi, "")) .map(f => require("../../../res_built/atlas/" + f)) - .map(data => new AtlasDefinition(data)); \ No newline at end of file + .map(data => new AtlasDefinition(data)); diff --git a/src/js/core/background_resources_loader.js b/src/js/core/background_resources_loader.js index 43fb74a5..bbd37036 100644 --- a/src/js/core/background_resources_loader.js +++ b/src/js/core/background_resources_loader.js @@ -107,10 +107,10 @@ export class BackgroundResourcesLoader { internalStartLoadingEssentialsForBareGame() { logger.log("⏰ Start load: bare game"); this.internalLoadSpritesAndSounds( - essentialBareGameSprites, - essentialBareGameSounds, - essentialBareGameAtlases - ) + essentialBareGameSprites, + essentialBareGameSounds, + essentialBareGameAtlases + ) .then(() => this.internalPreloadCss("async-resources.scss")) .catch(err => { logger.warn("⏰ Failed to load essentials for bare game:", err); @@ -174,13 +174,13 @@ export class BackgroundResourcesLoader { this.soundsLoaded.push(sounds[i]); promises.push( this.app.sound - .loadSound(sounds[i]) - .catch(err => { - logger.warn("Failed to load sound:", sounds[i]); - }) - .then(() => { - this.numAssetsLoaded++; - }) + .loadSound(sounds[i]) + .catch(err => { + logger.warn("Failed to load sound:", sounds[i]); + }) + .then(() => { + this.numAssetsLoaded++; + }) ); } @@ -192,12 +192,12 @@ export class BackgroundResourcesLoader { this.spritesLoaded.push(sprites[i]); promises.push( Loader.preloadCSSSprite(sprites[i]) - .catch(err => { - logger.warn("Failed to load css sprite:", sprites[i]); - }) - .then(() => { - this.numAssetsLoaded++; - }) + .catch(err => { + logger.warn("Failed to load css sprite:", sprites[i]); + }) + .then(() => { + this.numAssetsLoaded++; + }) ); } @@ -205,28 +205,28 @@ export class BackgroundResourcesLoader { const atlas = atlases[i]; promises.push( Loader.preloadAtlas(atlas) - .catch(err => { - logger.warn("Failed to load atlas:", atlas.sourceFileName); - }) - .then(() => { - this.numAssetsLoaded++; - }) + .catch(err => { + logger.warn("Failed to load atlas:", atlas.sourceFileName); + }) + .then(() => { + this.numAssetsLoaded++; + }) ); } return ( Promise.all(promises) - // // Remove some pressure by waiting a bit - // .then(() => { - // return new Promise(resolve => { - // setTimeout(resolve, 200); - // }); - // }) - .then(() => { - this.numAssetsToLoadTotal = 0; - this.numAssetsLoaded = 0; - }) + // // Remove some pressure by waiting a bit + // .then(() => { + // return new Promise(resolve => { + // setTimeout(resolve, 200); + // }); + // }) + .then(() => { + this.numAssetsToLoadTotal = 0; + this.numAssetsLoaded = 0; + }) ); } -} \ No newline at end of file +} diff --git a/src/js/core/buffer_maintainer.js b/src/js/core/buffer_maintainer.js index 237d5d3e..065ec05a 100644 --- a/src/js/core/buffer_maintainer.js +++ b/src/js/core/buffer_maintainer.js @@ -168,4 +168,4 @@ export class BufferMaintainer { }); return canvas; } -} \ No newline at end of file +} diff --git a/src/js/core/draw_parameters.js b/src/js/core/draw_parameters.js index a639a5a2..a6e0b807 100644 --- a/src/js/core/draw_parameters.js +++ b/src/js/core/draw_parameters.js @@ -17,4 +17,4 @@ export class DrawParameters { /** @type {import("../game/root").GameRoot} */ this.root = root; } -} \ No newline at end of file +} diff --git a/src/js/core/draw_utils.js b/src/js/core/draw_utils.js index 13a486f5..01361544 100644 --- a/src/js/core/draw_utils.js +++ b/src/js/core/draw_utils.js @@ -5,7 +5,7 @@ import { Rectangle } from "./rectangle"; const logger = createLogger("draw_utils"); export function initDrawUtils() { - CanvasRenderingContext2D.prototype.beginRoundedRect = function(x, y, w, h, r) { + CanvasRenderingContext2D.prototype.beginRoundedRect = function (x, y, w, h, r) { this.beginPath(); if (r < 0.05) { @@ -28,7 +28,7 @@ export function initDrawUtils() { this.arcTo(x, y, x + w, y, r); }; - CanvasRenderingContext2D.prototype.beginCircle = function(x, y, r) { + CanvasRenderingContext2D.prototype.beginCircle = function (x, y, r) { this.beginPath(); if (r < 0.05) { @@ -113,4 +113,4 @@ export function drawSpriteClipped({ parameters, sprite, x, y, w, h, originalW, o intersection.w, intersection.h ); -} \ No newline at end of file +} diff --git a/src/js/core/global_registries.js b/src/js/core/global_registries.js index 5f10d016..637780df 100644 --- a/src/js/core/global_registries.js +++ b/src/js/core/global_registries.js @@ -29,4 +29,4 @@ export let gItemRegistry = new Factory("item"); */ export function initBuildingsByCategory(buildings) { gBuildingsByCategory = buildings; -} \ No newline at end of file +} diff --git a/src/js/core/input_distributor.js b/src/js/core/input_distributor.js index c02882ce..c3b3efd8 100644 --- a/src/js/core/input_distributor.js +++ b/src/js/core/input_distributor.js @@ -240,4 +240,4 @@ export class InputDistributor { alt: event.altKey, }); } -} \ No newline at end of file +} diff --git a/src/js/core/loader.js b/src/js/core/loader.js index aa087541..26d16624 100644 --- a/src/js/core/loader.js +++ b/src/js/core/loader.js @@ -222,4 +222,4 @@ class LoaderImpl { } } -export const Loader = new LoaderImpl(); \ No newline at end of file +export const Loader = new LoaderImpl(); diff --git a/src/js/core/read_write_proxy.js b/src/js/core/read_write_proxy.js index e9a231d2..1023522c 100644 --- a/src/js/core/read_write_proxy.js +++ b/src/js/core/read_write_proxy.js @@ -111,9 +111,9 @@ export class ReadWriteProxy { const checksum = decompressed.substring(0, 40); const jsonString = decompressed.substr(40); - const desiredChecksum = checksum.startsWith(CRC_PREFIX) ? - computeCrc(jsonString + salt) : - sha1(jsonString + salt); + const desiredChecksum = checksum.startsWith(CRC_PREFIX) + ? computeCrc(jsonString + salt) + : sha1(jsonString + salt); if (desiredChecksum !== checksum) { // Checksum mismatch @@ -165,141 +165,141 @@ export class ReadWriteProxy { // Start read request return ( this.app.storage - .readFileAsync(this.filename) + .readFileAsync(this.filename) - // Check for errors during read - .catch(err => { - if (err === FILE_NOT_FOUND) { - logger.log("File not found, using default data"); + // Check for errors during read + .catch(err => { + if (err === FILE_NOT_FOUND) { + logger.log("File not found, using default data"); - // File not found or unreadable, assume default file - return Promise.resolve(null); - } - - return Promise.reject("file-error: " + err); - }) - - // Decrypt data (if its encrypted) - // @ts-ignore - .then(rawData => { - if (rawData == null) { - // So, the file has not been found, use default data - return JSON.stringify(compressObject(this.getDefaultData())); - } - - if (rawData.startsWith(compressionPrefix)) { - const decompressed = decompressX64(rawData.substr(compressionPrefix.length)); - if (!decompressed) { - // LZ string decompression failure - return Promise.reject("bad-content / decompression-failed"); - } - if (decompressed.length < 40) { - // String too short - return Promise.reject("bad-content / payload-too-small"); + // File not found or unreadable, assume default file + return Promise.resolve(null); } - // Compare stored checksum with actual checksum - const checksum = decompressed.substring(0, 40); - const jsonString = decompressed.substr(40); + return Promise.reject("file-error: " + err); + }) - const desiredChecksum = checksum.startsWith(CRC_PREFIX) ? - computeCrc(jsonString + salt) : - sha1(jsonString + salt); + // Decrypt data (if its encrypted) + // @ts-ignore + .then(rawData => { + if (rawData == null) { + // So, the file has not been found, use default data + return JSON.stringify(compressObject(this.getDefaultData())); + } - if (desiredChecksum !== checksum) { - // Checksum mismatch - return Promise.reject( - "bad-content / checksum-mismatch: " + desiredChecksum + " vs " + checksum + if (rawData.startsWith(compressionPrefix)) { + const decompressed = decompressX64(rawData.substr(compressionPrefix.length)); + if (!decompressed) { + // LZ string decompression failure + return Promise.reject("bad-content / decompression-failed"); + } + if (decompressed.length < 40) { + // String too short + return Promise.reject("bad-content / payload-too-small"); + } + + // Compare stored checksum with actual checksum + const checksum = decompressed.substring(0, 40); + const jsonString = decompressed.substr(40); + + const desiredChecksum = checksum.startsWith(CRC_PREFIX) + ? computeCrc(jsonString + salt) + : sha1(jsonString + salt); + + if (desiredChecksum !== checksum) { + // Checksum mismatch + return Promise.reject( + "bad-content / checksum-mismatch: " + desiredChecksum + " vs " + checksum + ); + } + return jsonString; + } else { + if (!G_IS_DEV) { + return Promise.reject("bad-content / missing-compression"); + } + } + return rawData; + }) + + // Parse JSON, this could throw but that's fine + .then(res => { + try { + return JSON.parse(res); + } catch (ex) { + logger.error( + "Failed to parse file content of", + this.filename, + ":", + ex, + "(content was:", + res, + ")" ); + throw new Error("invalid-serialized-data"); } - return jsonString; - } else { - if (!G_IS_DEV) { - return Promise.reject("bad-content / missing-compression"); + }) + + // Decompress + .then(compressed => decompressObject(compressed)) + + // Verify basic structure + .then(contents => { + const result = this.internalVerifyBasicStructure(contents); + if (!result.isGood()) { + return Promise.reject("verify-failed: " + result.reason); } - } - return rawData; - }) + return contents; + }) - // Parse JSON, this could throw but that's fine - .then(res => { - try { - return JSON.parse(res); - } catch (ex) { - logger.error( - "Failed to parse file content of", - this.filename, - ":", - ex, - "(content was:", - res, - ")" - ); - throw new Error("invalid-serialized-data"); - } - }) - - // Decompress - .then(compressed => decompressObject(compressed)) - - // Verify basic structure - .then(contents => { - const result = this.internalVerifyBasicStructure(contents); - if (!result.isGood()) { - return Promise.reject("verify-failed: " + result.reason); - } - return contents; - }) - - // Check version and migrate if required - .then(contents => { - if (contents.version > this.getCurrentVersion()) { - return Promise.reject("stored-data-is-newer"); - } - - if (contents.version < this.getCurrentVersion()) { - logger.log( - "Trying to migrate data object from version", - contents.version, - "to", - this.getCurrentVersion() - ); - const migrationResult = this.migrate(contents); // modify in place - if (migrationResult.isBad()) { - return Promise.reject("migration-failed: " + migrationResult.reason); + // Check version and migrate if required + .then(contents => { + if (contents.version > this.getCurrentVersion()) { + return Promise.reject("stored-data-is-newer"); } - } - return contents; - }) - // Verify - .then(contents => { - const verifyResult = this.internalVerifyEntry(contents); - if (!verifyResult.result) { - logger.error( - "Read invalid data from", - this.filename, - "reason:", - verifyResult.reason, - "contents:", - contents - ); - return Promise.reject("invalid-data: " + verifyResult.reason); - } - return contents; - }) + if (contents.version < this.getCurrentVersion()) { + logger.log( + "Trying to migrate data object from version", + contents.version, + "to", + this.getCurrentVersion() + ); + const migrationResult = this.migrate(contents); // modify in place + if (migrationResult.isBad()) { + return Promise.reject("migration-failed: " + migrationResult.reason); + } + } + return contents; + }) - // Store - .then(contents => { - this.currentData = contents; - logger.log("📄 Read data with version", this.currentData.version, "from", this.filename); - return contents; - }) + // Verify + .then(contents => { + const verifyResult = this.internalVerifyEntry(contents); + if (!verifyResult.result) { + logger.error( + "Read invalid data from", + this.filename, + "reason:", + verifyResult.reason, + "contents:", + contents + ); + return Promise.reject("invalid-data: " + verifyResult.reason); + } + return contents; + }) - // Catchall - .catch(err => { - return Promise.reject("Failed to read " + this.filename + ": " + err); - }) + // Store + .then(contents => { + this.currentData = contents; + logger.log("📄 Read data with version", this.currentData.version, "from", this.filename); + return contents; + }) + + // Catchall + .catch(err => { + return Promise.reject("Failed to read " + this.filename + ": " + err); + }) ); } @@ -341,4 +341,4 @@ export class ReadWriteProxy { } return this.verify(data); } -} \ No newline at end of file +} diff --git a/src/js/core/singleton_factory.js b/src/js/core/singleton_factory.js index 231f55dc..7fa38bd3 100644 --- a/src/js/core/singleton_factory.js +++ b/src/js/core/singleton_factory.js @@ -94,4 +94,4 @@ export class SingletonFactory { getNumEntries() { return this.entries.length; } -} \ No newline at end of file +} diff --git a/src/js/core/state_manager.js b/src/js/core/state_manager.js index 0b9cba78..3c49ada9 100644 --- a/src/js/core/state_manager.js +++ b/src/js/core/state_manager.js @@ -97,7 +97,8 @@ export class StateManager { this.app.analytics.trackStateEnter(key); - window.history.pushState({ + window.history.pushState( + { key, }, key @@ -117,4 +118,4 @@ export class StateManager { getCurrentState() { return this.currentState; } -} \ No newline at end of file +} diff --git a/src/js/core/textual_game_state.js b/src/js/core/textual_game_state.js index 4cd19cca..80dc7a01 100644 --- a/src/js/core/textual_game_state.js +++ b/src/js/core/textual_game_state.js @@ -153,4 +153,4 @@ export class TextualGameState extends GameState { this.onEnter(payload); } -} \ No newline at end of file +} diff --git a/src/js/core/utils.js b/src/js/core/utils.js index 80dfdc28..6eed9c34 100644 --- a/src/js/core/utils.js +++ b/src/js/core/utils.js @@ -334,9 +334,9 @@ export function formatBigNumberFull(num, divider = T.global.thousandsDivider) { * @returns {Promise} */ export function waitNextFrame() { - return new Promise(function(resolve) { - window.requestAnimationFrame(function() { - window.requestAnimationFrame(function() { + return new Promise(function (resolve) { + window.requestAnimationFrame(function () { + window.requestAnimationFrame(function () { resolve(); }); }); @@ -573,12 +573,12 @@ export function round1DigitLocalized(speed, separator = T.global.decimalSeparato * @param {string=} separator The decimal separator for numbers like 50.1 (separator='.') */ export function formatItemsPerSecond(speed, double = false, separator = T.global.decimalSeparator) { - return speed === 1.0 ? - T.ingame.buildingPlacement.infoTexts.oneItemPerSecond : - T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace( - "", - round2Digits(speed).toString().replace(".", separator) - ) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); + return speed === 1.0 + ? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond + : T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace( + "", + round2Digits(speed).toString().replace(".", separator) + ) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); } /** @@ -781,4 +781,4 @@ export function getRomanNumber(number) { romanLiteralsCache[number] = formatted; return formatted; -} \ No newline at end of file +} diff --git a/src/js/game/base_item.js b/src/js/game/base_item.js index 97af2d6b..0ef6bd9a 100644 --- a/src/js/game/base_item.js +++ b/src/js/game/base_item.js @@ -100,4 +100,4 @@ export class BaseItem extends BasicSerializableObject { abstract; return ""; } -} \ No newline at end of file +} diff --git a/src/js/game/blueprint.js b/src/js/game/blueprint.js index bf614755..9620393e 100644 --- a/src/js/game/blueprint.js +++ b/src/js/game/blueprint.js @@ -165,4 +165,4 @@ export class Blueprint { return anyPlaced; }); } -} \ No newline at end of file +} diff --git a/src/js/game/building_codes.js b/src/js/game/building_codes.js index e94efbe6..952fd3b8 100644 --- a/src/js/game/building_codes.js +++ b/src/js/game/building_codes.js @@ -33,7 +33,7 @@ export const gBuildingVariants = { */ export function registerBuildingVariant( meta, - variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */ , + variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */, rotationVariant = 0 ) { // @ts-ignore @@ -67,4 +67,4 @@ export function getBuildingDataFromCode(code) { */ export function getCodeFromBuildingData(metaBuilding, variant, rotationVariant = 0) { return metaBuilding.getId() + "/" + variant + "/" + rotationVariant; -} \ No newline at end of file +} diff --git a/src/js/game/buildings/analyzer.js b/src/js/game/buildings/analyzer.js index 5a409c01..d9d8babb 100644 --- a/src/js/game/buildings/analyzer.js +++ b/src/js/game/buildings/analyzer.js @@ -117,33 +117,34 @@ export class MetaAnalyzerBuilding extends MetaBuilding { 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.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, - }) - ), + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.analyzer, + }) + ), ]; MetaAnalyzerBuilding.silhouetteColors = { @@ -186,7 +187,8 @@ MetaAnalyzerBuilding.layerPreview = { MetaAnalyzerBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.left, type: enumPinSlotType.logicalEjector, @@ -205,4 +207,4 @@ MetaAnalyzerBuilding.componentVariations = { entity.components.LogicGate.type = enumLogicGateType.analyzer; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/balancer.js b/src/js/game/buildings/balancer.js index 4fbb3dfe..243f09fe 100644 --- a/src/js/game/buildings/balancer.js +++ b/src/js/game/buildings/balancer.js @@ -130,27 +130,27 @@ export class MetaBalancerBuilding extends MetaBuilding { MetaBalancerBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [], // set later - }) - ), + entity.addComponent( + new ItemAcceptorComponent({ + slots: [], // set later + }) + ), entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.balancer, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.balancer, + }) + ), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [], // set later - renderFloatingItems: false, - }) - ), + entity.addComponent( + new ItemEjectorComponent({ + slots: [], // set later + renderFloatingItems: false, + }) + ), entity => entity.addComponent(new BeltUnderlaysComponent({ underlays: [] })), ]; @@ -297,7 +297,8 @@ MetaBalancerBuilding.silhouetteColors = { MetaBalancerBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.bottom], }, @@ -319,7 +320,8 @@ MetaBalancerBuilding.componentVariations = { }, [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.bottom], }, @@ -335,7 +337,8 @@ MetaBalancerBuilding.componentVariations = { }, [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.bottom], }, @@ -352,12 +355,15 @@ MetaBalancerBuilding.componentVariations = { [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => { { - entity.components.ItemAcceptor.setSlots([{ - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, ]); + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); - entity.components.ItemEjector.setSlots([{ + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, }, @@ -375,12 +381,15 @@ MetaBalancerBuilding.componentVariations = { [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => { { - entity.components.ItemAcceptor.setSlots([{ - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, ]); + entity.components.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); - entity.components.ItemEjector.setSlots([{ + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, }, @@ -395,4 +404,4 @@ MetaBalancerBuilding.componentVariations = { ]; } }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/belt.js b/src/js/game/buildings/belt.js index 063e5e4b..93cfa296 100644 --- a/src/js/game/buildings/belt.js +++ b/src/js/game/buildings/belt.js @@ -138,43 +138,35 @@ export class MetaBeltBuilding extends MetaBuilding { getPreviewSprite(rotationVariant) { switch (MetaBeltBuilding.variantToRotation[rotationVariant]) { - case enumDirection.top: - { - return Loader.getSprite("sprites/buildings/belt_top.png"); - } - case enumDirection.left: - { - return Loader.getSprite("sprites/buildings/belt_left.png"); - } - case enumDirection.right: - { - return Loader.getSprite("sprites/buildings/belt_right.png"); - } - default: - { - assertAlways(false, "Invalid belt rotation variant"); - } + case enumDirection.top: { + return Loader.getSprite("sprites/buildings/belt_top.png"); + } + case enumDirection.left: { + return Loader.getSprite("sprites/buildings/belt_left.png"); + } + case enumDirection.right: { + return Loader.getSprite("sprites/buildings/belt_right.png"); + } + default: { + assertAlways(false, "Invalid belt rotation variant"); + } } } getBlueprintSprite(rotationVariant) { switch (MetaBeltBuilding.variantToRotation[rotationVariant]) { - case enumDirection.top: - { - return Loader.getSprite("sprites/blueprints/belt_top.png"); - } - case enumDirection.left: - { - return Loader.getSprite("sprites/blueprints/belt_left.png"); - } - case enumDirection.right: - { - return Loader.getSprite("sprites/blueprints/belt_right.png"); - } - default: - { - assertAlways(false, "Invalid belt rotation variant"); - } + case enumDirection.top: { + return Loader.getSprite("sprites/blueprints/belt_top.png"); + } + case enumDirection.left: { + return Loader.getSprite("sprites/blueprints/belt_left.png"); + } + case enumDirection.right: { + return Loader.getSprite("sprites/blueprints/belt_right.png"); + } + default: { + assertAlways(false, "Invalid belt rotation variant"); + } } } @@ -300,11 +292,11 @@ export class MetaBeltBuilding extends MetaBuilding { MetaBeltBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new BeltComponent({ - direction: enumDirection.top, // updated later - }) - ), + entity.addComponent( + new BeltComponent({ + direction: enumDirection.top, // updated later + }) + ), ]; MetaBeltBuilding.silhouetteColors = { @@ -371,4 +363,4 @@ MetaBeltBuilding.additionalStatistics = { [defaultBuildingVariant]: root => [ [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())], ], -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/comparator.js b/src/js/game/buildings/comparator.js index 8bbcb568..0090db1c 100644 --- a/src/js/game/buildings/comparator.js +++ b/src/js/game/buildings/comparator.js @@ -118,32 +118,33 @@ export class MetaComparatorBuilding extends MetaBuilding { 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.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, - }) - ), + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.compare, + }) + ), ]; MetaComparatorBuilding.overlayMatrices = { @@ -185,7 +186,8 @@ MetaComparatorBuilding.layerByVariant = { MetaComparatorBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -204,4 +206,4 @@ MetaComparatorBuilding.componentVariations = { entity.components.LogicGate.type = enumLogicGateType.compare; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/constant_signal.js b/src/js/game/buildings/constant_signal.js index 32c2ea88..3200a847 100644 --- a/src/js/game/buildings/constant_signal.js +++ b/src/js/game/buildings/constant_signal.js @@ -118,15 +118,17 @@ export class MetaConstantSignalBuilding extends MetaBuilding { MetaConstantSignalBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [{ - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, ], - }) - ), + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), entity => entity.addComponent(new ConstantSignalComponent({})), ]; @@ -170,10 +172,12 @@ MetaConstantSignalBuilding.layerPreview = { MetaConstantSignalBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, ]); + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/cutter.js b/src/js/game/buildings/cutter.js index c136975b..80d866c7 100644 --- a/src/js/game/buildings/cutter.js +++ b/src/js/game/buildings/cutter.js @@ -89,23 +89,25 @@ export class MetaCutterBuilding extends MetaBuilding { } MetaCutterBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.cutter, - }) - ), + 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", - }, ], - }) - ), + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ), ]; MetaCutterBuilding.variants = { @@ -197,4 +199,4 @@ MetaCutterBuilding.componentVariations = { ]); entity.components.ItemProcessor.type = enumItemProcessorTypes.cutterQuad; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/display.js b/src/js/game/buildings/display.js index fd06928a..d87140a9 100644 --- a/src/js/game/buildings/display.js +++ b/src/js/game/buildings/display.js @@ -105,15 +105,17 @@ export class MetaDisplayBuilding extends MetaBuilding { MetaDisplayBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [{ - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, ], - }) - ), + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ], + }) + ), entity => entity.addComponent(new DisplayComponent()), ]; @@ -155,10 +157,12 @@ MetaDisplayBuilding.renderPins = { MetaDisplayBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ - pos: new Vector(0, 0), - direction: enumDirection.bottom, - type: enumPinSlotType.logicalAcceptor, - }, ]); + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.bottom, + type: enumPinSlotType.logicalAcceptor, + }, + ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/filter.js b/src/js/game/buildings/filter.js index b2df8c30..243de778 100644 --- a/src/js/game/buildings/filter.js +++ b/src/js/game/buildings/filter.js @@ -130,40 +130,45 @@ export class MetaFilterBuilding extends MetaBuilding { MetaFilterBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [{ - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, ], - }) - ), + 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.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.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()), ]; @@ -212,18 +217,23 @@ MetaFilterBuilding.renderPins = { MetaFilterBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ - pos: new Vector(0, 0), - direction: enumDirection.left, - type: enumPinSlotType.logicalAcceptor, - }, ]); + 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.ItemAcceptor.setSlots([ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + }, + ]); - entity.components.ItemEjector.setSlots([{ + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, }, @@ -233,4 +243,4 @@ MetaFilterBuilding.componentVariations = { }, ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/hub.js b/src/js/game/buildings/hub.js index 92f3a233..e2ac459e 100644 --- a/src/js/game/buildings/hub.js +++ b/src/js/game/buildings/hub.js @@ -122,100 +122,103 @@ MetaHubBuilding.canPipet = () => false; MetaHubBuilding.setupEntityComponents = [ entity => entity.addComponent(new HubComponent()), entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.hub, - }) - ), + 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.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", - }, - ], - }) - ), + 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 = { @@ -256,13 +259,16 @@ MetaHubBuilding.componentVariations = { entity.components.ItemProcessor.type = enumItemProcessorTypes.hub; - entity.components.WiredPins.setSlots([{ - pos: new Vector(0, 2), - type: enumPinSlotType.logicalEjector, - direction: enumDirection.left, - }, ]); + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 2), + type: enumPinSlotType.logicalEjector, + direction: enumDirection.left, + }, + ]); - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.top, enumDirection.left], filter: "shape", @@ -334,4 +340,4 @@ MetaHubBuilding.componentVariations = { }, ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/item_producer.js b/src/js/game/buildings/item_producer.js index 13e67954..4f463b29 100644 --- a/src/js/game/buildings/item_producer.js +++ b/src/js/game/buildings/item_producer.js @@ -98,21 +98,23 @@ export class MetaItemProducerBuilding extends MetaBuilding { MetaItemProducerBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), + 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.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + type: enumPinSlotType.logicalAcceptor, + direction: enumDirection.bottom, + }, + ], + }) + ), entity => entity.addComponent(new ItemProducerComponent()), ]; @@ -153,10 +155,12 @@ 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, - }, ]); + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + type: enumPinSlotType.logicalAcceptor, + direction: enumDirection.bottom, + }, + ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/lever.js b/src/js/game/buildings/lever.js index 54244d20..9af392e3 100644 --- a/src/js/game/buildings/lever.js +++ b/src/js/game/buildings/lever.js @@ -121,15 +121,17 @@ export class MetaLeverBuilding extends MetaBuilding { MetaLeverBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [{ - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, ], - }) - ), + entity.addComponent( + new WiredPinsComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ], + }) + ), entity => entity.addComponent(new LeverComponent({})), ]; @@ -172,10 +174,12 @@ MetaLeverBuilding.renderPins = { MetaLeverBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ - pos: new Vector(0, 0), - direction: enumDirection.top, - type: enumPinSlotType.logicalEjector, - }, ]); + entity.components.WiredPins.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + type: enumPinSlotType.logicalEjector, + }, + ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/logic_gate.js b/src/js/game/buildings/logic_gate.js index 64918751..52431d34 100644 --- a/src/js/game/buildings/logic_gate.js +++ b/src/js/game/buildings/logic_gate.js @@ -117,11 +117,11 @@ export class MetaLogicGateBuilding extends MetaBuilding { } MetaLogicGateBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [], - }) - ), + entity.addComponent( + new WiredPinsComponent({ + slots: [], + }) + ), entity => entity.addComponent(new LogicGateComponent({})), ]; @@ -202,7 +202,8 @@ MetaLogicGateBuilding.layerPreview = { MetaLogicGateBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -223,7 +224,8 @@ MetaLogicGateBuilding.componentVariations = { }, [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -244,7 +246,8 @@ MetaLogicGateBuilding.componentVariations = { }, [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -264,7 +267,8 @@ MetaLogicGateBuilding.componentVariations = { entity.components.LogicGate.type = enumLogicGateType.or; }, [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -278,4 +282,4 @@ MetaLogicGateBuilding.componentVariations = { entity.components.LogicGate.type = enumLogicGateType.not; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/miner.js b/src/js/game/buildings/miner.js index ee7a3218..a29c08dc 100644 --- a/src/js/game/buildings/miner.js +++ b/src/js/game/buildings/miner.js @@ -115,11 +115,11 @@ export class MetaMinerBuilding extends MetaBuilding { MetaMinerBuilding.setupEntityComponents = [ entity => entity.addComponent(new MinerComponent({})), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ), ]; MetaMinerBuilding.variants = { chainable: "chainable", @@ -189,4 +189,4 @@ MetaMinerBuilding.componentVariations = { [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => { entity.components.Miner.chainable = true; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/mixer.js b/src/js/game/buildings/mixer.js index 1b60e2f0..7a7bbd93 100644 --- a/src/js/game/buildings/mixer.js +++ b/src/js/game/buildings/mixer.js @@ -115,35 +115,36 @@ export class MetaMixerBuilding extends MetaBuilding { MetaMixerBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 2, - processorType: enumItemProcessorTypes.mixer, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 2, + processorType: enumItemProcessorTypes.mixer, + }) + ), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), + 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", - }, - ], - }) - ), + 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 = { @@ -195,7 +196,8 @@ MetaMixerBuilding.componentVariations = { entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.bottom], filter: "color", @@ -207,4 +209,4 @@ MetaMixerBuilding.componentVariations = { }, ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/painter.js b/src/js/game/buildings/painter.js index 8d580707..9b50120f 100644 --- a/src/js/game/buildings/painter.js +++ b/src/js/game/buildings/painter.js @@ -121,27 +121,28 @@ export class MetaPainterBuilding extends MetaBuilding { MetaPainterBuilding.setupEntityComponents = [ entity => entity.addComponent(new ItemProcessorComponent({})), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(1, 0), direction: enumDirection.right }], - }) - ), + 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", - }, - ], - }) - ), + 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 = { @@ -251,7 +252,8 @@ MetaPainterBuilding.componentVariations = { entity.removeComponent(WiredPinsComponent); } - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.left], filter: "shape", @@ -275,7 +277,8 @@ MetaPainterBuilding.componentVariations = { entity.removeComponent(WiredPinsComponent); } - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.left], filter: "shape", @@ -299,7 +302,8 @@ MetaPainterBuilding.componentVariations = { entity.removeComponent(WiredPinsComponent); } - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.left], filter: "shape", @@ -328,7 +332,8 @@ MetaPainterBuilding.componentVariations = { entity.addComponent(new WiredPinsComponent({ slots: [] })); } - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.bottom, type: enumPinSlotType.logicalAcceptor, @@ -350,7 +355,8 @@ MetaPainterBuilding.componentVariations = { }, ]); - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.left], filter: "shape", @@ -383,4 +389,4 @@ MetaPainterBuilding.componentVariations = { entity.components.ItemProcessor.processingRequirement = enumItemProcessorRequirements.painterQuad; entity.components.ItemProcessor.inputsPerCharge = 5; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/reader.js b/src/js/game/buildings/reader.js index c28975f4..410cd05a 100644 --- a/src/js/game/buildings/reader.js +++ b/src/js/game/buildings/reader.js @@ -132,55 +132,62 @@ export class MetaReaderBuilding extends MetaBuilding { 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.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.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.addComponent( + new ItemEjectorComponent({ + slots: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ], + }) + ), entity => - entity.addComponent( - new ItemProcessorComponent({ - processorType: enumItemProcessorTypes.reader, - inputsPerCharge: 1, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + processorType: enumItemProcessorTypes.reader, + inputsPerCharge: 1, + }) + ), entity => - entity.addComponent( - new BeltUnderlaysComponent({ - underlays: [{ - pos: new Vector(0, 0), - direction: enumDirection.top, - }, ], - }) - ), + entity.addComponent( + new BeltUnderlaysComponent({ + underlays: [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ], + }) + ), entity => entity.addComponent(new BeltReaderComponent()), ]; @@ -229,23 +236,29 @@ MetaReaderBuilding.renderPins = { MetaReaderBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemAcceptor.setSlots([{ - pos: new Vector(0, 0), - directions: [enumDirection.bottom], - }, ]); + 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.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, - }, ]; + entity.components.BeltUnderlays.underlays = [ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ]; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/rotater.js b/src/js/game/buildings/rotater.js index 3cd11a30..23f44bb3 100644 --- a/src/js/game/buildings/rotater.js +++ b/src/js/game/buildings/rotater.js @@ -129,28 +129,30 @@ export class MetaRotaterBuilding extends MetaBuilding { MetaRotaterBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 1, - processorType: enumItemProcessorTypes.rotater, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.rotater, + }) + ), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), + 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", - }, ], - }) - ), + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ), ]; MetaRotaterBuilding.variants = { @@ -262,4 +264,4 @@ MetaRotaterBuilding.componentVariations = { [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => { entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater180; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/stacker.js b/src/js/game/buildings/stacker.js index 7017cb30..d75bd7e6 100644 --- a/src/js/game/buildings/stacker.js +++ b/src/js/game/buildings/stacker.js @@ -129,34 +129,35 @@ export class MetaStackerBuilding extends MetaBuilding { MetaStackerBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemProcessorComponent({ - inputsPerCharge: 2, - processorType: enumItemProcessorTypes.stacker, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 2, + processorType: enumItemProcessorTypes.stacker, + }) + ), entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], - }) - ), + 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", - }, - ], - }) - ), + 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 = { @@ -216,7 +217,8 @@ MetaStackerBuilding.componentVariations = { entity.components.ItemEjector.setSlots([{ pos: new Vector(0, 0), direction: enumDirection.top }]); - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 0), directions: [enumDirection.bottom], filter: "shape", @@ -228,4 +230,4 @@ MetaStackerBuilding.componentVariations = { }, ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/storage.js b/src/js/game/buildings/storage.js index 57482839..0b472380 100644 --- a/src/js/game/buildings/storage.js +++ b/src/js/game/buildings/storage.js @@ -132,56 +132,59 @@ export class MetaStorageBuilding extends MetaBuilding { 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, - }, - ], - }) - ), + // 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.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.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, - }, - ], - }) - ), + 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 = { @@ -232,7 +235,8 @@ MetaStorageBuilding.renderPins = { MetaStorageBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.ItemEjector.setSlots([{ + entity.components.ItemEjector.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, }, @@ -241,7 +245,8 @@ MetaStorageBuilding.componentVariations = { direction: enumDirection.top, }, ]); - entity.components.ItemAcceptor.setSlots([{ + entity.components.ItemAcceptor.setSlots([ + { pos: new Vector(0, 1), directions: [enumDirection.bottom], }, @@ -251,7 +256,8 @@ MetaStorageBuilding.componentVariations = { }, ]); entity.components.Storage.maximumStorage = storageSize; - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(1, 1), direction: enumDirection.right, type: enumPinSlotType.logicalEjector, @@ -263,4 +269,4 @@ MetaStorageBuilding.componentVariations = { }, ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/transistor.js b/src/js/game/buildings/transistor.js index c7e732fb..8e175d1c 100644 --- a/src/js/game/buildings/transistor.js +++ b/src/js/game/buildings/transistor.js @@ -118,32 +118,33 @@ export class MetaTransistorBuilding extends MetaBuilding { 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.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, - }) - ), + entity.addComponent( + new LogicGateComponent({ + type: enumLogicGateType.transistor, + }) + ), ]; MetaTransistorBuilding.variants = { @@ -206,4 +207,4 @@ MetaTransistorBuilding.componentVariations = { [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => { entity.components.WiredPins.slots[1].direction = enumDirection.right; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/trash.js b/src/js/game/buildings/trash.js index ac1261d5..2933b5a7 100644 --- a/src/js/game/buildings/trash.js +++ b/src/js/game/buildings/trash.js @@ -120,26 +120,28 @@ export class MetaTrashBuilding extends MetaBuilding { MetaTrashBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [{ - pos: new Vector(0, 0), - directions: [ - enumDirection.top, - enumDirection.right, - enumDirection.bottom, - enumDirection.left, + 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, - }) - ), + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: enumItemProcessorTypes.trash, + }) + ), ]; MetaTrashBuilding.overlayMatrices = { @@ -182,18 +184,20 @@ MetaTrashBuilding.avaibleVariants = { 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.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; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/underground_belt.js b/src/js/game/buildings/underground_belt.js index b72c72a0..48e85457 100644 --- a/src/js/game/buildings/underground_belt.js +++ b/src/js/game/buildings/underground_belt.js @@ -188,7 +188,8 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding { const targetSenderRotation = rotation; for ( - let searchOffset = 1; searchOffset <= globalConfig.undergroundBeltMaxTilesByTier[tier]; + let searchOffset = 1; + searchOffset <= globalConfig.undergroundBeltMaxTilesByTier[tier]; ++searchOffset ) { tile = tile.addScalars(searchVector.x, searchVector.y); @@ -245,18 +246,18 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding { MetaUndergroundBeltBuilding.setupEntityComponents = [ // Required, since the item processor needs this. entity => - entity.addComponent( - new ItemEjectorComponent({ - slots: [], - }) - ), + entity.addComponent( + new ItemEjectorComponent({ + slots: [], + }) + ), entity => entity.addComponent(new UndergroundBeltComponent({})), entity => - entity.addComponent( - new ItemAcceptorComponent({ - slots: [], - }) - ), + entity.addComponent( + new ItemAcceptorComponent({ + slots: [], + }) + ), ]; MetaUndergroundBeltBuilding.rotationVariants = [0, 1]; @@ -360,18 +361,22 @@ 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], - }, ]); + 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, - }, ]); + entity.components.ItemEjector.setSlots([ + { + pos: new Vector(0, 0), + direction: enumDirection.top, + }, + ]); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/virtual_processor.js b/src/js/game/buildings/virtual_processor.js index 944ed9de..0104babf 100644 --- a/src/js/game/buildings/virtual_processor.js +++ b/src/js/game/buildings/virtual_processor.js @@ -121,11 +121,11 @@ export class MetaVirtualProcessorBuilding extends MetaBuilding { MetaVirtualProcessorBuilding.setupEntityComponents = [ entity => - entity.addComponent( - new WiredPinsComponent({ - slots: [], - }) - ), + entity.addComponent( + new WiredPinsComponent({ + slots: [], + }) + ), entity => entity.addComponent(new LogicGateComponent({})), ]; @@ -219,7 +219,8 @@ MetaVirtualProcessorBuilding.silhouetteColors = { MetaVirtualProcessorBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.left, type: enumPinSlotType.logicalEjector, @@ -240,7 +241,8 @@ MetaVirtualProcessorBuilding.componentVariations = { }, [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -256,7 +258,8 @@ MetaVirtualProcessorBuilding.componentVariations = { }, [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.left, type: enumPinSlotType.logicalEjector, @@ -277,7 +280,8 @@ MetaVirtualProcessorBuilding.componentVariations = { }, [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -298,7 +302,8 @@ MetaVirtualProcessorBuilding.componentVariations = { }, [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => { - entity.components.WiredPins.setSlots([{ + entity.components.WiredPins.setSlots([ + { pos: new Vector(0, 0), direction: enumDirection.top, type: enumPinSlotType.logicalEjector, @@ -317,4 +322,4 @@ MetaVirtualProcessorBuilding.componentVariations = { entity.components.LogicGate.type = enumLogicGateType.painter; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/wire.js b/src/js/game/buildings/wire.js index eee50a50..231a5da9 100644 --- a/src/js/game/buildings/wire.js +++ b/src/js/game/buildings/wire.js @@ -151,26 +151,21 @@ export class MetaWireBuilding extends MetaBuilding { getPreviewSprite(rotationVariant, variant) { const wireVariant = MetaWireBuilding.wireVariantToVariant[variant]; switch (MetaWireBuilding.rotationVariantToType[rotationVariant]) { - case enumWireType.forward: - { - return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_forward.png"); - } - case enumWireType.turn: - { - return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_turn.png"); - } - case enumWireType.split: - { - return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_split.png"); - } - case enumWireType.cross: - { - return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_cross.png"); - } - default: - { - assertAlways(false, "Invalid wire rotation variant"); - } + case enumWireType.forward: { + return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_forward.png"); + } + case enumWireType.turn: { + return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_turn.png"); + } + case enumWireType.split: { + return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_split.png"); + } + case enumWireType.cross: { + return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_cross.png"); + } + default: { + assertAlways(false, "Invalid wire rotation variant"); + } } } @@ -398,4 +393,4 @@ MetaWireBuilding.componentVariations = { entity.components.Wire.type = MetaWireBuilding.rotationVariantToType[rotationVariant]; entity.components.Wire.variant = "second"; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/buildings/wire_tunnel.js b/src/js/game/buildings/wire_tunnel.js index a112d4c4..c59d68a3 100644 --- a/src/js/game/buildings/wire_tunnel.js +++ b/src/js/game/buildings/wire_tunnel.js @@ -157,4 +157,4 @@ MetaWireTunnelBuilding.layerByVariant = { MetaWireTunnelBuilding.componentVariations = { [defaultBuildingVariant]: (entity, rotationVariant) => {}, -}; \ No newline at end of file +}; diff --git a/src/js/game/component_registry.js b/src/js/game/component_registry.js index 7c23a7b4..b81bae0c 100644 --- a/src/js/game/component_registry.js +++ b/src/js/game/component_registry.js @@ -71,4 +71,4 @@ export function initComponentRegistry() { ); console.log("📦 There are", gComponentRegistry.getNumEntries(), "components"); -} \ No newline at end of file +} diff --git a/src/js/game/components/belt.js b/src/js/game/components/belt.js index ae5b43ca..427bacee 100644 --- a/src/js/game/components/belt.js +++ b/src/js/game/components/belt.js @@ -66,18 +66,16 @@ export class BeltComponent extends Component { assert(progress <= 1.02, "Invalid progress: " + progress); return new Vector(0, 0.5 - progress); - case enumDirection.right: - { - assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 2: " + progress); - const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI; - return new Vector(0.5 - 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress)); - } - case enumDirection.left: - { - assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 3: " + progress); - const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI; - return new Vector(-0.5 + 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress)); - } + case enumDirection.right: { + assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 2: " + progress); + const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI; + return new Vector(0.5 - 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress)); + } + case enumDirection.left: { + assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 3: " + progress); + const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI; + return new Vector(-0.5 + 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress)); + } default: assertAlways(false, "Invalid belt direction: " + this.direction); return new Vector(0, 0); @@ -115,4 +113,4 @@ BeltComponent.fake_belt_ejector_slot_by_direction = { item: null, progress: 0, }, -}; \ No newline at end of file +}; diff --git a/src/js/game/components/belt_reader.js b/src/js/game/components/belt_reader.js index d8446e64..d451bab5 100644 --- a/src/js/game/components/belt_reader.js +++ b/src/js/game/components/belt_reader.js @@ -41,4 +41,4 @@ export class BeltReaderComponent extends Component { */ this.lastThroughputComputation = 0; } -} \ No newline at end of file +} diff --git a/src/js/game/components/static_map_entity.js b/src/js/game/components/static_map_entity.js index 06495d96..e9fb2672 100644 --- a/src/js/game/components/static_map_entity.js +++ b/src/js/game/components/static_map_entity.js @@ -201,38 +201,34 @@ export class StaticMapEntityComponent extends Component { const size = this.getTileSize(); switch (this.rotation) { - case 0: - { - x = this.origin.x; - y = this.origin.y; - w = size.x; - h = size.y; - break; - } - case 90: - { - x = this.origin.x - size.y + 1; - y = this.origin.y; - w = size.y; - h = size.x; - break; - } - case 180: - { - x = this.origin.x - size.x + 1; - y = this.origin.y - size.y + 1; - w = size.x; - h = size.y; - break; - } - case 270: - { - x = this.origin.x; - y = this.origin.y - size.x + 1; - w = size.y; - h = size.x; - break; - } + case 0: { + x = this.origin.x; + y = this.origin.y; + w = size.x; + h = size.y; + break; + } + case 90: { + x = this.origin.x - size.y + 1; + y = this.origin.y; + w = size.y; + h = size.x; + break; + } + case 180: { + x = this.origin.x - size.x + 1; + y = this.origin.y - size.y + 1; + w = size.x; + h = size.y; + break; + } + case 270: { + x = this.origin.x; + y = this.origin.y - size.x + 1; + w = size.y; + h = size.x; + break; + } default: assert(false, "Invalid rotation"); } @@ -281,7 +277,9 @@ export class StaticMapEntityComponent extends Component { parameters.context.translate(rotationCenterX, rotationCenterY); parameters.context.rotate(Math.radians(this.rotation)); sprite.drawCached( - parameters, -globalConfig.halfTileSize - extrudePixels * size.x, -globalConfig.halfTileSize - extrudePixels * size.y, + parameters, + -globalConfig.halfTileSize - extrudePixels * size.x, + -globalConfig.halfTileSize - extrudePixels * size.y, globalConfig.tileSize * size.x + 2 * extrudePixels * size.x, globalConfig.tileSize * size.y + 2 * extrudePixels * size.y, false // no clipping possible here @@ -290,4 +288,4 @@ export class StaticMapEntityComponent extends Component { parameters.context.translate(-rotationCenterX, -rotationCenterY); } } -} \ No newline at end of file +} diff --git a/src/js/game/components/wire.js b/src/js/game/components/wire.js index 038dcafd..ee60d733 100644 --- a/src/js/game/components/wire.js +++ b/src/js/game/components/wire.js @@ -34,4 +34,4 @@ export class WireComponent extends Component { */ this.linkedNetwork = null; } -} \ No newline at end of file +} diff --git a/src/js/game/core.js b/src/js/game/core.js index d95394ac..a0c68786 100644 --- a/src/js/game/core.js +++ b/src/js/game/core.js @@ -422,7 +422,9 @@ export class GameCore { // Transform to world space if (G_IS_DEV && globalConfig.debug.testClipping) { - params.visibleRect = params.visibleRect.expandedInAllDirections(-200 / this.root.camera.zoomLevel); + params.visibleRect = params.visibleRect.expandedInAllDirections( + -200 / this.root.camera.zoomLevel + ); } root.camera.transform(context); @@ -521,11 +523,11 @@ export class GameCore { context.fillStyle = "blue"; context.fillText( "Atlas: " + - desiredAtlasScale + - " / Zoom: " + - round2Digits(zoomLevel) + - " / Effective Zoom: " + - round2Digits(effectiveZoomLevel), + desiredAtlasScale + + " / Zoom: " + + round2Digits(zoomLevel) + + " / Effective Zoom: " + + round2Digits(effectiveZoomLevel), 20, 600 ); @@ -534,31 +536,31 @@ export class GameCore { context.fillText( "Maintained Buffers: " + - stats.rootKeys + - " root keys / " + - stats.subKeys + - " buffers / VRAM: " + - round2Digits(stats.vramBytes / (1024 * 1024)) + - " MB", + stats.rootKeys + + " root keys / " + + stats.subKeys + + " buffers / VRAM: " + + round2Digits(stats.vramBytes / (1024 * 1024)) + + " MB", 20, 620 ); const internalStats = getBufferStats(); context.fillText( "Total Buffers: " + - internalStats.bufferCount + - " buffers / " + - internalStats.backlogSize + - " backlog / " + - internalStats.backlogKeys + - " keys in backlog / VRAM " + - round2Digits(internalStats.vramUsage / (1024 * 1024)) + - " MB / Backlog " + - round2Digits(internalStats.backlogVramUsage / (1024 * 1024)) + - " MB / Created " + - internalStats.numCreated + - " / Reused " + - internalStats.numReused, + internalStats.bufferCount + + " buffers / " + + internalStats.backlogSize + + " backlog / " + + internalStats.backlogKeys + + " keys in backlog / VRAM " + + round2Digits(internalStats.vramUsage / (1024 * 1024)) + + " MB / Backlog " + + round2Digits(internalStats.backlogVramUsage / (1024 * 1024)) + + " MB / Created " + + internalStats.numCreated + + " / Reused " + + internalStats.numReused, 20, 640 ); @@ -572,4 +574,4 @@ export class GameCore { context.stroke(); } } -} \ No newline at end of file +} diff --git a/src/js/game/entity.js b/src/js/game/entity.js index 3e3952d3..6b50929c 100644 --- a/src/js/game/entity.js +++ b/src/js/game/entity.js @@ -235,4 +235,4 @@ export class Entity extends BasicSerializableObject { drawImpl(parameters) { abstract; } -} \ No newline at end of file +} diff --git a/src/js/game/entity_manager.js b/src/js/game/entity_manager.js index 8e4ef812..4c83343e 100644 --- a/src/js/game/entity_manager.js +++ b/src/js/game/entity_manager.js @@ -238,4 +238,4 @@ export class EntityManager extends BasicSerializableObject { assert(false, "Trying to destroy entity twice"); } } -} \ No newline at end of file +} diff --git a/src/js/game/game_mode.js b/src/js/game/game_mode.js index c5ed0b3e..31ec62d0 100644 --- a/src/js/game/game_mode.js +++ b/src/js/game/game_mode.js @@ -73,4 +73,4 @@ export class GameMode { getIsFreeplayAvailable() { return true; } -} \ No newline at end of file +} diff --git a/src/js/game/game_mode_registry.js b/src/js/game/game_mode_registry.js index a7bc3996..4272e036 100644 --- a/src/js/game/game_mode_registry.js +++ b/src/js/game/game_mode_registry.js @@ -10,4 +10,4 @@ export function initGameModeRegistry() { if (!shapezAPI.ingame.gamemodes.hasOwnProperty(gamemodeKey)) continue; gGameModeRegistry.register(shapezAPI.ingame.gamemodes[gamemodeKey]); } -} \ No newline at end of file +} diff --git a/src/js/game/game_speed_registry.js b/src/js/game/game_speed_registry.js index 0f247c8f..34776325 100644 --- a/src/js/game/game_speed_registry.js +++ b/src/js/game/game_speed_registry.js @@ -14,4 +14,4 @@ export function initGameSpeedRegistry() { if (!shapezAPI.ingame.gamespeed.hasOwnProperty(gamespeedKey)) continue; gGameSpeedRegistry.register(shapezAPI.ingame.gamespeed[gamespeedKey]); } -} \ No newline at end of file +} diff --git a/src/js/game/game_system.js b/src/js/game/game_system.js index 073e0ac8..4cd3cb5b 100644 --- a/src/js/game/game_system.js +++ b/src/js/game/game_system.js @@ -48,4 +48,4 @@ export class GameSystem { startDraw(parameters) { this.draw(parameters); } -} \ No newline at end of file +} diff --git a/src/js/game/game_system_manager.js b/src/js/game/game_system_manager.js index 9bb22ec8..0adcf572 100644 --- a/src/js/game/game_system_manager.js +++ b/src/js/game/game_system_manager.js @@ -164,4 +164,4 @@ export class GameSystemManager { system.refreshCaches(); } } -} \ No newline at end of file +} diff --git a/src/js/game/game_system_with_filter.js b/src/js/game/game_system_with_filter.js index 21ebb162..a6efeffd 100644 --- a/src/js/game/game_system_with_filter.js +++ b/src/js/game/game_system_with_filter.js @@ -134,4 +134,4 @@ export class GameSystemWithFilter extends GameSystem { arrayDelete(this.allEntities, index); } } -} \ No newline at end of file +} diff --git a/src/js/game/hub_goals.js b/src/js/game/hub_goals.js index 44e5eedb..45e745ac 100644 --- a/src/js/game/hub_goals.js +++ b/src/js/game/hub_goals.js @@ -127,7 +127,8 @@ export class HubGoals extends BasicSerializableObject { * @returns {boolean} */ isEndOfDemoReached() { - return (!this.root.gameMode.getIsFreeplayAvailable() && + return ( + !this.root.gameMode.getIsFreeplayAvailable() && this.level >= this.root.gameMode.getLevelDefinitions().length ); } @@ -506,13 +507,13 @@ export class HubGoals extends BasicSerializableObject { HubGoals.getProcessorBaseSpeed = { trash: processorType => 1e30, hub: processorType => 1e30, - balancer: function(processorType) { + balancer: function (processorType) { return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2; }, - reader: function(processorType) { + reader: function (processorType) { return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt; }, - mixer: function(processorType) { + mixer: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -523,7 +524,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - painter: function(processorType) { + painter: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -534,7 +535,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - painterDouble: function(processorType) { + painterDouble: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -545,7 +546,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - painterQuad: function(processorType) { + painterQuad: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -557,7 +558,7 @@ HubGoals.getProcessorBaseSpeed = { ); }, - cutter: function(processorType) { + cutter: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -568,7 +569,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - cutterQuad: function(processorType) { + cutterQuad: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -579,7 +580,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - rotater: function(processorType) { + rotater: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -590,7 +591,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - rotaterCCW: function(processorType) { + rotaterCCW: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -601,7 +602,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - rotater180: function(processorType) { + rotater180: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -612,7 +613,7 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, - stacker: function(processorType) { + stacker: function (processorType) { assert( globalConfig.buildingSpeeds[processorType], "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType @@ -623,4 +624,4 @@ HubGoals.getProcessorBaseSpeed = { globalConfig.buildingSpeeds[processorType] ); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/hud/base_hud_part.js b/src/js/game/hud/base_hud_part.js index 167382f5..84b6d619 100644 --- a/src/js/game/hud/base_hud_part.js +++ b/src/js/game/hud/base_hud_part.js @@ -164,4 +164,4 @@ export class BaseHUDPart { "mapMoveLeft", ]); } -} \ No newline at end of file +} diff --git a/src/js/game/hud/hud.js b/src/js/game/hud/hud.js index aee04d9c..714b697a 100644 --- a/src/js/game/hud/hud.js +++ b/src/js/game/hud/hud.js @@ -342,4 +342,4 @@ export class GameHUD { this.signals[key].removeAll(); } } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/base_toolbar.js b/src/js/game/hud/parts/base_toolbar.js index d8b1e3c1..b3f5abfc 100644 --- a/src/js/game/hud/parts/base_toolbar.js +++ b/src/js/game/hud/parts/base_toolbar.js @@ -18,7 +18,8 @@ export class HUDBaseToolbar extends BaseHUDPart { * @param {Layer=} param0.layer */ constructor( - root, { primaryBuildings, secondaryBuildings = [], visibilityCondition, htmlElementId, layer = "regular" } + root, + { primaryBuildings, secondaryBuildings = [], visibilityCondition, htmlElementId, layer = "regular" } ) { super(root); @@ -81,7 +82,8 @@ export class HUDBaseToolbar extends BaseHUDPart { const itemContainer = makeDiv( this.primaryBuildings.includes(allBuildings[i]) ? rowPrimary : rowSecondary, - null, ["building"] + null, + ["building"] ); itemContainer.setAttribute("data-icon", "building_icons/" + metaBuilding.getId() + ".png"); itemContainer.setAttribute("data-id", metaBuilding.getId()); @@ -159,9 +161,9 @@ export class HUDBaseToolbar extends BaseHUDPart { let newBuildingFound = false; let newIndex = this.lastSelectedIndex; - const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed ? - -1 : - 1; + const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed + ? -1 + : 1; for (let i = 0; i <= this.primaryBuildings.length; ++i) { newIndex = safeModulo(newIndex + direction, this.primaryBuildings.length); @@ -227,4 +229,4 @@ export class HUDBaseToolbar extends BaseHUDPart { this.root.hud.signals.buildingSelectedForPlacement.dispatch(metaBuilding); this.onSelectedPlacementBuildingChanged(metaBuilding); } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/building_placer.js b/src/js/game/hud/parts/building_placer.js index abab3e56..96e2924b 100644 --- a/src/js/game/hud/parts/building_placer.js +++ b/src/js/game/hud/parts/building_placer.js @@ -34,7 +34,8 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { this.buildingInfoElements.descText = makeDiv(this.buildingInfoElements.desc, null, ["text"], ""); this.buildingInfoElements.additionalInfo = makeDiv( this.buildingInfoElements.desc, - null, ["additionalInfo"], + null, + ["additionalInfo"], "" ); this.buildingInfoElements.hotkey = makeDiv(this.buildingInfoElements.desc, null, ["hotkey"], ""); @@ -135,9 +136,9 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { this.buildingInfoElements.tutorialImage.setAttribute( "data-icon", "building_tutorials/" + - metaBuilding.getId() + - (variant === defaultBuildingVariant ? "" : "-" + variant) + - ".png" + metaBuilding.getId() + + (variant === defaultBuildingVariant ? "" : "-" + variant) + + ".png" ); removeAllChildren(this.buildingInfoElements.additionalInfo); @@ -189,14 +190,15 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { makeDiv( this.variantsElement, - null, ["explanation"], + null, + ["explanation"], T.ingame.buildingPlacement.cycleBuildingVariants.replace( "", "" + - this.root.keyMapper - .getBinding(KEYMAPPINGS.placement.cycleBuildingVariants) - .getKeyCodeString() + - "" + this.root.keyMapper + .getBinding(KEYMAPPINGS.placement.cycleBuildingVariants) + .getKeyCodeString() + + "" ) ); @@ -442,10 +444,12 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { parameters.context.translate(worldPos.x, worldPos.y); parameters.context.rotate(angle); parameters.context.drawImage( - arrowSprite, -6, -globalConfig.halfTileSize - - clamp((this.root.time.realtimeNow() * 1.5) % 1.0, 0, 1) * 1 * globalConfig.tileSize + - globalConfig.halfTileSize - - 6, + arrowSprite, + -6, + -globalConfig.halfTileSize - + clamp((this.root.time.realtimeNow() * 1.5) % 1.0, 0, 1) * 1 * globalConfig.tileSize + + globalConfig.halfTileSize - + 6, 12, 12 ); @@ -498,7 +502,8 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { // Go over all slots for ( - let acceptorDirectionIndex = 0; acceptorDirectionIndex < slot.directions.length; + let acceptorDirectionIndex = 0; + acceptorDirectionIndex < slot.directions.length; ++acceptorDirectionIndex ) { const direction = slot.directions[acceptorDirectionIndex]; @@ -529,7 +534,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { } else if ( sourceBeltComp && sourceStaticComp.localDirectionToWorld(sourceBeltComp.direction) === - enumInvertedDirections[worldDirection] + enumInvertedDirections[worldDirection] ) { // Belt connected isConnected = true; @@ -615,4 +620,4 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { parameters.context.globalAlpha = 1; } } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/building_placer_logic.js b/src/js/game/hud/parts/building_placer_logic.js index c42d2418..a875aad8 100644 --- a/src/js/game/hud/parts/building_placer_logic.js +++ b/src/js/game/hud/parts/building_placer_logic.js @@ -279,20 +279,20 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { * Tries to rotate the current building */ tryRotate() { - const selectedBuilding = this.currentMetaBuilding.get(); - if (selectedBuilding) { - if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) { - this.currentBaseRotation = (this.currentBaseRotation + 270) % 360; - } else { - this.currentBaseRotation = (this.currentBaseRotation + 90) % 360; - } - const staticComp = this.fakeEntity.components.StaticMapEntity; - staticComp.rotation = this.currentBaseRotation; + const selectedBuilding = this.currentMetaBuilding.get(); + if (selectedBuilding) { + if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) { + this.currentBaseRotation = (this.currentBaseRotation + 270) % 360; + } else { + this.currentBaseRotation = (this.currentBaseRotation + 90) % 360; } + const staticComp = this.fakeEntity.components.StaticMapEntity; + staticComp.rotation = this.currentBaseRotation; } - /** - * Tries to delete the building under the mouse - */ + } + /** + * Tries to delete the building under the mouse + */ deleteBelowCursor() { const mousePosition = this.root.app.mousePosition; if (!mousePosition) { @@ -443,7 +443,8 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { } // Check if we should stop placement - if (!metaBuilding.getStayInPlacementMode() && + if ( + !metaBuilding.getStayInPlacementMode() && !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).pressed && !this.root.app.settings.getAllSettings().alwaysMultiplace ) { @@ -471,9 +472,9 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { console.warn("Invalid variant selected:", this.currentVariant.get()); } const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier) - .pressed ? - -1 : - 1; + .pressed + ? -1 + : 1; const newIndex = safeModulo(index + direction, availableVariants.length); const newVariant = availableVariants[newIndex]; @@ -804,4 +805,4 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { this.abortDragging(); } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/buildings_toolbar.js b/src/js/game/hud/parts/buildings_toolbar.js index 1c834279..1daf0973 100644 --- a/src/js/game/hud/parts/buildings_toolbar.js +++ b/src/js/game/hud/parts/buildings_toolbar.js @@ -52,4 +52,4 @@ HUDBuildingsToolbar.bar = { MetaDisplayBuilding, ], htmlElementId: "ingame_HUD_BuildingsToolbar", -}; \ No newline at end of file +}; diff --git a/src/js/game/hud/parts/miner_highlight.js b/src/js/game/hud/parts/miner_highlight.js index e735d8b5..a0c6919d 100644 --- a/src/js/game/hud/parts/miner_highlight.js +++ b/src/js/game/hud/parts/miner_highlight.js @@ -103,9 +103,9 @@ export class HUDMinerHighlight extends BaseHUDPart { parameters.context.globalAlpha = 0.6; parameters.context.font = "bold " + scale * 8 + "px GameFont"; parameters.context.fillText( - connectedEntities.length === 1 ? - T.ingame.connectedMiners.one_miner : - T.ingame.connectedMiners.n_miners.replace("", String(connectedEntities.length)), + connectedEntities.length === 1 + ? T.ingame.connectedMiners.one_miner + : T.ingame.connectedMiners.n_miners.replace("", String(connectedEntities.length)), tooltipLocation.x + 10 * scale, tooltipLocation.y + 22 * scale ); @@ -173,4 +173,4 @@ export class HUDMinerHighlight extends BaseHUDPart { return results; } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/settings_menu.js b/src/js/game/hud/parts/settings_menu.js index e00b107e..81156400 100644 --- a/src/js/game/hud/parts/settings_menu.js +++ b/src/js/game/hud/parts/settings_menu.js @@ -15,7 +15,8 @@ export class HUDSettingsMenu extends BaseHUDPart { this.statsElement = makeDiv( this.background, - null, ["statsElement"], + null, + ["statsElement"], ` ${T.ingame.settingsMenu.beltsPlaced} ${T.ingame.settingsMenu.buildingsPlaced} @@ -91,7 +92,7 @@ export class HUDSettingsMenu extends BaseHUDPart { buildingsPlacedElement.innerText = formatBigNumberFull( this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length - - this.root.entityMgr.getAllWithComponent(BeltComponent).length + this.root.entityMgr.getAllWithComponent(BeltComponent).length ); beltsPlacedElement.innerText = formatBigNumberFull( @@ -110,7 +111,8 @@ export class HUDSettingsMenu extends BaseHUDPart { } } -HUDSettingsMenu.buttons = [{ +HUDSettingsMenu.buttons = [ + { id: "continue", action: hudSettingsMenu => () => hudSettingsMenu.close(), options: { @@ -131,4 +133,4 @@ HUDSettingsMenu.buttons = [{ preventDefault: false, }, }, -]; \ No newline at end of file +]; diff --git a/src/js/game/hud/parts/shop.js b/src/js/game/hud/parts/shop.js index 7481e4c6..96521898 100644 --- a/src/js/game/hud/parts/shop.js +++ b/src/js/game/hud/parts/shop.js @@ -244,4 +244,4 @@ export class HUDShop extends BaseHUDPart { isBlockingOverlay() { return this.visible; } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/waypoints.js b/src/js/game/hud/parts/waypoints.js index a9db8db6..7de0dde1 100644 --- a/src/js/game/hud/parts/waypoints.js +++ b/src/js/game/hud/parts/waypoints.js @@ -44,12 +44,13 @@ export class HUDWaypoints extends BaseHUDPart { * @param {HTMLElement} parent */ createElements(parent) { - // Create the helper box on the lower right when zooming out - if (this.root.app.settings.getAllSettings().offerHints) { - this.hintElement = makeDiv( - parent, - "ingame_HUD_Waypoints_Hint", [], - ` + // Create the helper box on the lower right when zooming out + if (this.root.app.settings.getAllSettings().offerHints) { + this.hintElement = makeDiv( + parent, + "ingame_HUD_Waypoints_Hint", + [], + ` ${T.ingame.waypoints.waypoints} ${T.ingame.waypoints.description.replace( "", @@ -643,4 +644,4 @@ export class HUDWaypoints extends BaseHUDPart { parameters.context.textBaseline = "alphabetic"; parameters.context.globalAlpha = 1; } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/wire_info.js b/src/js/game/hud/parts/wire_info.js index 58f47edf..60a34796 100644 --- a/src/js/game/hud/parts/wire_info.js +++ b/src/js/game/hud/parts/wire_info.js @@ -36,7 +36,8 @@ export class HUDWireInfo extends BaseHUDPart { return; } - if (!this.root.camera.getIsMapOverlayActive() && + if ( + !this.root.camera.getIsMapOverlayActive() && !this.root.logic.getIsEntityIntersectedWithMatrix(entity, worldPos) ) { // Detailed intersection check @@ -115,4 +116,4 @@ export class HUDWireInfo extends BaseHUDPart { } parameters.context.globalAlpha = 1; } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/wires_overlay.js b/src/js/game/hud/parts/wires_overlay.js index d0643610..3bcab232 100644 --- a/src/js/game/hud/parts/wires_overlay.js +++ b/src/js/game/hud/parts/wires_overlay.js @@ -146,9 +146,9 @@ export class HUDWiresOverlay extends BaseHUDPart { parameters.context.globalCompositeOperation = "source-over"; parameters.context.scale(scaleFactor, scaleFactor); - parameters.context.fillStyle = hasTileGrid ? - this.cachedPatternBackground : - "rgba(78, 137, 125, 0.75)"; + parameters.context.fillStyle = hasTileGrid + ? this.cachedPatternBackground + : "rgba(78, 137, 125, 0.75)"; parameters.context.fillRect( bounds.x / scaleFactor, bounds.y / scaleFactor, @@ -159,4 +159,4 @@ export class HUDWiresOverlay extends BaseHUDPart { parameters.context.globalAlpha = 1; } -} \ No newline at end of file +} diff --git a/src/js/game/hud/parts/wires_toolbar.js b/src/js/game/hud/parts/wires_toolbar.js index 6b8a09ad..fdb9a3e7 100644 --- a/src/js/game/hud/parts/wires_toolbar.js +++ b/src/js/game/hud/parts/wires_toolbar.js @@ -45,4 +45,4 @@ HUDWiresToolbar.bar = { MetaDisplayBuilding, ], htmlElementId: "ingame_HUD_wires_toolbar", -}; \ No newline at end of file +}; diff --git a/src/js/game/item_registry.js b/src/js/game/item_registry.js index 9617253b..98538e5b 100644 --- a/src/js/game/item_registry.js +++ b/src/js/game/item_registry.js @@ -15,4 +15,4 @@ export function initItemRegistry() { const itemClass = shapezAPI.ingame.items[itemId]; gItemRegistry.register(itemClass); } -} \ No newline at end of file +} diff --git a/src/js/game/item_resolver.js b/src/js/game/item_resolver.js index 0b9e90f6..4e676d08 100644 --- a/src/js/game/item_resolver.js +++ b/src/js/game/item_resolver.js @@ -19,4 +19,4 @@ export function itemResolverSingleton(root, data) { assertAlways(false, "Unknown item type: " + itemType); } -export const typeItemSingleton = types.obj(gItemRegistry, itemResolverSingleton); \ No newline at end of file +export const typeItemSingleton = types.obj(gItemRegistry, itemResolverSingleton); diff --git a/src/js/game/items/boolean_item.js b/src/js/game/items/boolean_item.js index 31d7ad0a..1d710ad4 100644 --- a/src/js/game/items/boolean_item.js +++ b/src/js/game/items/boolean_item.js @@ -93,7 +93,7 @@ export const BOOL_TRUE_SINGLETON = new BooleanItem(1); * @returns {boolean} */ export function isTrueItem(item) { - return item && item.getItemType() === "boolean" && !!( /** @type {BooleanItem} */ (item).value); + return item && item.getItemType() === "boolean" && !!(/** @type {BooleanItem} */ (item).value); } /** @@ -107,8 +107,8 @@ export function isTruthyItem(item) { } if (item.getItemType() === "boolean") { - return !!( /** @type {BooleanItem} */ (item).value); + return !!(/** @type {BooleanItem} */ (item).value); } return true; -} \ No newline at end of file +} diff --git a/src/js/game/items/color_item.js b/src/js/game/items/color_item.js index 8bff826f..1cae9b8d 100644 --- a/src/js/game/items/color_item.js +++ b/src/js/game/items/color_item.js @@ -102,4 +102,4 @@ ColorItem.ITEM_SINGLETONS = {}; for (const color in enumColors) { ColorItem.ITEM_SINGLETONS[color] = new ColorItem(color); -} \ No newline at end of file +} diff --git a/src/js/game/items/shape_item.js b/src/js/game/items/shape_item.js index 511b2383..fd74112b 100644 --- a/src/js/game/items/shape_item.js +++ b/src/js/game/items/shape_item.js @@ -79,4 +79,4 @@ export class ShapeItem extends BaseItem { ShapeItem.resolveSingleton = (root, itemData) => { return root.shapeDefinitionMgr.getShapeItemFromShortKey(itemData); -}; \ No newline at end of file +}; diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index b505ac39..6f8e914a 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -264,9 +264,9 @@ export function getStringForKeyCode(code) { return "'"; } - return (48 <= code && code <= 57) || (65 <= code && code <= 90) ? - String.fromCharCode(code) : - "[" + code + "]"; + return (48 <= code && code <= 57) || (65 <= code && code <= 90) + ? String.fromCharCode(code) + : "[" + code + "]"; } export class Keybinding { @@ -478,4 +478,4 @@ export class KeyActionMapper { assert(this.keybindings[id], "Keybinding " + id + " not known!"); return this.keybindings[id]; } -} \ No newline at end of file +} diff --git a/src/js/game/logic.js b/src/js/game/logic.js index 7f1edf60..ae828de5 100644 --- a/src/js/game/logic.js +++ b/src/js/game/logic.js @@ -430,4 +430,4 @@ export class GameLogic { } return { ejectors, acceptors }; } -} \ No newline at end of file +} diff --git a/src/js/game/map_chunk_view.js b/src/js/game/map_chunk_view.js index 37663801..f8b934fb 100644 --- a/src/js/game/map_chunk_view.js +++ b/src/js/game/map_chunk_view.js @@ -142,9 +142,9 @@ export class MapChunkView extends MapChunk { */ generateOverlayBuffer(canvas, context, w, h, dpi) { context.fillStyle = - this.containedEntities.length > 0 ? - THEME.map.chunkOverview.filled : - THEME.map.chunkOverview.empty; + this.containedEntities.length > 0 + ? THEME.map.chunkOverview.filled + : THEME.map.chunkOverview.empty; context.fillRect(0, 0, w, h); if (this.root.app.settings.getAllSettings().displayChunkBorders) { @@ -350,4 +350,4 @@ export class MapChunkView extends MapChunk { system.drawChunk_ForegroundLayer(parameters, this, layer); } } -} \ No newline at end of file +} diff --git a/src/js/game/map_view.js b/src/js/game/map_view.js index b2e3e536..b15d3768 100644 --- a/src/js/game/map_view.js +++ b/src/js/game/map_view.js @@ -216,4 +216,4 @@ export class MapView extends BaseMap { this.drawVisibleChunks(parameters, MapChunkView.prototype.drawBackgroundLayer); } -} \ No newline at end of file +} diff --git a/src/js/game/meta_building.js b/src/js/game/meta_building.js index 1139fb75..f2ad2e51 100644 --- a/src/js/game/meta_building.js +++ b/src/js/game/meta_building.js @@ -142,9 +142,9 @@ export class MetaBuilding { getPreviewSprite(rotationVariant = 0, variant = defaultBuildingVariant) { return Loader.getSprite( "sprites/buildings/" + - this.id + - (variant === defaultBuildingVariant ? "" : "-" + variant) + - ".png" + this.id + + (variant === defaultBuildingVariant ? "" : "-" + variant) + + ".png" ); } @@ -155,9 +155,9 @@ export class MetaBuilding { getBlueprintSprite(rotationVariant = 0, variant = defaultBuildingVariant) { return Loader.getSprite( "sprites/blueprints/" + - this.id + - (variant === defaultBuildingVariant ? "" : "-" + variant) + - ".png" + this.id + + (variant === defaultBuildingVariant ? "" : "-" + variant) + + ".png" ); } @@ -232,9 +232,9 @@ export class MetaBuilding { getSprite(rotationVariant, variant) { return Loader.getSprite( "sprites/buildings/" + - this.id + - (variant === defaultBuildingVariant ? "" : "-" + variant) + - ".png" + this.id + + (variant === defaultBuildingVariant ? "" : "-" + variant) + + ".png" ); } @@ -279,4 +279,4 @@ export class MetaBuilding { setupEntityComponents(entity, root) { abstract; } -} \ No newline at end of file +} diff --git a/src/js/game/meta_building_registry.js b/src/js/game/meta_building_registry.js index 41922bdc..1cfa3c31 100644 --- a/src/js/game/meta_building_registry.js +++ b/src/js/game/meta_building_registry.js @@ -187,4 +187,4 @@ export function initBuildingCodesAfterResourcesLoaded() { variant.rotationVariant ); } -} \ No newline at end of file +} diff --git a/src/js/game/modes/regular.js b/src/js/game/modes/regular.js index 26038f0a..44c2c748 100644 --- a/src/js/game/modes/regular.js +++ b/src/js/game/modes/regular.js @@ -43,7 +43,8 @@ function generateUpgrades(limitedVersion = false) { } const upgrades = { - belt: [{ + belt: [ + { required: [{ shape: "CuCuCuCu", amount: 30 }], }, { @@ -72,7 +73,8 @@ function generateUpgrades(limitedVersion = false) { ...generateInfiniteUnlocks(), ], - miner: [{ + miner: [ + { required: [{ shape: "RuRuRuRu", amount: 300 }], }, { @@ -101,7 +103,8 @@ function generateUpgrades(limitedVersion = false) { ...generateInfiniteUnlocks(), ], - processors: [{ + processors: [ + { required: [{ shape: "SuSuSuSu", amount: 500 }], }, { @@ -130,7 +133,8 @@ function generateUpgrades(limitedVersion = false) { ...generateInfiniteUnlocks(), ], - painting: [{ + painting: [ + { required: [{ shape: "RbRb----", amount: 600 }], }, { @@ -317,115 +321,117 @@ export function generateLevelDefinitions(limitedVersion = false) { }, // DEMO STOPS HERE - ...(limitedVersion ? - [{ - shape: "RpRpRpRp:CwCwCwCw", - required: 0, - reward: enumHubGoalRewards.reward_demo_end, - }, ] : - [ - // 14 - // Belt reader - { - shape: "--Cg----:--Cr----", // unused - required: 8, // Per second! - reward: enumHubGoalRewards.reward_belt_reader, - throughputOnly: true, - }, + ...(limitedVersion + ? [ + { + shape: "RpRpRpRp:CwCwCwCw", + required: 0, + reward: enumHubGoalRewards.reward_demo_end, + }, + ] + : [ + // 14 + // Belt reader + { + shape: "--Cg----:--Cr----", // unused + required: 8, // Per second! + reward: enumHubGoalRewards.reward_belt_reader, + throughputOnly: true, + }, - // 15 - // Storage - { - shape: "SrSrSrSr:CyCyCyCy", // unused - required: 10000, - reward: enumHubGoalRewards.reward_storage, - }, + // 15 + // Storage + { + shape: "SrSrSrSr:CyCyCyCy", // unused + required: 10000, + reward: enumHubGoalRewards.reward_storage, + }, - // 16 - // Quad Cutter - { - shape: "SrSrSrSr:CyCyCyCy:SwSwSwSw", // belts t4 (two variants) - required: 6000, - reward: enumHubGoalRewards.reward_cutter_quad, - }, + // 16 + // Quad Cutter + { + shape: "SrSrSrSr:CyCyCyCy:SwSwSwSw", // belts t4 (two variants) + required: 6000, + reward: enumHubGoalRewards.reward_cutter_quad, + }, - // 17 - // Double painter - { - shape: "CbRbRbCb:CwCwCwCw:WbWbWbWb", // miner t4 (two variants) - required: 20000, - reward: enumHubGoalRewards.reward_painter_double, - }, + // 17 + // Double painter + { + shape: "CbRbRbCb:CwCwCwCw:WbWbWbWb", // miner t4 (two variants) + required: 20000, + reward: enumHubGoalRewards.reward_painter_double, + }, - // 18 - // Rotater (180deg) - { - shape: "Sg----Sg:CgCgCgCg:--CyCy--", // unused - required: 20000, - reward: enumHubGoalRewards.reward_rotater_180, - }, + // 18 + // Rotater (180deg) + { + shape: "Sg----Sg:CgCgCgCg:--CyCy--", // unused + required: 20000, + reward: enumHubGoalRewards.reward_rotater_180, + }, - // 19 - // Compact splitter - { - shape: "CpRpCp--:SwSwSwSw", - required: 25000, - reward: enumHubGoalRewards.reward_splitter, - }, + // 19 + // Compact splitter + { + shape: "CpRpCp--:SwSwSwSw", + required: 25000, + reward: enumHubGoalRewards.reward_splitter, + }, - // 20 - // WIRES - { - shape: finalGameShape, - required: 25000, - reward: enumHubGoalRewards.reward_wires_painter_and_levers, - }, + // 20 + // WIRES + { + shape: finalGameShape, + required: 25000, + reward: enumHubGoalRewards.reward_wires_painter_and_levers, + }, - // 21 - // Filter - { - shape: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr", - required: 25000, - reward: enumHubGoalRewards.reward_filter, - }, + // 21 + // Filter + { + shape: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr", + required: 25000, + reward: enumHubGoalRewards.reward_filter, + }, - // 22 - // Constant signal - { - shape: "Cg----Cr:Cw----Cw:Sy------:Cy----Cy", - required: 25000, - reward: enumHubGoalRewards.reward_constant_signal, - }, + // 22 + // Constant signal + { + shape: "Cg----Cr:Cw----Cw:Sy------:Cy----Cy", + required: 25000, + reward: enumHubGoalRewards.reward_constant_signal, + }, - // 23 - // Display - { - shape: "CcSyCcSy:SyCcSyCc:CcSyCcSy", - required: 25000, - reward: enumHubGoalRewards.reward_display, - }, + // 23 + // Display + { + shape: "CcSyCcSy:SyCcSyCc:CcSyCcSy", + required: 25000, + reward: enumHubGoalRewards.reward_display, + }, - // 24 Logic gates - { - shape: "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy", - required: 25000, - reward: enumHubGoalRewards.reward_logic_gates, - }, + // 24 Logic gates + { + shape: "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy", + required: 25000, + reward: enumHubGoalRewards.reward_logic_gates, + }, - // 25 Virtual Processing - { - shape: "Rg--Rg--:CwRwCwRw:--Rg--Rg", - required: 25000, - reward: enumHubGoalRewards.reward_virtual_processing, - }, + // 25 Virtual Processing + { + shape: "Rg--Rg--:CwRwCwRw:--Rg--Rg", + required: 25000, + reward: enumHubGoalRewards.reward_virtual_processing, + }, - // 26 Freeplay - { - shape: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", - required: 50000, - reward: enumHubGoalRewards.reward_freeplay, - }, - ]), + // 26 Freeplay + { + shape: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", + required: 50000, + reward: enumHubGoalRewards.reward_freeplay, + }, + ]), ]; if (G_IS_DEV) { @@ -457,9 +463,9 @@ export class RegularGameMode extends GameMode { } getUpgrades() { - return this.root.app.restrictionMgr.getHasExtendedUpgrades() ? - fullVersionUpgrades : - demoVersionUpgrades; + return this.root.app.restrictionMgr.getHasExtendedUpgrades() + ? fullVersionUpgrades + : demoVersionUpgrades; } getIsFreeplayAvailable() { @@ -471,8 +477,8 @@ export class RegularGameMode extends GameMode { } getLevelDefinitions() { - return this.root.app.restrictionMgr.getHasExtendedLevelsAndFreeplay() ? - fullVersionLevels : - demoVersionLevels; + return this.root.app.restrictionMgr.getHasExtendedLevelsAndFreeplay() + ? fullVersionLevels + : demoVersionLevels; } -} \ No newline at end of file +} diff --git a/src/js/game/production_analytics.js b/src/js/game/production_analytics.js index e4b4f449..c8a1fa5e 100644 --- a/src/js/game/production_analytics.js +++ b/src/js/game/production_analytics.js @@ -131,4 +131,4 @@ export class ProductionAnalytics extends BasicSerializableObject { this.startNewSlice(); } } -} \ No newline at end of file +} diff --git a/src/js/game/root.js b/src/js/game/root.js index 78969643..a0b9d189 100644 --- a/src/js/game/root.js +++ b/src/js/game/root.js @@ -222,4 +222,4 @@ export class GameRoot { } } } -} \ No newline at end of file +} diff --git a/src/js/game/shape_definition.js b/src/js/game/shape_definition.js index 52e84bfb..91a10e5b 100644 --- a/src/js/game/shape_definition.js +++ b/src/js/game/shape_definition.js @@ -607,10 +607,12 @@ ShapeDefinition.renderQuad = { context.beginPath(); context.moveTo(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize); context.arc( - insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize, - quadrantSize * layerScale, -Math.PI * 0.5, + insetPadding + -quadrantHalfSize, + -insetPadding + quadrantHalfSize, + quadrantSize * layerScale, + -Math.PI * 0.5, 0 ); context.closePath(); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/systems/belt.js b/src/js/game/systems/belt.js index 5375d447..12155439 100644 --- a/src/js/game/systems/belt.js +++ b/src/js/game/systems/belt.js @@ -502,7 +502,7 @@ export class BeltSystem extends GameSystemWithFilter { // 126 / 42 is the exact animation speed of the png animation const animationIndex = Math.floor( ((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) * - globalConfig.itemSpacingOnBelts + globalConfig.itemSpacingOnBelts ); const contents = chunk.containedEntitiesByLayer.regular; @@ -555,4 +555,4 @@ export class BeltSystem extends GameSystemWithFilter { this.beltPaths[i].drawDebug(parameters); } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 436e6cfe..bbb25744 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -30,9 +30,9 @@ export class BeltReaderSystem extends GameSystemWithFilter { pinsComp.slots[1].value = readerComp.lastItem; pinsComp.slots[0].value = (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > - minimumTimeForThroughput ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; + minimumTimeForThroughput + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; if (now - readerComp.lastThroughputComputation > 0.5) { // Compute throughput @@ -56,4 +56,4 @@ export class BeltReaderSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/belt_underlays.js b/src/js/game/systems/belt_underlays.js index 8956a582..d7d8933a 100644 --- a/src/js/game/systems/belt_underlays.js +++ b/src/js/game/systems/belt_underlays.js @@ -252,12 +252,14 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter { } // Culling, Part 2: Check if the overlay is visible - if (!parameters.visibleRect.containsRect4Params( + if ( + !parameters.visibleRect.containsRect4Params( destX, destY, globalConfig.tileSize, globalConfig.tileSize - )) { + ) + ) { continue; } @@ -280,14 +282,16 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter { // SYNC with systems/belt.js:drawSingleEntity! const animationIndex = Math.floor( ((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) * - globalConfig.itemSpacingOnBelts + globalConfig.itemSpacingOnBelts ); parameters.context.translate(x, y); parameters.context.rotate(angleRadians); this.underlayBeltSprites[ animationIndex % this.underlayBeltSprites.length ].drawCachedWithClipRect( - parameters, -globalConfig.halfTileSize, -globalConfig.halfTileSize, + parameters, + -globalConfig.halfTileSize, + -globalConfig.halfTileSize, globalConfig.tileSize, globalConfig.tileSize, clipRect @@ -297,4 +301,4 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/constant_signal.js b/src/js/game/systems/constant_signal.js index a5d56759..17e07162 100644 --- a/src/js/game/systems/constant_signal.js +++ b/src/js/game/systems/constant_signal.js @@ -172,4 +172,4 @@ export class ConstantSignalSystem extends GameSystemWithFilter { return null; } -} \ No newline at end of file +} diff --git a/src/js/game/systems/display.js b/src/js/game/systems/display.js index a1616119..7915e447 100644 --- a/src/js/game/systems/display.js +++ b/src/js/game/systems/display.js @@ -86,7 +86,7 @@ DisplaySystem.displayItemType = { DisplaySystem.displayItem = { color: (parameters, value, origin, globalConfig) => - DisplaySystem.displaySprites[ /** @type {ColorItem} */ (value).color].drawCachedCentered( + DisplaySystem.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered( parameters, (origin.x + 0.5) * globalConfig.tileSize, (origin.y + 0.5) * globalConfig.tileSize, @@ -104,4 +104,4 @@ DisplaySystem.displayItem = { }; DisplaySystem.shapeRadius = () => 30; -DisplaySystem.shapeBackground = () => true; \ No newline at end of file +DisplaySystem.shapeBackground = () => true; diff --git a/src/js/game/systems/filter.js b/src/js/game/systems/filter.js index 541c1e06..ff0650b4 100644 --- a/src/js/game/systems/filter.js +++ b/src/js/game/systems/filter.js @@ -84,6 +84,6 @@ export class FilterSystem extends GameSystemWithFilter { } FilterSystem.listToCheck = (entity, slot, item, filterComp, networkValue) => - networkValue.equals(BOOL_TRUE_SINGLETON) || networkValue.equals(item) ? - filterComp.pendingItemsToLeaveThrough : - filterComp.pendingItemsToReject; \ No newline at end of file + networkValue.equals(BOOL_TRUE_SINGLETON) || networkValue.equals(item) + ? filterComp.pendingItemsToLeaveThrough + : filterComp.pendingItemsToReject; diff --git a/src/js/game/systems/hub.js b/src/js/game/systems/hub.js index 39cdb6ba..f83780d1 100644 --- a/src/js/game/systems/hub.js +++ b/src/js/game/systems/hub.js @@ -35,23 +35,23 @@ export class HubSystem extends GameSystemWithFilter { } update() { - for (let i = 0; i < this.allEntities.length; ++i) { - // Set hub goal - const entity = this.allEntities[i]; - const pinsComp = entity.components.WiredPins; - pinsComp.slots[0].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition( - this.root.hubGoals.currentGoal.definition - ); - } + for (let i = 0; i < this.allEntities.length; ++i) { + // Set hub goal + const entity = this.allEntities[i]; + const pinsComp = entity.components.WiredPins; + pinsComp.slots[0].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition( + this.root.hubGoals.currentGoal.definition + ); } - /** - * - * @param {HTMLCanvasElement} canvas - * @param {CanvasRenderingContext2D} context - * @param {number} w - * @param {number} h - * @param {number} dpi - */ + } + /** + * + * @param {HTMLCanvasElement} canvas + * @param {CanvasRenderingContext2D} context + * @param {number} w + * @param {number} h + * @param {number} dpi + */ redrawHubBaseTexture(canvas, context, w, h, dpi) { // This method is quite ugly, please ignore it! @@ -197,4 +197,4 @@ export class HubSystem extends GameSystemWithFilter { originalH: HUB_SIZE_PIXELS * dpi, }); } -} \ No newline at end of file +} diff --git a/src/js/game/systems/item_acceptor.js b/src/js/game/systems/item_acceptor.js index ccd6f98f..7d1e8962 100644 --- a/src/js/game/systems/item_acceptor.js +++ b/src/js/game/systems/item_acceptor.js @@ -106,4 +106,4 @@ export class ItemAcceptorSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/item_processor.js b/src/js/game/systems/item_processor.js index f3480e07..685e103b 100644 --- a/src/js/game/systems/item_processor.js +++ b/src/js/game/systems/item_processor.js @@ -570,4 +570,4 @@ ItemProcessorSystem.canProcess = { return true; }, -}; \ No newline at end of file +}; diff --git a/src/js/game/systems/item_processor_overlays.js b/src/js/game/systems/item_processor_overlays.js index 453429d0..ffdf0e47 100644 --- a/src/js/game/systems/item_processor_overlays.js +++ b/src/js/game/systems/item_processor_overlays.js @@ -147,7 +147,7 @@ export class ItemProcessorOverlaysSystem extends GameSystem { } ItemProcessorOverlaysSystem.processorOverlayStatic = { - [enumItemProcessorRequirements.painterQuad]: function(parameters, chunk, entity, processorComp) { + [enumItemProcessorRequirements.painterQuad]: function (parameters, chunk, entity, processorComp) { this.drawConnectedSlotRequirement(parameters, entity, { drawIfFalse: true }); }, -}; \ No newline at end of file +}; diff --git a/src/js/game/systems/item_producer.js b/src/js/game/systems/item_producer.js index c09d6b40..a19aa3dc 100644 --- a/src/js/game/systems/item_producer.js +++ b/src/js/game/systems/item_producer.js @@ -25,4 +25,4 @@ export class ItemProducerSystem extends GameSystemWithFilter { ejectorComp.tryEject(0, network.currentValue); } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/lever.js b/src/js/game/systems/lever.js index b86ecb81..2724229c 100644 --- a/src/js/game/systems/lever.js +++ b/src/js/game/systems/lever.js @@ -45,4 +45,4 @@ export class LeverSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/logic_gate.js b/src/js/game/systems/logic_gate.js index 3130d6c8..23a1f8fa 100644 --- a/src/js/game/systems/logic_gate.js +++ b/src/js/game/systems/logic_gate.js @@ -104,9 +104,9 @@ export class LogicGateSystem extends GameSystemWithFilter { */ compute_AND(parameters) { assert(parameters.length === 2, "bad parameter count for AND"); - return isTruthyItem(parameters[0]) && isTruthyItem(parameters[1]) ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; + return isTruthyItem(parameters[0]) && isTruthyItem(parameters[1]) + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; } /** @@ -123,9 +123,9 @@ export class LogicGateSystem extends GameSystemWithFilter { */ compute_XOR(parameters) { assert(parameters.length === 2, "bad parameter count for XOR"); - return isTruthyItem(parameters[0]) !== isTruthyItem(parameters[1]) ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; + return isTruthyItem(parameters[0]) !== isTruthyItem(parameters[1]) + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; } /** @@ -134,9 +134,9 @@ export class LogicGateSystem extends GameSystemWithFilter { */ compute_OR(parameters) { assert(parameters.length === 2, "bad parameter count for OR"); - return isTruthyItem(parameters[0]) || isTruthyItem(parameters[1]) ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; + return isTruthyItem(parameters[0]) || isTruthyItem(parameters[1]) + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; } /** @@ -226,12 +226,12 @@ export class LogicGateSystem extends GameSystemWithFilter { const definition = /** @type {ShapeItem} */ (item).definition; const result = this.root.shapeDefinitionMgr.shapeActionCutHalf(definition); return [ - result[0].isEntirelyEmpty() ? - null : - this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]), - result[1].isEntirelyEmpty() ? - null : - this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]), + result[0].isEntirelyEmpty() + ? null + : this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]), + result[1].isEntirelyEmpty() + ? null + : this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]), ]; } @@ -258,9 +258,9 @@ export class LogicGateSystem extends GameSystemWithFilter { lowerLayers.length > 0 ? new ShapeDefinition({ layers: lowerLayers }) : null; return [ - lowerLayerDefinition ? - this.root.shapeDefinitionMgr.getShapeItemFromDefinition(lowerLayerDefinition) : - null, + lowerLayerDefinition + ? this.root.shapeDefinitionMgr.getShapeItemFromDefinition(lowerLayerDefinition) + : null, this.root.shapeDefinitionMgr.getShapeItemFromDefinition(upperLayerDefinition), ]; } @@ -340,32 +340,28 @@ export class LogicGateSystem extends GameSystemWithFilter { } switch (itemA.getItemType()) { - case "shape": - { - return /** @type {ShapeItem} */ (itemA).definition.getHash() === - /** @type {ShapeItem} */ - (itemB).definition.getHash() ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; - } - case "color": - { - return /** @type {ColorItem} */ (itemA).color === /** @type {ColorItem} */ (itemB).color ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; - } + case "shape": { + return /** @type {ShapeItem} */ (itemA).definition.getHash() === + /** @type {ShapeItem} */ + (itemB).definition.getHash() + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; + } + case "color": { + return /** @type {ColorItem} */ (itemA).color === /** @type {ColorItem} */ (itemB).color + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; + } - case "boolean": - { - return /** @type {BooleanItem} */ (itemA).value === /** @type {BooleanItem} */ (itemB).value ? - BOOL_TRUE_SINGLETON : - BOOL_FALSE_SINGLETON; - } + case "boolean": { + return /** @type {BooleanItem} */ (itemA).value === /** @type {BooleanItem} */ (itemB).value + ? BOOL_TRUE_SINGLETON + : BOOL_FALSE_SINGLETON; + } - default: - { - assertAlways(false, "Bad item type: " + itemA.getItemType()); - } + default: { + assertAlways(false, "Bad item type: " + itemA.getItemType()); + } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/map_resources.js b/src/js/game/systems/map_resources.js index f475d137..c433eecd 100644 --- a/src/js/game/systems/map_resources.js +++ b/src/js/game/systems/map_resources.js @@ -132,4 +132,4 @@ export class MapResourcesSystem extends GameSystem { context.fillRect(0, 1, 1, h); } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/static_map_entity.js b/src/js/game/systems/static_map_entity.js index 9c30beab..53db1b26 100644 --- a/src/js/game/systems/static_map_entity.js +++ b/src/js/game/systems/static_map_entity.js @@ -111,4 +111,4 @@ export class StaticMapEntitySystem extends GameSystem { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/storage.js b/src/js/game/systems/storage.js index b132d3cd..8b39346c 100644 --- a/src/js/game/systems/storage.js +++ b/src/js/game/systems/storage.js @@ -102,4 +102,4 @@ export class StorageSystem extends GameSystemWithFilter { context.globalAlpha = 1; } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/underground_belt.js b/src/js/game/systems/underground_belt.js index df849882..b4d0f0d1 100644 --- a/src/js/game/systems/underground_belt.js +++ b/src/js/game/systems/underground_belt.js @@ -254,7 +254,8 @@ export class UndergroundBeltSystem extends GameSystemWithFilter { // Search in the direction of the tunnel for ( - let searchOffset = 0; searchOffset < globalConfig.undergroundBeltMaxTilesByTier[undergroundComp.tier]; + let searchOffset = 0; + searchOffset < globalConfig.undergroundBeltMaxTilesByTier[undergroundComp.tier]; ++searchOffset ) { currentTile = currentTile.add(searchVector); @@ -349,4 +350,4 @@ export class UndergroundBeltSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/systems/wire.js b/src/js/game/systems/wire.js index 0d767bfb..1e735515 100644 --- a/src/js/game/systems/wire.js +++ b/src/js/game/systems/wire.js @@ -217,10 +217,12 @@ export class WireSystem extends GameSystemWithFilter { currentNetwork.uid, ")" ); - const entitiesToVisit = [{ - entity: initialEntity, - slot, - }, ]; + const entitiesToVisit = [ + { + entity: initialEntity, + slot, + }, + ]; /** * Once we occur a wire, we store its variant so we don't connect to @@ -245,13 +247,14 @@ export class WireSystem extends GameSystemWithFilter { //// WIRE if (wireComp) { // Sanity check - assert(!wireComp.linkedNetwork || wireComp.linkedNetwork === currentNetwork, + assert( + !wireComp.linkedNetwork || wireComp.linkedNetwork === currentNetwork, "Mismatching wire network on wire entity " + - (wireComp.linkedNetwork ? wireComp.linkedNetwork.uid : "") + - " vs " + - currentNetwork.uid + - " @ " + - staticComp.origin.toString() + (wireComp.linkedNetwork ? wireComp.linkedNetwork.uid : "") + + " vs " + + currentNetwork.uid + + " @ " + + staticComp.origin.toString() ); if (!wireComp.linkedNetwork) { @@ -287,11 +290,12 @@ export class WireSystem extends GameSystemWithFilter { } // Sanity check - assert(!slot.linkedNetwork || slot.linkedNetwork === currentNetwork, + assert( + !slot.linkedNetwork || slot.linkedNetwork === currentNetwork, "Mismatching wire network on pin slot entity " + - (slot.linkedNetwork ? slot.linkedNetwork.uid : "") + - " vs " + - currentNetwork.uid + (slot.linkedNetwork ? slot.linkedNetwork.uid : "") + + " vs " + + currentNetwork.uid ); if (!slot.linkedNetwork) { // This one is new @@ -758,4 +762,4 @@ export class WireSystem extends GameSystemWithFilter { } } -WireSystem.getForwardedTile = (tunnelComp, staticComp, offset) => staticComp.origin.add(offset); \ No newline at end of file +WireSystem.getForwardedTile = (tunnelComp, staticComp, offset) => staticComp.origin.add(offset); diff --git a/src/js/game/systems/wired_pins.js b/src/js/game/systems/wired_pins.js index c2e0751a..55e689d8 100644 --- a/src/js/game/systems/wired_pins.js +++ b/src/js/game/systems/wired_pins.js @@ -121,9 +121,11 @@ export class WiredPinsSystem extends GameSystemWithFilter { if (collidingEntity) { const staticComp = collidingEntity.components.StaticMapEntity; const data = getBuildingDataFromCode(staticComp.code); - if (!collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable( + if ( + !collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable( data.variant - )) { + ) + ) { return true; } } @@ -193,7 +195,9 @@ export class WiredPinsSystem extends GameSystemWithFilter { const worldPos = tile.toWorldSpaceCenterOfTile(); // Culling - if (!parameters.visibleRect.containsCircle(worldPos.x, worldPos.y, globalConfig.halfTileSize)) { + if ( + !parameters.visibleRect.containsCircle(worldPos.x, worldPos.y, globalConfig.halfTileSize) + ) { continue; } @@ -244,4 +248,4 @@ export class WiredPinsSystem extends GameSystemWithFilter { } } } -} \ No newline at end of file +} diff --git a/src/js/game/theme.js b/src/js/game/theme.js index f9dec2f0..330fa0c8 100644 --- a/src/js/game/theme.js +++ b/src/js/game/theme.js @@ -7,4 +7,4 @@ export let THEME = VANILLA_THEMES.light; export function applyGameTheme(id) { THEME = shapezAPI.themes[id]; -} \ No newline at end of file +} diff --git a/src/js/game/time/game_time.js b/src/js/game/time/game_time.js index fcbf3224..07b224a7 100644 --- a/src/js/game/time/game_time.js +++ b/src/js/game/time/game_time.js @@ -197,4 +197,4 @@ export class GameTime extends BasicSerializableObject { this.speed.initializeAfterDeserialize(this.root); } -} \ No newline at end of file +} diff --git a/src/js/game/tutorial_goals_mappings.js b/src/js/game/tutorial_goals_mappings.js index b803c081..c70f8696 100644 --- a/src/js/game/tutorial_goals_mappings.js +++ b/src/js/game/tutorial_goals_mappings.js @@ -28,31 +28,15 @@ const typed = x => x; * @enum {TutorialGoalReward?} */ export const enumHubGoalRewardsToContentUnlocked = { - [enumHubGoalRewards.reward_cutter_and_trash]: typed([ - [MetaCutterBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_rotater]: typed([ - [MetaRotaterBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_painter]: typed([ - [MetaPainterBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_mixer]: typed([ - [MetaMixerBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_stacker]: typed([ - [MetaStackerBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_balancer]: typed([ - [MetaBalancerBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_tunnel]: typed([ - [MetaUndergroundBeltBuilding, defaultBuildingVariant] - ]), + [enumHubGoalRewards.reward_cutter_and_trash]: typed([[MetaCutterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_rotater]: typed([[MetaRotaterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_painter]: typed([[MetaPainterBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_mixer]: typed([[MetaMixerBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_stacker]: typed([[MetaStackerBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_balancer]: typed([[MetaBalancerBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_tunnel]: typed([[MetaUndergroundBeltBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_rotater_ccw]: typed([ - [MetaRotaterBuilding, MetaRotaterBuilding.variants.ccw] - ]), + [enumHubGoalRewards.reward_rotater_ccw]: typed([[MetaRotaterBuilding, MetaRotaterBuilding.variants.ccw]]), [enumHubGoalRewards.reward_rotater_180]: typed([ [MetaRotaterBuilding, MetaRotaterBuilding.variants.rotate180], ]), @@ -65,34 +49,20 @@ export const enumHubGoalRewardsToContentUnlocked = { [enumHubGoalRewards.reward_splitter]: typed([ [MetaBalancerBuilding, MetaBalancerBuilding.variants.splitter], ]), - [enumHubGoalRewards.reward_merger]: typed([ - [MetaBalancerBuilding, MetaBalancerBuilding.variants.merger] - ]), - [enumHubGoalRewards.reward_cutter_quad]: typed([ - [MetaCutterBuilding, MetaCutterBuilding.variants.quad] - ]), + [enumHubGoalRewards.reward_merger]: typed([[MetaBalancerBuilding, MetaBalancerBuilding.variants.merger]]), + [enumHubGoalRewards.reward_cutter_quad]: typed([[MetaCutterBuilding, MetaCutterBuilding.variants.quad]]), [enumHubGoalRewards.reward_painter_double]: typed([ [MetaPainterBuilding, MetaPainterBuilding.variants.double], ]), - [enumHubGoalRewards.reward_storage]: typed([ - [MetaStorageBuilding, defaultBuildingVariant] - ]), + [enumHubGoalRewards.reward_storage]: typed([[MetaStorageBuilding, defaultBuildingVariant]]), - [enumHubGoalRewards.reward_belt_reader]: typed([ - [MetaReaderBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_display]: typed([ - [MetaDisplayBuilding, defaultBuildingVariant] - ]), + [enumHubGoalRewards.reward_belt_reader]: typed([[MetaReaderBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_display]: typed([[MetaDisplayBuilding, defaultBuildingVariant]]), [enumHubGoalRewards.reward_constant_signal]: typed([ [MetaConstantSignalBuilding, defaultBuildingVariant], ]), - [enumHubGoalRewards.reward_logic_gates]: typed([ - [MetaLogicGateBuilding, defaultBuildingVariant] - ]), - [enumHubGoalRewards.reward_filter]: typed([ - [MetaFilterBuilding, defaultBuildingVariant] - ]), + [enumHubGoalRewards.reward_logic_gates]: typed([[MetaLogicGateBuilding, defaultBuildingVariant]]), + [enumHubGoalRewards.reward_filter]: typed([[MetaFilterBuilding, defaultBuildingVariant]]), [enumHubGoalRewards.reward_virtual_processing]: null, [enumHubGoalRewards.reward_wires_painter_and_levers]: typed([ @@ -122,4 +92,4 @@ if (G_IS_DEV) { assertAlways(false, "Translation for reward " + rewardId + "missing"); } } -} \ No newline at end of file +} diff --git a/src/js/languages.js b/src/js/languages.js index 40c9570b..4cc39f9b 100644 --- a/src/js/languages.js +++ b/src/js/languages.js @@ -124,4 +124,4 @@ export const LANGUAGES = { code: "hu", region: "", }, -}; \ No newline at end of file +}; diff --git a/src/js/main.js b/src/js/main.js index 02ea467d..0608dbf2 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -15,7 +15,7 @@ import { addVanillaSystemsToAPI } from "./game/game_system_manager"; import { addVanillaGameModesToAPI } from "./game/game_mode_registry"; import { getIPCRenderer } from "./core/utils"; const logger = createLogger("main"); -window.onload = async() => { +window.onload = async () => { if (window.coreThreadLoadedCb) { logger.log("Javascript parsed, calling html thread"); window.coreThreadLoadedCb(); @@ -188,4 +188,4 @@ window.onload = async() => { app.boot(); } bootApp(); -}; \ No newline at end of file +}; diff --git a/src/js/modloader/mod.js b/src/js/modloader/mod.js index 372579ef..8c03675e 100644 --- a/src/js/modloader/mod.js +++ b/src/js/modloader/mod.js @@ -941,7 +941,8 @@ export class ShapezAPI { sourceImage.crossOrigin = "anonymous"; sourceImage.onload = () => { // @ts-ignore - Loader.internalParseAtlas({ + Loader.internalParseAtlas( + { meta: atlasData.atlasData.meta, sourceData: atlasData.atlasData.frames, }, @@ -1019,4 +1020,4 @@ export class ShapezAPI { clickDetector.click.add(clickHandler); this.clickDetectors.push(clickDetector); } -} \ No newline at end of file +} diff --git a/src/js/modloader/modmanager.js b/src/js/modloader/modmanager.js index da5ea7cc..1e9cfc27 100644 --- a/src/js/modloader/modmanager.js +++ b/src/js/modloader/modmanager.js @@ -112,14 +112,14 @@ export class ModManager { }); } else return Promise.race([ - new Promise((resolve, reject) => { - setTimeout(reject, 60 * 1000); - }), - fetch(url, { - method: "GET", - cache: "no-cache", - }), - ]) + new Promise((resolve, reject) => { + setTimeout(reject, 60 * 1000); + }), + fetch(url, { + method: "GET", + cache: "no-cache", + }), + ]) .then(res => res.text()) .catch(err => { assert(this, "Failed to load mod:", err); @@ -208,9 +208,9 @@ export class ModManager { if (isMissingDependecie) { console.warn( "Mod with mod id: " + - mod.id + - " is disabled because it's missings the dependecie " + - missingDependecie + mod.id + + " is disabled because it's missings the dependecie " + + missingDependecie ); continue; } else sorter.add(id, mod.dependencies); @@ -259,4 +259,4 @@ export class ModManager { if (this.modPack && this.modPack.mods) mod.main(this.modPack.mods.find(mod => mod.id === id).config); else mod.main(); } -} \ No newline at end of file +} diff --git a/src/js/modloader/overwrite.js b/src/js/modloader/overwrite.js index 4617871d..c876b33c 100644 --- a/src/js/modloader/overwrite.js +++ b/src/js/modloader/overwrite.js @@ -15,4 +15,4 @@ export function matchOverwriteRecursiveSettings(dest, src) { console.log("Unknown type:", typeof data, "in key", key); } } -} \ No newline at end of file +} diff --git a/src/js/platform/game_analytics.js b/src/js/platform/game_analytics.js index 328b532d..498e68a5 100644 --- a/src/js/platform/game_analytics.js +++ b/src/js/platform/game_analytics.js @@ -35,4 +35,4 @@ export class GameAnalyticsInterface { * @param {number} level */ handleUpgradeUnlocked(id, level) {} -} \ No newline at end of file +} diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 2348ffd4..dcb5d84b 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -24,7 +24,8 @@ export const enumCategories = { debug: "debug", }; -export const uiScales = [{ +export const uiScales = [ + { id: "super_small", size: 0.6, }, @@ -46,7 +47,8 @@ export const uiScales = [{ }, ]; -export const scrollWheelSensitivities = [{ +export const scrollWheelSensitivities = [ + { id: "super_slow", scale: 0.25, }, @@ -68,7 +70,8 @@ export const scrollWheelSensitivities = [{ }, ]; -export const movementSpeeds = [{ +export const movementSpeeds = [ + { id: "super_slow", multiplier: 0.25, }, @@ -94,7 +97,8 @@ export const movementSpeeds = [{ }, ]; -export const autosaveIntervals = [{ +export const autosaveIntervals = [ + { id: "one_minute", seconds: 60, }, @@ -150,9 +154,9 @@ export const allApplicationSettings = () => { category: enumCategories.userInterface, restartRequired: false, changeCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ (app, id) => app.updateAfterUiScaleChanged(), }), @@ -208,17 +212,17 @@ export const allApplicationSettings = () => { category: enumCategories.userInterface, restartRequired: false, changeCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ (app, id) => { - applyGameTheme(id); - document.documentElement.setAttribute("data-theme", id); - }, + applyGameTheme(id); + document.documentElement.setAttribute("data-theme", id); + }, enabledCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ app => app.restrictionMgr.getHasExtendedSettings(), }), @@ -229,9 +233,9 @@ export const allApplicationSettings = () => { category: enumCategories.advanced, restartRequired: false, changeCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ (app, id) => null, }), @@ -242,9 +246,9 @@ export const allApplicationSettings = () => { category: enumCategories.advanced, restartRequired: false, changeCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ (app, id) => app.updateAfterUiScaleChanged(), }), @@ -278,9 +282,9 @@ export const allApplicationSettings = () => { restartRequired: false, changeCb: (app, id) => {}, enabledCb: - /** - * @param {Application} app - */ + /** + * @param {Application} app + */ app => app.restrictionMgr.getHasExtendedSettings(), }), @@ -372,7 +376,7 @@ export class ApplicationSettings extends ReadWriteProxy { } }) - .then(() => this.writeAsync()); + .then(() => this.writeAsync()); } save() { @@ -510,12 +514,12 @@ export class ApplicationSettings extends ReadWriteProxy { * @param {string} id */ resetKeybindingOverride(id) { - delete this.getAllSettings().keybindingOverrides[id]; - return this.writeAsync(); - } - /** - * Resets all keybinding overrides - */ + delete this.getAllSettings().keybindingOverrides[id]; + return this.writeAsync(); + } + /** + * Resets all keybinding overrides + */ resetKeybindingOverrides() { this.getAllSettings().keybindingOverrides = {}; return this.writeAsync(); @@ -537,14 +541,14 @@ export class ApplicationSettings extends ReadWriteProxy { if (!setting.validate(storedValue)) { return ExplainedResult.bad( "Bad setting value for " + - setting.id + - ": " + - storedValue + - " @ settings version " + - data.version + - " (latest is " + - this.getCurrentVersion() + - ")" + setting.id + + ": " + + storedValue + + " @ settings version " + + data.version + + " (latest is " + + this.getCurrentVersion() + + ")" ); } } @@ -708,4 +712,4 @@ export class ApplicationSettings extends ReadWriteProxy { return ExplainedResult.good(); } -} \ No newline at end of file +} diff --git a/src/js/profile/setting_types.js b/src/js/profile/setting_types.js index 80a335f4..9a1e0c03 100644 --- a/src/js/profile/setting_types.js +++ b/src/js/profile/setting_types.js @@ -117,7 +117,8 @@ export class BaseSetting { export class EnumSetting extends BaseSetting { constructor( - id, { + id, + { options, valueGetter, textGetter, @@ -145,8 +146,8 @@ export class EnumSetting extends BaseSetting { * @param {Application} app */ getHtml(app) { - const available = this.getIsAvailable(app); - return ` + const available = this.getIsAvailable(app); + return `
${available ? "" : `${T.demo.settingNotAvailable}`}
@@ -362,4 +363,4 @@ export class RangeSetting extends BaseSetting { validate(value) { return typeof value === "number" && value >= this.minValue && value <= this.maxValue; } -} \ No newline at end of file +} diff --git a/src/js/savegame/savegame.js b/src/js/savegame/savegame.js index dcb7c258..a6dfac3b 100644 --- a/src/js/savegame/savegame.js +++ b/src/js/savegame/savegame.js @@ -151,12 +151,12 @@ export class Savegame extends ReadWriteProxy { * @returns {boolean} */ isSaveable() { - return true; - } - /** - * Returns the statistics of the savegame - * @returns {import("./savegame_typedefs").SavegameStats} - */ + return true; + } + /** + * Returns the statistics of the savegame + * @returns {import("./savegame_typedefs").SavegameStats} + */ getStatistics() { return this.currentData.stats; } @@ -283,4 +283,4 @@ export class Savegame extends ReadWriteProxy { } return super.writeAsync(); } -} \ No newline at end of file +} diff --git a/src/js/savegame/savegame_interface_registry.js b/src/js/savegame/savegame_interface_registry.js index 3e09fe21..3edbdb7e 100644 --- a/src/js/savegame/savegame_interface_registry.js +++ b/src/js/savegame/savegame_interface_registry.js @@ -48,4 +48,4 @@ export function getSavegameInterface(savegame) { } return new interfaceClass(savegame); -} \ No newline at end of file +} diff --git a/src/js/savegame/savegame_manager.js b/src/js/savegame/savegame_manager.js index e3ae5024..1634ac88 100644 --- a/src/js/savegame/savegame_manager.js +++ b/src/js/savegame/savegame_manager.js @@ -150,7 +150,8 @@ export class SavegameManager extends ReadWriteProxy { this.updateAfterSavegamesChanged(); return new Savegame( - this.app, { + this.app, + { internalId: id, metaDataRef: metaData, }, @@ -243,4 +244,4 @@ export class SavegameManager extends ReadWriteProxy { return this.updateAfterSavegamesChanged(); }); } -} \ No newline at end of file +} diff --git a/src/js/savegame/savegame_serializer.js b/src/js/savegame/savegame_serializer.js index 7fb0d834..eeb01a4a 100644 --- a/src/js/savegame/savegame_serializer.js +++ b/src/js/savegame/savegame_serializer.js @@ -142,4 +142,4 @@ export class SavegameSerializer { return ExplainedResult.good(); } -} \ No newline at end of file +} diff --git a/src/js/savegame/savegame_typedefs.js b/src/js/savegame/savegame_typedefs.js index e7c082e9..5052ad13 100644 --- a/src/js/savegame/savegame_typedefs.js +++ b/src/js/savegame/savegame_typedefs.js @@ -35,4 +35,4 @@ * }} SavegamesData */ -export default {}; \ No newline at end of file +export default {}; diff --git a/src/js/savegame/schemas/1006.js b/src/js/savegame/schemas/1006.js index 3956c9de..f7ea54f4 100644 --- a/src/js/savegame/schemas/1006.js +++ b/src/js/savegame/schemas/1006.js @@ -307,4 +307,4 @@ export class SavegameInterface_V1006 extends SavegameInterface_V1005 { entity.components.StaticMapEntity = newStaticComp; } -} \ No newline at end of file +} diff --git a/src/js/savegame/schemas/ML01.js b/src/js/savegame/schemas/ML01.js index 6abfefd6..5e35cc44 100644 --- a/src/js/savegame/schemas/ML01.js +++ b/src/js/savegame/schemas/ML01.js @@ -182,4 +182,4 @@ export class SavegameInterface_ML01 extends SavegameInterface_V1007 { codes[dump.entities[i].components.StaticMapEntity.code]; } } -} \ No newline at end of file +} diff --git a/src/js/savegame/serialization.js b/src/js/savegame/serialization.js index 5eb10dd8..799a5710 100644 --- a/src/js/savegame/serialization.js +++ b/src/js/savegame/serialization.js @@ -350,4 +350,4 @@ export function extendSchema(base, newOne) { result[key] = newOne[key]; } return result; -} \ No newline at end of file +} diff --git a/src/js/savegame/serialization_data_types.js b/src/js/savegame/serialization_data_types.js index baf2b104..9d3b689f 100644 --- a/src/js/savegame/serialization_data_types.js +++ b/src/js/savegame/serialization_data_types.js @@ -699,7 +699,7 @@ export class TypeClassData extends BaseDataType { for (let i = 0; i < entries.length; ++i) { const entry = entries[i]; options.push( - schemaToJsonSchema( /** @type {typeof BasicSerializableObject} */ (entry).getCachedSchema()) + schemaToJsonSchema(/** @type {typeof BasicSerializableObject} */ (entry).getCachedSchema()) ); } return { oneOf: options }; @@ -1197,7 +1197,8 @@ export class TypeNullable extends BaseDataType { getAsJsonSchemaUncached() { return { - oneOf: [{ + oneOf: [ + { type: "null", }, this.wrapped.getAsJsonSchema(), @@ -1291,4 +1292,4 @@ export class TypeStructuredObject extends BaseDataType { } return "structured[" + props.join(",") + "]"; } -} \ No newline at end of file +} diff --git a/src/js/states/ingame.js b/src/js/states/ingame.js index 561ccf90..c7c1fa4a 100644 --- a/src/js/states/ingame.js +++ b/src/js/states/ingame.js @@ -468,4 +468,4 @@ export class InGameState extends GameState { return this.currentSavePromise; } -} \ No newline at end of file +} diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index d6ac64bf..b48c90c4 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -155,7 +155,8 @@ export class KeybindingsState extends TextualGameState { resetBindings() { const { reset } = this.dialogs.showWarning( T.dialogs.resetKeybindingsConfirmation.title, - T.dialogs.resetKeybindingsConfirmation.desc, ["cancel:good", "reset:bad"] + T.dialogs.resetKeybindingsConfirmation.desc, + ["cancel:good", "reset:bad"] ); reset.add(() => { @@ -169,4 +170,4 @@ export class KeybindingsState extends TextualGameState { getDefaultPreviousState() { return "SettingsState"; } -} \ No newline at end of file +} diff --git a/src/js/states/main_menu.js b/src/js/states/main_menu.js index cbc15aae..1165780f 100644 --- a/src/js/states/main_menu.js +++ b/src/js/states/main_menu.js @@ -32,15 +32,15 @@ export class MainMenuState extends GameState { } getInnerHTML() { - const bannerHtml = ` + const bannerHtml = `

${T.demoBanners.title}

${T.demoBanners.intro}

Get the shapez.io standalone! `; - const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive(); + const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive(); - return ` + return `
@@ -667,4 +667,4 @@ export class MainMenuState extends GameState { MainMenuState.extraTopButtons = []; MainMenuState.extraSmallButtons = []; -MainMenuState.extraTrackClicks = []; \ No newline at end of file +MainMenuState.extraTrackClicks = []; diff --git a/src/js/states/preload.js b/src/js/states/preload.js index 1026a7df..2f7b846b 100644 --- a/src/js/states/preload.js +++ b/src/js/states/preload.js @@ -68,43 +68,43 @@ export class PreloadState extends GameState { } startLoading() { - this.setStatus("Booting") + this.setStatus("Booting") .then(() => this.setStatus("Creating platform wrapper")) - .then(() => this.app.platformWrapper.initialize()) + .then(() => this.app.platformWrapper.initialize()) .then(() => this.setStatus("Initializing local storage")) - .then(() => { - const wrapper = this.app.platformWrapper; - if (wrapper instanceof PlatformWrapperImplBrowser) { - try { - window.localStorage.setItem("local_storage_test", "1"); - window.localStorage.removeItem("local_storage_test"); - } catch (ex) { - logger.error("Failed to read/write local storage:", ex); - return new Promise(() => { - alert(`Your brower does not support thirdparty cookies or you have disabled it in your security settings.\n\n + .then(() => { + const wrapper = this.app.platformWrapper; + if (wrapper instanceof PlatformWrapperImplBrowser) { + try { + window.localStorage.setItem("local_storage_test", "1"); + window.localStorage.removeItem("local_storage_test"); + } catch (ex) { + logger.error("Failed to read/write local storage:", ex); + return new Promise(() => { + alert(`Your brower does not support thirdparty cookies or you have disabled it in your security settings.\n\n In Chrome this setting is called "Block third-party cookies and site data".\n\n Please allow third party cookies and then reload the page.`); - // Never return - }); - } + // Never return + }); } - }) + } + }) .then(() => this.setStatus("Creating storage")) - .then(() => { - return this.app.storage.initialize(); - }) + .then(() => { + return this.app.storage.initialize(); + }) .then(() => this.setStatus("Initializing libraries")) - .then(() => this.app.analytics.initialize()) - .then(() => this.app.gameAnalytics.initialize()) + .then(() => this.app.analytics.initialize()) + .then(() => this.app.gameAnalytics.initialize()) .then(() => this.setStatus("Initializing settings")) - .then(() => { - return this.app.settings.initialize(); - }) + .then(() => { + return this.app.settings.initialize(); + }) .then(() => { // Initialize fullscreen @@ -114,84 +114,84 @@ export class PreloadState extends GameState { }) .then(() => this.setStatus("Initializing language")) - .then(() => { - if (this.app.settings.getLanguage() === "auto-detect") { - const language = autoDetectLanguageId(); - logger.log("Setting language to", language); - return this.app.settings.updateLanguage(language); - } - }) - .then(() => { - const language = this.app.settings.getLanguage(); - updateApplicationLanguage(language); - }) + .then(() => { + if (this.app.settings.getLanguage() === "auto-detect") { + const language = autoDetectLanguageId(); + logger.log("Setting language to", language); + return this.app.settings.updateLanguage(language); + } + }) + .then(() => { + const language = this.app.settings.getLanguage(); + updateApplicationLanguage(language); + }) .then(() => this.setStatus("Initializing sounds")) - .then(() => { - // Notice: We don't await the sounds loading itself - return this.app.sound.initialize(); - }) + .then(() => { + // Notice: We don't await the sounds loading itself + return this.app.sound.initialize(); + }) .then(() => { this.app.backgroundResourceLoader.startLoading(); }) .then(() => this.setStatus("Initializing restrictions")) - .then(() => { - return this.app.restrictionMgr.initialize(); - }) + .then(() => { + return this.app.restrictionMgr.initialize(); + }) .then(() => this.setStatus("Initializing savegame")) - .then(() => { - return this.app.savegameMgr.initialize().catch(err => { - logger.error("Failed to initialize savegames:", err); - alert( - "Your savegames failed to load, it seems your data files got corrupted. I'm so sorry!\n\n(This can happen if your pc crashed while a game was saved).\n\nYou can try re-importing your savegames." - ); - return this.app.savegameMgr.writeAsync(); - }); - }) + .then(() => { + return this.app.savegameMgr.initialize().catch(err => { + logger.error("Failed to initialize savegames:", err); + alert( + "Your savegames failed to load, it seems your data files got corrupted. I'm so sorry!\n\n(This can happen if your pc crashed while a game was saved).\n\nYou can try re-importing your savegames." + ); + return this.app.savegameMgr.writeAsync(); + }); + }) .then(() => this.setStatus("Downloading resources")) - .then(() => { - return this.app.backgroundResourceLoader.getPromiseForBareGame(); - }) + .then(() => { + return this.app.backgroundResourceLoader.getPromiseForBareGame(); + }) .then(() => this.setStatus("Checking changelog")) - .then(() => { - if (G_IS_DEV && globalConfig.debug.disableUpgradeNotification) { + .then(() => { + if (G_IS_DEV && globalConfig.debug.disableUpgradeNotification) { + return; + } + + return this.app.storage + .readFileAsync("lastversion.bin") + .catch(err => { + logger.warn("Failed to read lastversion:", err); + return G_BUILD_VERSION; + }) + .then(version => { + logger.log("Last version:", version, "App version:", G_BUILD_VERSION); + this.app.storage.writeFileAsync("lastversion.bin", G_BUILD_VERSION); + return version; + }) + .then(version => { + let changelogEntries = []; + logger.log("Last seen version:", version); + + for (let i = 0; i < CHANGELOG.length; ++i) { + if (CHANGELOG[i].version === version) { + break; + } + changelogEntries.push(CHANGELOG[i]); + } + if (changelogEntries.length === 0) { return; } - return this.app.storage - .readFileAsync("lastversion.bin") - .catch(err => { - logger.warn("Failed to read lastversion:", err); - return G_BUILD_VERSION; - }) - .then(version => { - logger.log("Last version:", version, "App version:", G_BUILD_VERSION); - this.app.storage.writeFileAsync("lastversion.bin", G_BUILD_VERSION); - return version; - }) - .then(version => { - let changelogEntries = []; - logger.log("Last seen version:", version); - - for (let i = 0; i < CHANGELOG.length; ++i) { - if (CHANGELOG[i].version === version) { - break; - } - changelogEntries.push(CHANGELOG[i]); - } - if (changelogEntries.length === 0) { - return; - } - - let dialogHtml = T.dialogs.updateSummary.desc; - for (let i = 0; i < changelogEntries.length; ++i) { - const entry = changelogEntries[i]; - dialogHtml += ` + let dialogHtml = T.dialogs.updateSummary.desc; + for (let i = 0; i < changelogEntries.length; ++i) { + const entry = changelogEntries[i]; + dialogHtml += `
${entry.version} ${entry.date} @@ -316,4 +316,4 @@ export class PreloadState extends GameState { window.location.reload(); }); } -} \ No newline at end of file +} diff --git a/src/js/states/settings.js b/src/js/states/settings.js index a825023e..d5584c52 100644 --- a/src/js/states/settings.js +++ b/src/js/states/settings.js @@ -12,7 +12,7 @@ export class SettingsState extends TextualGameState { } getMainContentHTML() { - return `