1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Prettier and readded shapez.io logo

This commit is contained in:
DJ1TJOO 2021-02-26 16:29:37 +01:00
parent 31a6444bfc
commit 9f5ceff0bb
142 changed files with 1668 additions and 1645 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,6 +1,6 @@
// Removes the unit (px, %, etc) from a value // Removes the unit (px, %, etc) from a value
@function strip-unit($number) { @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 / ($number * 0 + 1);
} }
@return $number; @return $number;
@ -25,14 +25,14 @@
$impSuffix: "!important"; $impSuffix: "!important";
} }
$v1: D($v1); $v1: D($v1);
@if $v2 !="" { @if $v2 != "" {
$v2: D($v2); $v2: D($v2);
} }
@if $v3 !="" { @if $v3 != "" {
$v3: D($v3); $v3: D($v3);
} }
@if $v4 !="" { @if $v4 != "" {
$v4: D($v4); $v4: D($v4);
} }
#{$propName}: #{$v1} #{$v2} #{$v3} #{$v4} #{$impSuffix}; #{$propName}: #{$v1} #{$v2} #{$v3} #{$v4} #{$impSuffix};
} }

View File

@ -1,27 +1,6 @@
$buildings: belt, $buildings: belt, cutter, miner, mixer, painter, rotater, balancer, stacker, trash, underground_belt, wire,
cutter, constant_signal, logic_gate, lever, filter, wire_tunnel, display, virtual_processor, reader, storage,
miner, transistor, analyzer, comparator, item_producer;
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 { @each $building in $buildings {
[data-icon="building_icons/#{$building}.png"] { [data-icon="building_icons/#{$building}.png"] {
/* @load-async */ /* @load-async */
@ -29,41 +8,11 @@ item_producer;
} }
} }
$buildingsAndVariants: belt, $buildingsAndVariants: belt, balancer, underground_belt, underground_belt-tier2, miner, miner-chainable,
balancer, cutter, cutter-quad, rotater, rotater-ccw, stacker, mixer, painter-double, painter-quad, trash, storage,
underground_belt, reader, rotater-rotate180, display, constant_signal, wire, wire_tunnel, logic_gate-or, logic_gate-not,
underground_belt-tier2, logic_gate-xor, analyzer, virtual_processor-rotater, virtual_processor-unstacker, item_producer,
miner, virtual_processor-stacker, virtual_processor-painter, wire-second, painter, painter-mirrored, comparator;
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 { @each $building in $buildingsAndVariants {
[data-icon="building_tutorials/#{$building}.png"] { [data-icon="building_tutorials/#{$building}.png"] {
/* @load-async */ /* @load-async */
@ -108,9 +57,7 @@ comparator;
background-image: uiResource("res/ui/building_tutorials/virtual_processor-cutter.png") !important; background-image: uiResource("res/ui/building_tutorials/virtual_processor-cutter.png") !important;
} }
$icons: notification_saved, $icons: notification_saved, notification_success, notification_upgrade;
notification_success,
notification_upgrade;
@each $icon in $icons { @each $icon in $icons {
[data-icon="icons/#{$icon}.png"] { [data-icon="icons/#{$icon}.png"] {
/* @load-async */ /* @load-async */
@ -118,34 +65,8 @@ notification_upgrade;
} }
} }
$languages: en, $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,
de, th, hu, pl, ja, kor, no, pt-PT;
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 { @each $language in $languages {
[data-languageicon="#{$language}"] { [data-languageicon="#{$language}"] {
/* @load-async */ /* @load-async */
@ -153,7 +74,6 @@ pt-PT;
} }
} }
/* /*
PRICE PRICE
*/ */
@ -166,4 +86,4 @@ PRICE
.steam_2_npr { .steam_2_npr {
/* @load-async */ /* @load-async */
background-image: uiResource("get_on_steam.png") !important; background-image: uiResource("get_on_steam.png") !important;
} }

View File

@ -277,7 +277,7 @@
grid-row: 2 / 3; grid-row: 2 / 3;
@include SuperSmallText; @include SuperSmallText;
opacity: 0.5; opacity: 0.5;
>span { > span {
display: inline-flex; display: inline-flex;
@include S(max-width, 140px); @include S(max-width, 140px);
overflow: hidden; overflow: hidden;
@ -290,7 +290,7 @@
@include PlainText; @include PlainText;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
>span { > span {
display: inline-flex; display: inline-flex;
@include S(max-width, 140px); @include S(max-width, 140px);
overflow: hidden; overflow: hidden;
@ -429,7 +429,7 @@
$linkBg: #fdfdff; $linkBg: #fdfdff;
$linkBgHover: darken($linkBg, 2); $linkBgHover: darken($linkBg, 2);
$linkColor: #55586a; $linkColor: #55586a;
>.boxLink { > .boxLink {
display: grid; display: grid;
align-items: center; align-items: center;
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
@ -470,14 +470,14 @@
} }
} }
} }
>.sidelinks { > .sidelinks {
display: grid; display: grid;
align-items: flex-start; align-items: flex-start;
justify-content: flex-start; justify-content: flex-start;
grid-template-rows: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr;
@include S(grid-gap, 3px); @include S(grid-gap, 3px);
@include S(height, 60px); @include S(height, 60px);
>a { > a {
color: $linkColor; color: $linkColor;
background: $linkBg; background: $linkBg;
height: 100%; height: 100%;
@ -524,8 +524,8 @@
} }
} }
.footer { .footer {
>a, > a,
.sidelinks>a { .sidelinks > a {
background-color: $darkModeControlsBackground; background-color: $darkModeControlsBackground;
color: #eee; color: #eee;
&:hover { &:hover {
@ -534,7 +534,7 @@
} }
.author { .author {
color: #bdbdbd; color: #bdbdbd;
>a { > a {
color: white; color: white;
} }
} }
@ -543,4 +543,4 @@
} }
} }
} }
} }

View File

@ -1,36 +1,46 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<title>shapez.io - Build automated factories to build, combine and color shapes!</title>
<head> <!-- mobile stuff -->
<title>shapez.io - Build automated factories to build, combine and color shapes!</title> <meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no, viewport-fit=cover"
/>
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="320" />
<meta name="theme-color" content="#393747" />
<!-- mobile stuff --> <!-- seo -->
<meta name="format-detection" content="telephone=no" /> <meta name="copyright" content="2020 Tobias Springer IT Solutions and .io Games" />
<meta name="msapplication-tap-highlight" content="no" /> <meta name="author" content="Tobias Springer, tobias.springer1@gmail.com" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no, viewport-fit=cover" /> <meta
<meta name="HandheldFriendly" content="true" /> name="description"
<meta name="MobileOptimized" content="320" /> content="shapez.io is an open-source factory building game about combining and producing different types of shapes."
<meta name="theme-color" content="#393747" /> />
<meta
name="keywords"
content="shapes, .io games, factorio, incremental, upgrades, base building, open source"
/>
<meta property="og:title" content="shapez.io" />
<meta
property="og:description"
content="shapez.io is a fun factory base building game about combining shapes"
/>
<meta property="og:url" content="https://shapez.io/" />
<meta property="og:image" content="https://shapez.io/og_thumb.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:type" content="website" />
<!-- seo --> <!-- misc -->
<meta name="copyright" content="2020 Tobias Springer IT Solutions and .io Games" /> <meta http-equiv="Cache-Control" content="private, max-age=0, no-store, no-cache, must-revalidate" />
<meta name="author" content="Tobias Springer, tobias.springer1@gmail.com" /> <meta http-equiv="Expires" content="0" />
<meta name="description" content="shapez.io is an open-source factory building game about combining and producing different types of shapes." /> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<meta name="keywords" content="shapes, .io games, factorio, incremental, upgrades, base building, open source" /> <link rel="canonical" href="https://shapez.io" />
<meta property="og:title" content="shapez.io" /> </head>
<meta property="og:description" content="shapez.io is a fun factory base building game about combining shapes" />
<meta property="og:url" content="https://shapez.io/" />
<meta property="og:image" content="https://shapez.io/og_thumb.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:type" content="website" />
<!-- misc --> <body oncontextmenu="return false" style="background: #393747;"></body>
<meta http-equiv="Cache-Control" content="private, max-age=0, no-store, no-cache, must-revalidate" /> </html>
<meta http-equiv="Expires" content="0" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="canonical" href="https://shapez.io" />
</head>
<body oncontextmenu="return false" style="background: #393747"></body>
</html>

View File

@ -411,4 +411,4 @@ Application.states = {
KeybindingsState, KeybindingsState,
AboutState, AboutState,
ChangelogState, ChangelogState,
}; };

View File

@ -1,7 +1,8 @@
/** /**
* @type {Array<{version: string, date: string, entries: Array<String>}>} changelog * @type {Array<{version: string, date: string, entries: Array<String>}>} changelog
*/ */
export const CHANGELOG = [{ export const CHANGELOG = [
{
version: "1.2.3", version: "1.2.3",
date: "unreleased", date: "unreleased",
entries: [ entries: [
@ -314,4 +315,4 @@ export const CHANGELOG = [{
date: "21.05.2020", date: "21.05.2020",
entries: ["Initial release!"], entries: ["Initial release!"],
}, },
]; ];

View File

@ -77,4 +77,4 @@ export class AnimationFrame {
window.requestAnimationFrame(this.boundMethod); window.requestAnimationFrame(this.boundMethod);
} }
} }

View File

@ -20,7 +20,7 @@ function initAssert() {
* @param {Boolean} condition * @param {Boolean} condition
* @param {...String} failureMessage * @param {...String} failureMessage
*/ */
window.assert = function(condition, ...failureMessage) { window.assert = function (condition, ...failureMessage) {
if (!condition) { if (!condition) {
logger.error("assertion failed:", ...failureMessage); logger.error("assertion failed:", ...failureMessage);
if (!assertionErrorShown) { if (!assertionErrorShown) {
@ -32,4 +32,4 @@ function initAssert() {
}; };
} }
initAssert(); initAssert();

View File

@ -118,4 +118,4 @@ class AsynCompression {
} }
} }
export const asyncCompressor = new AsynCompression(); export const asyncCompressor = new AsynCompression();

View File

@ -47,4 +47,4 @@ export const atlasFiles = require
.keys() .keys()
.map(f => f.replace(/^\.\//gi, "")) .map(f => f.replace(/^\.\//gi, ""))
.map(f => require("../../../res_built/atlas/" + f)) .map(f => require("../../../res_built/atlas/" + f))
.map(data => new AtlasDefinition(data)); .map(data => new AtlasDefinition(data));

View File

@ -107,10 +107,10 @@ export class BackgroundResourcesLoader {
internalStartLoadingEssentialsForBareGame() { internalStartLoadingEssentialsForBareGame() {
logger.log("⏰ Start load: bare game"); logger.log("⏰ Start load: bare game");
this.internalLoadSpritesAndSounds( this.internalLoadSpritesAndSounds(
essentialBareGameSprites, essentialBareGameSprites,
essentialBareGameSounds, essentialBareGameSounds,
essentialBareGameAtlases essentialBareGameAtlases
) )
.then(() => this.internalPreloadCss("async-resources.scss")) .then(() => this.internalPreloadCss("async-resources.scss"))
.catch(err => { .catch(err => {
logger.warn("⏰ Failed to load essentials for bare game:", err); logger.warn("⏰ Failed to load essentials for bare game:", err);
@ -174,13 +174,13 @@ export class BackgroundResourcesLoader {
this.soundsLoaded.push(sounds[i]); this.soundsLoaded.push(sounds[i]);
promises.push( promises.push(
this.app.sound this.app.sound
.loadSound(sounds[i]) .loadSound(sounds[i])
.catch(err => { .catch(err => {
logger.warn("Failed to load sound:", sounds[i]); logger.warn("Failed to load sound:", sounds[i]);
}) })
.then(() => { .then(() => {
this.numAssetsLoaded++; this.numAssetsLoaded++;
}) })
); );
} }
@ -192,12 +192,12 @@ export class BackgroundResourcesLoader {
this.spritesLoaded.push(sprites[i]); this.spritesLoaded.push(sprites[i]);
promises.push( promises.push(
Loader.preloadCSSSprite(sprites[i]) Loader.preloadCSSSprite(sprites[i])
.catch(err => { .catch(err => {
logger.warn("Failed to load css sprite:", sprites[i]); logger.warn("Failed to load css sprite:", sprites[i]);
}) })
.then(() => { .then(() => {
this.numAssetsLoaded++; this.numAssetsLoaded++;
}) })
); );
} }
@ -205,28 +205,28 @@ export class BackgroundResourcesLoader {
const atlas = atlases[i]; const atlas = atlases[i];
promises.push( promises.push(
Loader.preloadAtlas(atlas) Loader.preloadAtlas(atlas)
.catch(err => { .catch(err => {
logger.warn("Failed to load atlas:", atlas.sourceFileName); logger.warn("Failed to load atlas:", atlas.sourceFileName);
}) })
.then(() => { .then(() => {
this.numAssetsLoaded++; this.numAssetsLoaded++;
}) })
); );
} }
return ( return (
Promise.all(promises) Promise.all(promises)
// // Remove some pressure by waiting a bit // // Remove some pressure by waiting a bit
// .then(() => { // .then(() => {
// return new Promise(resolve => { // return new Promise(resolve => {
// setTimeout(resolve, 200); // setTimeout(resolve, 200);
// }); // });
// }) // })
.then(() => { .then(() => {
this.numAssetsToLoadTotal = 0; this.numAssetsToLoadTotal = 0;
this.numAssetsLoaded = 0; this.numAssetsLoaded = 0;
}) })
); );
} }
} }

View File

@ -168,4 +168,4 @@ export class BufferMaintainer {
}); });
return canvas; return canvas;
} }
} }

View File

@ -17,4 +17,4 @@ export class DrawParameters {
/** @type {import("../game/root").GameRoot} */ /** @type {import("../game/root").GameRoot} */
this.root = root; this.root = root;
} }
} }

View File

@ -5,7 +5,7 @@ import { Rectangle } from "./rectangle";
const logger = createLogger("draw_utils"); const logger = createLogger("draw_utils");
export function initDrawUtils() { export function initDrawUtils() {
CanvasRenderingContext2D.prototype.beginRoundedRect = function(x, y, w, h, r) { CanvasRenderingContext2D.prototype.beginRoundedRect = function (x, y, w, h, r) {
this.beginPath(); this.beginPath();
if (r < 0.05) { if (r < 0.05) {
@ -28,7 +28,7 @@ export function initDrawUtils() {
this.arcTo(x, y, x + w, y, r); this.arcTo(x, y, x + w, y, r);
}; };
CanvasRenderingContext2D.prototype.beginCircle = function(x, y, r) { CanvasRenderingContext2D.prototype.beginCircle = function (x, y, r) {
this.beginPath(); this.beginPath();
if (r < 0.05) { if (r < 0.05) {
@ -113,4 +113,4 @@ export function drawSpriteClipped({ parameters, sprite, x, y, w, h, originalW, o
intersection.w, intersection.w,
intersection.h intersection.h
); );
} }

View File

@ -29,4 +29,4 @@ export let gItemRegistry = new Factory("item");
*/ */
export function initBuildingsByCategory(buildings) { export function initBuildingsByCategory(buildings) {
gBuildingsByCategory = buildings; gBuildingsByCategory = buildings;
} }

View File

@ -240,4 +240,4 @@ export class InputDistributor {
alt: event.altKey, alt: event.altKey,
}); });
} }
} }

View File

@ -222,4 +222,4 @@ class LoaderImpl {
} }
} }
export const Loader = new LoaderImpl(); export const Loader = new LoaderImpl();

View File

@ -111,9 +111,9 @@ export class ReadWriteProxy {
const checksum = decompressed.substring(0, 40); const checksum = decompressed.substring(0, 40);
const jsonString = decompressed.substr(40); const jsonString = decompressed.substr(40);
const desiredChecksum = checksum.startsWith(CRC_PREFIX) ? const desiredChecksum = checksum.startsWith(CRC_PREFIX)
computeCrc(jsonString + salt) : ? computeCrc(jsonString + salt)
sha1(jsonString + salt); : sha1(jsonString + salt);
if (desiredChecksum !== checksum) { if (desiredChecksum !== checksum) {
// Checksum mismatch // Checksum mismatch
@ -165,141 +165,141 @@ export class ReadWriteProxy {
// Start read request // Start read request
return ( return (
this.app.storage this.app.storage
.readFileAsync(this.filename) .readFileAsync(this.filename)
// Check for errors during read // Check for errors during read
.catch(err => { .catch(err => {
if (err === FILE_NOT_FOUND) { if (err === FILE_NOT_FOUND) {
logger.log("File not found, using default data"); logger.log("File not found, using default data");
// File not found or unreadable, assume default file // File not found or unreadable, assume default file
return Promise.resolve(null); 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");
} }
// Compare stored checksum with actual checksum return Promise.reject("file-error: " + err);
const checksum = decompressed.substring(0, 40); })
const jsonString = decompressed.substr(40);
const desiredChecksum = checksum.startsWith(CRC_PREFIX) ? // Decrypt data (if its encrypted)
computeCrc(jsonString + salt) : // @ts-ignore
sha1(jsonString + salt); .then(rawData => {
if (rawData == null) {
// So, the file has not been found, use default data
return JSON.stringify(compressObject(this.getDefaultData()));
}
if (desiredChecksum !== checksum) { if (rawData.startsWith(compressionPrefix)) {
// Checksum mismatch const decompressed = decompressX64(rawData.substr(compressionPrefix.length));
return Promise.reject( if (!decompressed) {
"bad-content / checksum-mismatch: " + desiredChecksum + " vs " + checksum // 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) { // Decompress
return Promise.reject("bad-content / missing-compression"); .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;
return rawData; })
})
// Parse JSON, this could throw but that's fine // Check version and migrate if required
.then(res => { .then(contents => {
try { if (contents.version > this.getCurrentVersion()) {
return JSON.parse(res); return Promise.reject("stored-data-is-newer");
} 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);
} }
}
return contents;
})
// Verify if (contents.version < this.getCurrentVersion()) {
.then(contents => { logger.log(
const verifyResult = this.internalVerifyEntry(contents); "Trying to migrate data object from version",
if (!verifyResult.result) { contents.version,
logger.error( "to",
"Read invalid data from", this.getCurrentVersion()
this.filename, );
"reason:", const migrationResult = this.migrate(contents); // modify in place
verifyResult.reason, if (migrationResult.isBad()) {
"contents:", return Promise.reject("migration-failed: " + migrationResult.reason);
contents }
); }
return Promise.reject("invalid-data: " + verifyResult.reason); return contents;
} })
return contents;
})
// Store // Verify
.then(contents => { .then(contents => {
this.currentData = contents; const verifyResult = this.internalVerifyEntry(contents);
logger.log("📄 Read data with version", this.currentData.version, "from", this.filename); if (!verifyResult.result) {
return contents; logger.error(
}) "Read invalid data from",
this.filename,
"reason:",
verifyResult.reason,
"contents:",
contents
);
return Promise.reject("invalid-data: " + verifyResult.reason);
}
return contents;
})
// Catchall // Store
.catch(err => { .then(contents => {
return Promise.reject("Failed to read " + this.filename + ": " + err); 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); return this.verify(data);
} }
} }

View File

@ -94,4 +94,4 @@ export class SingletonFactory {
getNumEntries() { getNumEntries() {
return this.entries.length; return this.entries.length;
} }
} }

View File

@ -97,7 +97,8 @@ export class StateManager {
this.app.analytics.trackStateEnter(key); this.app.analytics.trackStateEnter(key);
window.history.pushState({ window.history.pushState(
{
key, key,
}, },
key key
@ -117,4 +118,4 @@ export class StateManager {
getCurrentState() { getCurrentState() {
return this.currentState; return this.currentState;
} }
} }

View File

@ -153,4 +153,4 @@ export class TextualGameState extends GameState {
this.onEnter(payload); this.onEnter(payload);
} }
} }

View File

@ -334,9 +334,9 @@ export function formatBigNumberFull(num, divider = T.global.thousandsDivider) {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
export function waitNextFrame() { export function waitNextFrame() {
return new Promise(function(resolve) { return new Promise(function (resolve) {
window.requestAnimationFrame(function() { window.requestAnimationFrame(function () {
window.requestAnimationFrame(function() { window.requestAnimationFrame(function () {
resolve(); 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='.') * @param {string=} separator The decimal separator for numbers like 50.1 (separator='.')
*/ */
export function formatItemsPerSecond(speed, double = false, separator = T.global.decimalSeparator) { export function formatItemsPerSecond(speed, double = false, separator = T.global.decimalSeparator) {
return speed === 1.0 ? return speed === 1.0
T.ingame.buildingPlacement.infoTexts.oneItemPerSecond : ? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond
T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace( : T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace(
"<x>", "<x>",
round2Digits(speed).toString().replace(".", separator) round2Digits(speed).toString().replace(".", separator)
) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); ) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : "");
} }
/** /**
@ -781,4 +781,4 @@ export function getRomanNumber(number) {
romanLiteralsCache[number] = formatted; romanLiteralsCache[number] = formatted;
return formatted; return formatted;
} }

View File

@ -100,4 +100,4 @@ export class BaseItem extends BasicSerializableObject {
abstract; abstract;
return ""; return "";
} }
} }

View File

@ -165,4 +165,4 @@ export class Blueprint {
return anyPlaced; return anyPlaced;
}); });
} }
} }

View File

@ -33,7 +33,7 @@ export const gBuildingVariants = {
*/ */
export function registerBuildingVariant( export function registerBuildingVariant(
meta, meta,
variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */ , variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */,
rotationVariant = 0 rotationVariant = 0
) { ) {
// @ts-ignore // @ts-ignore
@ -67,4 +67,4 @@ export function getBuildingDataFromCode(code) {
*/ */
export function getCodeFromBuildingData(metaBuilding, variant, rotationVariant = 0) { export function getCodeFromBuildingData(metaBuilding, variant, rotationVariant = 0) {
return metaBuilding.getId() + "/" + variant + "/" + rotationVariant; return metaBuilding.getId() + "/" + variant + "/" + rotationVariant;
} }

View File

@ -117,33 +117,34 @@ export class MetaAnalyzerBuilding extends MetaBuilding {
MetaAnalyzerBuilding.setupEntityComponents = [ MetaAnalyzerBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.left,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.right, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.right,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.bottom, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.bottom,
}, type: enumPinSlotType.logicalAcceptor,
], },
}) ],
), })
),
entity => entity =>
entity.addComponent( entity.addComponent(
new LogicGateComponent({ new LogicGateComponent({
type: enumLogicGateType.analyzer, type: enumLogicGateType.analyzer,
}) })
), ),
]; ];
MetaAnalyzerBuilding.silhouetteColors = { MetaAnalyzerBuilding.silhouetteColors = {
@ -186,7 +187,8 @@ MetaAnalyzerBuilding.layerPreview = {
MetaAnalyzerBuilding.componentVariations = { MetaAnalyzerBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.left, direction: enumDirection.left,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -205,4 +207,4 @@ MetaAnalyzerBuilding.componentVariations = {
entity.components.LogicGate.type = enumLogicGateType.analyzer; entity.components.LogicGate.type = enumLogicGateType.analyzer;
}, },
}; };

View File

@ -130,27 +130,27 @@ export class MetaBalancerBuilding extends MetaBuilding {
MetaBalancerBuilding.setupEntityComponents = [ MetaBalancerBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [], // set later slots: [], // set later
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 1, inputsPerCharge: 1,
processorType: enumItemProcessorTypes.balancer, processorType: enumItemProcessorTypes.balancer,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [], // set later slots: [], // set later
renderFloatingItems: false, renderFloatingItems: false,
}) })
), ),
entity => entity.addComponent(new BeltUnderlaysComponent({ underlays: [] })), entity => entity.addComponent(new BeltUnderlaysComponent({ underlays: [] })),
]; ];
@ -297,7 +297,8 @@ MetaBalancerBuilding.silhouetteColors = {
MetaBalancerBuilding.componentVariations = { MetaBalancerBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
}, },
@ -319,7 +320,8 @@ MetaBalancerBuilding.componentVariations = {
}, },
[MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => { [MetaBalancerBuilding.variants.merger]: (entity, rotationVariant) => {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
}, },
@ -335,7 +337,8 @@ MetaBalancerBuilding.componentVariations = {
}, },
[MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => { [MetaBalancerBuilding.variants.mergerInverse]: (entity, rotationVariant) => {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
}, },
@ -352,12 +355,15 @@ MetaBalancerBuilding.componentVariations = {
[MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => { [MetaBalancerBuilding.variants.splitter]: (entity, rotationVariant) => {
{ {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ]); directions: [enumDirection.bottom],
},
]);
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
}, },
@ -375,12 +381,15 @@ MetaBalancerBuilding.componentVariations = {
[MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => { [MetaBalancerBuilding.variants.splitterInverse]: (entity, rotationVariant) => {
{ {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ]); directions: [enumDirection.bottom],
},
]);
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
}, },
@ -395,4 +404,4 @@ MetaBalancerBuilding.componentVariations = {
]; ];
} }
}, },
}; };

View File

@ -138,43 +138,35 @@ export class MetaBeltBuilding extends MetaBuilding {
getPreviewSprite(rotationVariant) { getPreviewSprite(rotationVariant) {
switch (MetaBeltBuilding.variantToRotation[rotationVariant]) { switch (MetaBeltBuilding.variantToRotation[rotationVariant]) {
case enumDirection.top: case enumDirection.top: {
{ return Loader.getSprite("sprites/buildings/belt_top.png");
return Loader.getSprite("sprites/buildings/belt_top.png"); }
} case enumDirection.left: {
case enumDirection.left: return Loader.getSprite("sprites/buildings/belt_left.png");
{ }
return Loader.getSprite("sprites/buildings/belt_left.png"); case enumDirection.right: {
} return Loader.getSprite("sprites/buildings/belt_right.png");
case enumDirection.right: }
{ default: {
return Loader.getSprite("sprites/buildings/belt_right.png"); assertAlways(false, "Invalid belt rotation variant");
} }
default:
{
assertAlways(false, "Invalid belt rotation variant");
}
} }
} }
getBlueprintSprite(rotationVariant) { getBlueprintSprite(rotationVariant) {
switch (MetaBeltBuilding.variantToRotation[rotationVariant]) { switch (MetaBeltBuilding.variantToRotation[rotationVariant]) {
case enumDirection.top: case enumDirection.top: {
{ return Loader.getSprite("sprites/blueprints/belt_top.png");
return Loader.getSprite("sprites/blueprints/belt_top.png"); }
} case enumDirection.left: {
case enumDirection.left: return Loader.getSprite("sprites/blueprints/belt_left.png");
{ }
return Loader.getSprite("sprites/blueprints/belt_left.png"); case enumDirection.right: {
} return Loader.getSprite("sprites/blueprints/belt_right.png");
case enumDirection.right: }
{ default: {
return Loader.getSprite("sprites/blueprints/belt_right.png"); assertAlways(false, "Invalid belt rotation variant");
} }
default:
{
assertAlways(false, "Invalid belt rotation variant");
}
} }
} }
@ -300,11 +292,11 @@ export class MetaBeltBuilding extends MetaBuilding {
MetaBeltBuilding.setupEntityComponents = [ MetaBeltBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new BeltComponent({ new BeltComponent({
direction: enumDirection.top, // updated later direction: enumDirection.top, // updated later
}) })
), ),
]; ];
MetaBeltBuilding.silhouetteColors = { MetaBeltBuilding.silhouetteColors = {
@ -371,4 +363,4 @@ MetaBeltBuilding.additionalStatistics = {
[defaultBuildingVariant]: root => [ [defaultBuildingVariant]: root => [
[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())], [T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(root.hubGoals.getBeltBaseSpeed())],
], ],
}; };

View File

@ -118,32 +118,33 @@ export class MetaComparatorBuilding extends MetaBuilding {
MetaComparatorBuilding.setupEntityComponents = [ MetaComparatorBuilding.setupEntityComponents = [
(entity, rotationVariant) => (entity, rotationVariant) =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.left,
}, type: enumPinSlotType.logicalAcceptor,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.right, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.right,
}, type: enumPinSlotType.logicalAcceptor,
], },
}) ],
), })
),
(entity, rotationVariant) => (entity, rotationVariant) =>
entity.addComponent( entity.addComponent(
new LogicGateComponent({ new LogicGateComponent({
type: enumLogicGateType.compare, type: enumLogicGateType.compare,
}) })
), ),
]; ];
MetaComparatorBuilding.overlayMatrices = { MetaComparatorBuilding.overlayMatrices = {
@ -185,7 +186,8 @@ MetaComparatorBuilding.layerByVariant = {
MetaComparatorBuilding.componentVariations = { MetaComparatorBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -204,4 +206,4 @@ MetaComparatorBuilding.componentVariations = {
entity.components.LogicGate.type = enumLogicGateType.compare; entity.components.LogicGate.type = enumLogicGateType.compare;
}, },
}; };

View File

@ -118,15 +118,17 @@ export class MetaConstantSignalBuilding extends MetaBuilding {
MetaConstantSignalBuilding.setupEntityComponents = [ MetaConstantSignalBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, ], type: enumPinSlotType.logicalEjector,
}) },
), ],
})
),
entity => entity.addComponent(new ConstantSignalComponent({})), entity => entity.addComponent(new ConstantSignalComponent({})),
]; ];
@ -170,10 +172,12 @@ MetaConstantSignalBuilding.layerPreview = {
MetaConstantSignalBuilding.componentVariations = { MetaConstantSignalBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, ]); type: enumPinSlotType.logicalEjector,
},
]);
}, },
}; };

View File

@ -89,23 +89,25 @@ export class MetaCutterBuilding extends MetaBuilding {
} }
MetaCutterBuilding.setupEntityComponents = [ MetaCutterBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 1, inputsPerCharge: 1,
processorType: enumItemProcessorTypes.cutter, processorType: enumItemProcessorTypes.cutter,
}) })
), ),
entity => entity.addComponent(new ItemEjectorComponent({})), entity => entity.addComponent(new ItemEjectorComponent({})),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
filter: "shape", directions: [enumDirection.bottom],
}, ], filter: "shape",
}) },
), ],
})
),
]; ];
MetaCutterBuilding.variants = { MetaCutterBuilding.variants = {
@ -197,4 +199,4 @@ MetaCutterBuilding.componentVariations = {
]); ]);
entity.components.ItemProcessor.type = enumItemProcessorTypes.cutterQuad; entity.components.ItemProcessor.type = enumItemProcessorTypes.cutterQuad;
}, },
}; };

View File

@ -105,15 +105,17 @@ export class MetaDisplayBuilding extends MetaBuilding {
MetaDisplayBuilding.setupEntityComponents = [ MetaDisplayBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.bottom, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.bottom,
}, ], type: enumPinSlotType.logicalAcceptor,
}) },
), ],
})
),
entity => entity.addComponent(new DisplayComponent()), entity => entity.addComponent(new DisplayComponent()),
]; ];
@ -155,10 +157,12 @@ MetaDisplayBuilding.renderPins = {
MetaDisplayBuilding.componentVariations = { MetaDisplayBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.bottom, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.bottom,
}, ]); type: enumPinSlotType.logicalAcceptor,
},
]);
}, },
}; };

View File

@ -130,40 +130,45 @@ export class MetaFilterBuilding extends MetaBuilding {
MetaFilterBuilding.setupEntityComponents = [ MetaFilterBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.left,
}, ], type: enumPinSlotType.logicalAcceptor,
}) },
), ],
})
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ], directions: [enumDirection.bottom],
}) },
), ],
})
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, direction: enumDirection.top,
{ },
pos: new Vector(1, 0), {
direction: enumDirection.right, pos: new Vector(1, 0),
}, direction: enumDirection.right,
], },
}) ],
), })
),
entity => entity.addComponent(new FilterComponent()), entity => entity.addComponent(new FilterComponent()),
]; ];
@ -212,18 +217,23 @@ MetaFilterBuilding.renderPins = {
MetaFilterBuilding.componentVariations = { MetaFilterBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.left,
}, ]); type: enumPinSlotType.logicalAcceptor,
},
]);
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ]); directions: [enumDirection.bottom],
},
]);
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
}, },
@ -233,4 +243,4 @@ MetaFilterBuilding.componentVariations = {
}, },
]); ]);
}, },
}; };

View File

@ -122,100 +122,103 @@ MetaHubBuilding.canPipet = () => false;
MetaHubBuilding.setupEntityComponents = [ MetaHubBuilding.setupEntityComponents = [
entity => entity.addComponent(new HubComponent()), entity => entity.addComponent(new HubComponent()),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 1, inputsPerCharge: 1,
processorType: enumItemProcessorTypes.hub, processorType: enumItemProcessorTypes.hub,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 2), {
type: enumPinSlotType.logicalEjector, pos: new Vector(0, 2),
direction: enumDirection.left, type: enumPinSlotType.logicalEjector,
}, ], direction: enumDirection.left,
}) },
), ],
})
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.top, enumDirection.left], pos: new Vector(0, 0),
filter: "shape", directions: [enumDirection.top, enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(1, 0), {
directions: [enumDirection.top], pos: new Vector(1, 0),
filter: "shape", directions: [enumDirection.top],
}, filter: "shape",
{ },
pos: new Vector(2, 0), {
directions: [enumDirection.top], pos: new Vector(2, 0),
filter: "shape", directions: [enumDirection.top],
}, filter: "shape",
{ },
pos: new Vector(3, 0), {
directions: [enumDirection.top, enumDirection.right], pos: new Vector(3, 0),
filter: "shape", directions: [enumDirection.top, enumDirection.right],
}, filter: "shape",
{ },
pos: new Vector(0, 3), {
directions: [enumDirection.bottom, enumDirection.left], pos: new Vector(0, 3),
filter: "shape", directions: [enumDirection.bottom, enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(1, 3), {
directions: [enumDirection.bottom], pos: new Vector(1, 3),
filter: "shape", directions: [enumDirection.bottom],
}, filter: "shape",
{ },
pos: new Vector(2, 3), {
directions: [enumDirection.bottom], pos: new Vector(2, 3),
filter: "shape", directions: [enumDirection.bottom],
}, filter: "shape",
{ },
pos: new Vector(3, 3), {
directions: [enumDirection.bottom, enumDirection.right], pos: new Vector(3, 3),
filter: "shape", directions: [enumDirection.bottom, enumDirection.right],
}, filter: "shape",
{ },
pos: new Vector(0, 1), {
directions: [enumDirection.left], pos: new Vector(0, 1),
filter: "shape", directions: [enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(0, 2), {
directions: [enumDirection.left], pos: new Vector(0, 2),
filter: "shape", directions: [enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(0, 3), {
directions: [enumDirection.left], pos: new Vector(0, 3),
filter: "shape", directions: [enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(3, 1), {
directions: [enumDirection.right], pos: new Vector(3, 1),
filter: "shape", directions: [enumDirection.right],
}, filter: "shape",
{ },
pos: new Vector(3, 2), {
directions: [enumDirection.right], pos: new Vector(3, 2),
filter: "shape", directions: [enumDirection.right],
}, filter: "shape",
{ },
pos: new Vector(3, 3), {
directions: [enumDirection.right], pos: new Vector(3, 3),
filter: "shape", directions: [enumDirection.right],
}, filter: "shape",
], },
}) ],
), })
),
]; ];
MetaHubBuilding.silhouetteColors = { MetaHubBuilding.silhouetteColors = {
@ -256,13 +259,16 @@ MetaHubBuilding.componentVariations = {
entity.components.ItemProcessor.type = enumItemProcessorTypes.hub; entity.components.ItemProcessor.type = enumItemProcessorTypes.hub;
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 2), {
type: enumPinSlotType.logicalEjector, pos: new Vector(0, 2),
direction: enumDirection.left, type: enumPinSlotType.logicalEjector,
}, ]); direction: enumDirection.left,
},
]);
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.top, enumDirection.left], directions: [enumDirection.top, enumDirection.left],
filter: "shape", filter: "shape",
@ -334,4 +340,4 @@ MetaHubBuilding.componentVariations = {
}, },
]); ]);
}, },
}; };

View File

@ -98,21 +98,23 @@ export class MetaItemProducerBuilding extends MetaBuilding {
MetaItemProducerBuilding.setupEntityComponents = [ MetaItemProducerBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }],
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
type: enumPinSlotType.logicalAcceptor, pos: new Vector(0, 0),
direction: enumDirection.bottom, type: enumPinSlotType.logicalAcceptor,
}, ], direction: enumDirection.bottom,
}) },
), ],
})
),
entity => entity.addComponent(new ItemProducerComponent()), entity => entity.addComponent(new ItemProducerComponent()),
]; ];
@ -153,10 +155,12 @@ MetaItemProducerBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
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.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 0), {
type: enumPinSlotType.logicalAcceptor, pos: new Vector(0, 0),
direction: enumDirection.bottom, type: enumPinSlotType.logicalAcceptor,
}, ]); direction: enumDirection.bottom,
},
]);
}, },
}; };

View File

@ -121,15 +121,17 @@ export class MetaLeverBuilding extends MetaBuilding {
MetaLeverBuilding.setupEntityComponents = [ MetaLeverBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, ], type: enumPinSlotType.logicalEjector,
}) },
), ],
})
),
entity => entity.addComponent(new LeverComponent({})), entity => entity.addComponent(new LeverComponent({})),
]; ];
@ -172,10 +174,12 @@ MetaLeverBuilding.renderPins = {
MetaLeverBuilding.componentVariations = { MetaLeverBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, ]); type: enumPinSlotType.logicalEjector,
},
]);
}, },
}; };

View File

@ -117,11 +117,11 @@ export class MetaLogicGateBuilding extends MetaBuilding {
} }
MetaLogicGateBuilding.setupEntityComponents = [ MetaLogicGateBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [], slots: [],
}) })
), ),
entity => entity.addComponent(new LogicGateComponent({})), entity => entity.addComponent(new LogicGateComponent({})),
]; ];
@ -202,7 +202,8 @@ MetaLogicGateBuilding.layerPreview = {
MetaLogicGateBuilding.componentVariations = { MetaLogicGateBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -223,7 +224,8 @@ MetaLogicGateBuilding.componentVariations = {
}, },
[MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => { [MetaLogicGateBuilding.variants.xor]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -244,7 +246,8 @@ MetaLogicGateBuilding.componentVariations = {
}, },
[MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => { [MetaLogicGateBuilding.variants.or]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -264,7 +267,8 @@ MetaLogicGateBuilding.componentVariations = {
entity.components.LogicGate.type = enumLogicGateType.or; entity.components.LogicGate.type = enumLogicGateType.or;
}, },
[MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => { [MetaLogicGateBuilding.variants.not]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -278,4 +282,4 @@ MetaLogicGateBuilding.componentVariations = {
entity.components.LogicGate.type = enumLogicGateType.not; entity.components.LogicGate.type = enumLogicGateType.not;
}, },
}; };

View File

@ -115,11 +115,11 @@ export class MetaMinerBuilding extends MetaBuilding {
MetaMinerBuilding.setupEntityComponents = [ MetaMinerBuilding.setupEntityComponents = [
entity => entity.addComponent(new MinerComponent({})), entity => entity.addComponent(new MinerComponent({})),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }],
}) })
), ),
]; ];
MetaMinerBuilding.variants = { MetaMinerBuilding.variants = {
chainable: "chainable", chainable: "chainable",
@ -189,4 +189,4 @@ MetaMinerBuilding.componentVariations = {
[MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => { [MetaMinerBuilding.variants.chainable]: (entity, rotationVariant) => {
entity.components.Miner.chainable = true; entity.components.Miner.chainable = true;
}, },
}; };

View File

@ -115,35 +115,36 @@ export class MetaMixerBuilding extends MetaBuilding {
MetaMixerBuilding.setupEntityComponents = [ MetaMixerBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 2, inputsPerCharge: 2,
processorType: enumItemProcessorTypes.mixer, processorType: enumItemProcessorTypes.mixer,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }],
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
filter: "color", directions: [enumDirection.bottom],
}, filter: "color",
{ },
pos: new Vector(1, 0), {
directions: [enumDirection.bottom], pos: new Vector(1, 0),
filter: "color", directions: [enumDirection.bottom],
}, filter: "color",
], },
}) ],
), })
),
]; ];
MetaMixerBuilding.silhouetteColors = { MetaMixerBuilding.silhouetteColors = {
@ -195,7 +196,8 @@ MetaMixerBuilding.componentVariations = {
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.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
filter: "color", filter: "color",
@ -207,4 +209,4 @@ MetaMixerBuilding.componentVariations = {
}, },
]); ]);
}, },
}; };

View File

@ -121,27 +121,28 @@ export class MetaPainterBuilding extends MetaBuilding {
MetaPainterBuilding.setupEntityComponents = [ MetaPainterBuilding.setupEntityComponents = [
entity => entity.addComponent(new ItemProcessorComponent({})), entity => entity.addComponent(new ItemProcessorComponent({})),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(1, 0), direction: enumDirection.right }], slots: [{ pos: new Vector(1, 0), direction: enumDirection.right }],
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.left], pos: new Vector(0, 0),
filter: "shape", directions: [enumDirection.left],
}, filter: "shape",
{ },
pos: new Vector(1, 0), {
directions: [enumDirection.top], pos: new Vector(1, 0),
filter: "color", directions: [enumDirection.top],
}, filter: "color",
], },
}) ],
), })
),
]; ];
MetaPainterBuilding.variants = { MetaPainterBuilding.variants = {
@ -251,7 +252,8 @@ MetaPainterBuilding.componentVariations = {
entity.removeComponent(WiredPinsComponent); entity.removeComponent(WiredPinsComponent);
} }
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.left], directions: [enumDirection.left],
filter: "shape", filter: "shape",
@ -275,7 +277,8 @@ MetaPainterBuilding.componentVariations = {
entity.removeComponent(WiredPinsComponent); entity.removeComponent(WiredPinsComponent);
} }
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.left], directions: [enumDirection.left],
filter: "shape", filter: "shape",
@ -299,7 +302,8 @@ MetaPainterBuilding.componentVariations = {
entity.removeComponent(WiredPinsComponent); entity.removeComponent(WiredPinsComponent);
} }
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.left], directions: [enumDirection.left],
filter: "shape", filter: "shape",
@ -328,7 +332,8 @@ MetaPainterBuilding.componentVariations = {
entity.addComponent(new WiredPinsComponent({ slots: [] })); entity.addComponent(new WiredPinsComponent({ slots: [] }));
} }
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.bottom, direction: enumDirection.bottom,
type: enumPinSlotType.logicalAcceptor, type: enumPinSlotType.logicalAcceptor,
@ -350,7 +355,8 @@ MetaPainterBuilding.componentVariations = {
}, },
]); ]);
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.left], directions: [enumDirection.left],
filter: "shape", filter: "shape",
@ -383,4 +389,4 @@ MetaPainterBuilding.componentVariations = {
entity.components.ItemProcessor.processingRequirement = enumItemProcessorRequirements.painterQuad; entity.components.ItemProcessor.processingRequirement = enumItemProcessorRequirements.painterQuad;
entity.components.ItemProcessor.inputsPerCharge = 5; entity.components.ItemProcessor.inputsPerCharge = 5;
}, },
}; };

View File

@ -132,55 +132,62 @@ export class MetaReaderBuilding extends MetaBuilding {
MetaReaderBuilding.setupEntityComponents = [ MetaReaderBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.right, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.right,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.left,
}, type: enumPinSlotType.logicalEjector,
], },
}) ],
), })
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ], directions: [enumDirection.bottom],
}) },
), ],
})
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, ], direction: enumDirection.top,
}) },
), ],
})
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
processorType: enumItemProcessorTypes.reader, processorType: enumItemProcessorTypes.reader,
inputsPerCharge: 1, inputsPerCharge: 1,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new BeltUnderlaysComponent({ new BeltUnderlaysComponent({
underlays: [{ underlays: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, ], direction: enumDirection.top,
}) },
), ],
})
),
entity => entity.addComponent(new BeltReaderComponent()), entity => entity.addComponent(new BeltReaderComponent()),
]; ];
@ -229,23 +236,29 @@ MetaReaderBuilding.renderPins = {
MetaReaderBuilding.componentVariations = { MetaReaderBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ]); directions: [enumDirection.bottom],
},
]);
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, ]); direction: enumDirection.top,
},
]);
entity.components.ItemProcessor.inputsPerCharge = 1; entity.components.ItemProcessor.inputsPerCharge = 1;
entity.components.ItemProcessor.type = enumItemProcessorTypes.reader; entity.components.ItemProcessor.type = enumItemProcessorTypes.reader;
entity.components.BeltUnderlays.underlays = [{ entity.components.BeltUnderlays.underlays = [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, ]; direction: enumDirection.top,
},
];
}, },
}; };

View File

@ -129,28 +129,30 @@ export class MetaRotaterBuilding extends MetaBuilding {
MetaRotaterBuilding.setupEntityComponents = [ MetaRotaterBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 1, inputsPerCharge: 1,
processorType: enumItemProcessorTypes.rotater, processorType: enumItemProcessorTypes.rotater,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }],
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
filter: "shape", directions: [enumDirection.bottom],
}, ], filter: "shape",
}) },
), ],
})
),
]; ];
MetaRotaterBuilding.variants = { MetaRotaterBuilding.variants = {
@ -262,4 +264,4 @@ MetaRotaterBuilding.componentVariations = {
[MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => { [MetaRotaterBuilding.variants.rotate180]: (entity, rotationVariant) => {
entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater180; entity.components.ItemProcessor.type = enumItemProcessorTypes.rotater180;
}, },
}; };

View File

@ -129,34 +129,35 @@ export class MetaStackerBuilding extends MetaBuilding {
MetaStackerBuilding.setupEntityComponents = [ MetaStackerBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 2, inputsPerCharge: 2,
processorType: enumItemProcessorTypes.stacker, processorType: enumItemProcessorTypes.stacker,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }],
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
filter: "shape", directions: [enumDirection.bottom],
}, filter: "shape",
{ },
pos: new Vector(1, 0), {
directions: [enumDirection.bottom], pos: new Vector(1, 0),
filter: "shape", directions: [enumDirection.bottom],
}, filter: "shape",
], },
}) ],
), })
),
]; ];
MetaStackerBuilding.dimensions = { MetaStackerBuilding.dimensions = {
@ -216,7 +217,8 @@ MetaStackerBuilding.componentVariations = {
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.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
filter: "shape", filter: "shape",
@ -228,4 +230,4 @@ MetaStackerBuilding.componentVariations = {
}, },
]); ]);
}, },
}; };

View File

@ -132,56 +132,59 @@ export class MetaStorageBuilding extends MetaBuilding {
MetaStorageBuilding.setupEntityComponents = [ MetaStorageBuilding.setupEntityComponents = [
entity => entity =>
// Required, since the item processor needs this. // Required, since the item processor needs this.
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, direction: enumDirection.top,
{ },
pos: new Vector(1, 0), {
direction: enumDirection.top, pos: new Vector(1, 0),
}, direction: enumDirection.top,
], },
}) ],
), })
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 1), {
directions: [enumDirection.bottom], pos: new Vector(0, 1),
}, directions: [enumDirection.bottom],
{ },
pos: new Vector(1, 1), {
directions: [enumDirection.bottom], pos: new Vector(1, 1),
}, directions: [enumDirection.bottom],
], },
}) ],
), })
),
entity => entity =>
entity.addComponent( entity.addComponent(
new StorageComponent({ new StorageComponent({
maximumStorage: storageSize, maximumStorage: storageSize,
}) })
), ),
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(1, 1), {
direction: enumDirection.right, pos: new Vector(1, 1),
type: enumPinSlotType.logicalEjector, direction: enumDirection.right,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 1), {
direction: enumDirection.left, pos: new Vector(0, 1),
type: enumPinSlotType.logicalEjector, direction: enumDirection.left,
}, type: enumPinSlotType.logicalEjector,
], },
}) ],
), })
),
]; ];
MetaStorageBuilding.dimensions = { MetaStorageBuilding.dimensions = {
@ -232,7 +235,8 @@ MetaStorageBuilding.renderPins = {
MetaStorageBuilding.componentVariations = { MetaStorageBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
}, },
@ -241,7 +245,8 @@ MetaStorageBuilding.componentVariations = {
direction: enumDirection.top, direction: enumDirection.top,
}, },
]); ]);
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
{
pos: new Vector(0, 1), pos: new Vector(0, 1),
directions: [enumDirection.bottom], directions: [enumDirection.bottom],
}, },
@ -251,7 +256,8 @@ MetaStorageBuilding.componentVariations = {
}, },
]); ]);
entity.components.Storage.maximumStorage = storageSize; entity.components.Storage.maximumStorage = storageSize;
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(1, 1), pos: new Vector(1, 1),
direction: enumDirection.right, direction: enumDirection.right,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -263,4 +269,4 @@ MetaStorageBuilding.componentVariations = {
}, },
]); ]);
}, },
}; };

View File

@ -118,32 +118,33 @@ export class MetaTransistorBuilding extends MetaBuilding {
MetaTransistorBuilding.setupEntityComponents = [ MetaTransistorBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector, direction: enumDirection.top,
}, type: enumPinSlotType.logicalEjector,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.left, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.left,
}, type: enumPinSlotType.logicalAcceptor,
{ },
pos: new Vector(0, 0), {
direction: enumDirection.bottom, pos: new Vector(0, 0),
type: enumPinSlotType.logicalAcceptor, direction: enumDirection.bottom,
}, type: enumPinSlotType.logicalAcceptor,
], },
}) ],
), })
),
entity => entity =>
entity.addComponent( entity.addComponent(
new LogicGateComponent({ new LogicGateComponent({
type: enumLogicGateType.transistor, type: enumLogicGateType.transistor,
}) })
), ),
]; ];
MetaTransistorBuilding.variants = { MetaTransistorBuilding.variants = {
@ -206,4 +207,4 @@ MetaTransistorBuilding.componentVariations = {
[MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => { [MetaTransistorBuilding.variants.mirrored]: (entity, rotationVariant) => {
entity.components.WiredPins.slots[1].direction = enumDirection.right; entity.components.WiredPins.slots[1].direction = enumDirection.right;
}, },
}; };

View File

@ -120,26 +120,28 @@ export class MetaTrashBuilding extends MetaBuilding {
MetaTrashBuilding.setupEntityComponents = [ MetaTrashBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [{ slots: [
pos: new Vector(0, 0), {
directions: [ pos: new Vector(0, 0),
enumDirection.top, directions: [
enumDirection.right, enumDirection.top,
enumDirection.bottom, enumDirection.right,
enumDirection.left, enumDirection.bottom,
enumDirection.left,
],
},
], ],
}, ], })
}) ),
),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemProcessorComponent({ new ItemProcessorComponent({
inputsPerCharge: 1, inputsPerCharge: 1,
processorType: enumItemProcessorTypes.trash, processorType: enumItemProcessorTypes.trash,
}) })
), ),
]; ];
MetaTrashBuilding.overlayMatrices = { MetaTrashBuilding.overlayMatrices = {
@ -182,18 +184,20 @@ MetaTrashBuilding.avaibleVariants = {
MetaTrashBuilding.componentVariations = { MetaTrashBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [ pos: new Vector(0, 0),
enumDirection.top, directions: [
enumDirection.right, enumDirection.top,
enumDirection.bottom, enumDirection.right,
enumDirection.left, enumDirection.bottom,
], enumDirection.left,
}, ]); ],
},
]);
entity.components.ItemProcessor.inputsPerCharge = 1; entity.components.ItemProcessor.inputsPerCharge = 1;
entity.components.ItemProcessor.type = enumItemProcessorTypes.trash; entity.components.ItemProcessor.type = enumItemProcessorTypes.trash;
}, },
}; };

View File

@ -188,7 +188,8 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
const targetSenderRotation = rotation; const targetSenderRotation = rotation;
for ( for (
let searchOffset = 1; searchOffset <= globalConfig.undergroundBeltMaxTilesByTier[tier]; let searchOffset = 1;
searchOffset <= globalConfig.undergroundBeltMaxTilesByTier[tier];
++searchOffset ++searchOffset
) { ) {
tile = tile.addScalars(searchVector.x, searchVector.y); tile = tile.addScalars(searchVector.x, searchVector.y);
@ -245,18 +246,18 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
MetaUndergroundBeltBuilding.setupEntityComponents = [ MetaUndergroundBeltBuilding.setupEntityComponents = [
// Required, since the item processor needs this. // Required, since the item processor needs this.
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemEjectorComponent({ new ItemEjectorComponent({
slots: [], slots: [],
}) })
), ),
entity => entity.addComponent(new UndergroundBeltComponent({})), entity => entity.addComponent(new UndergroundBeltComponent({})),
entity => entity =>
entity.addComponent( entity.addComponent(
new ItemAcceptorComponent({ new ItemAcceptorComponent({
slots: [], slots: [],
}) })
), ),
]; ];
MetaUndergroundBeltBuilding.rotationVariants = [0, 1]; MetaUndergroundBeltBuilding.rotationVariants = [0, 1];
@ -360,18 +361,22 @@ MetaUndergroundBeltBuilding.componentVariationsByRotation = {
[enumUndergroundBeltMode.sender]: (entity, rotationVariant) => { [enumUndergroundBeltMode.sender]: (entity, rotationVariant) => {
entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.sender; entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.sender;
entity.components.ItemEjector.setSlots([]); entity.components.ItemEjector.setSlots([]);
entity.components.ItemAcceptor.setSlots([{ entity.components.ItemAcceptor.setSlots([
pos: new Vector(0, 0), {
directions: [enumDirection.bottom], pos: new Vector(0, 0),
}, ]); directions: [enumDirection.bottom],
},
]);
}, },
[enumUndergroundBeltMode.receiver]: (entity, rotationVariant) => { [enumUndergroundBeltMode.receiver]: (entity, rotationVariant) => {
entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.receiver; entity.components.UndergroundBelt.mode = enumUndergroundBeltMode.receiver;
entity.components.ItemAcceptor.setSlots([]); entity.components.ItemAcceptor.setSlots([]);
entity.components.ItemEjector.setSlots([{ entity.components.ItemEjector.setSlots([
pos: new Vector(0, 0), {
direction: enumDirection.top, pos: new Vector(0, 0),
}, ]); direction: enumDirection.top,
},
]);
}, },
}; };

View File

@ -121,11 +121,11 @@ export class MetaVirtualProcessorBuilding extends MetaBuilding {
MetaVirtualProcessorBuilding.setupEntityComponents = [ MetaVirtualProcessorBuilding.setupEntityComponents = [
entity => entity =>
entity.addComponent( entity.addComponent(
new WiredPinsComponent({ new WiredPinsComponent({
slots: [], slots: [],
}) })
), ),
entity => entity.addComponent(new LogicGateComponent({})), entity => entity.addComponent(new LogicGateComponent({})),
]; ];
@ -219,7 +219,8 @@ MetaVirtualProcessorBuilding.silhouetteColors = {
MetaVirtualProcessorBuilding.componentVariations = { MetaVirtualProcessorBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => { [defaultBuildingVariant]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.left, direction: enumDirection.left,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -240,7 +241,8 @@ MetaVirtualProcessorBuilding.componentVariations = {
}, },
[MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => { [MetaVirtualProcessorBuilding.variants.rotater]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -256,7 +258,8 @@ MetaVirtualProcessorBuilding.componentVariations = {
}, },
[MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => { [MetaVirtualProcessorBuilding.variants.unstacker]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.left, direction: enumDirection.left,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -277,7 +280,8 @@ MetaVirtualProcessorBuilding.componentVariations = {
}, },
[MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => { [MetaVirtualProcessorBuilding.variants.stacker]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -298,7 +302,8 @@ MetaVirtualProcessorBuilding.componentVariations = {
}, },
[MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => { [MetaVirtualProcessorBuilding.variants.painter]: (entity, rotationVariant) => {
entity.components.WiredPins.setSlots([{ entity.components.WiredPins.setSlots([
{
pos: new Vector(0, 0), pos: new Vector(0, 0),
direction: enumDirection.top, direction: enumDirection.top,
type: enumPinSlotType.logicalEjector, type: enumPinSlotType.logicalEjector,
@ -317,4 +322,4 @@ MetaVirtualProcessorBuilding.componentVariations = {
entity.components.LogicGate.type = enumLogicGateType.painter; entity.components.LogicGate.type = enumLogicGateType.painter;
}, },
}; };

View File

@ -151,26 +151,21 @@ export class MetaWireBuilding extends MetaBuilding {
getPreviewSprite(rotationVariant, variant) { getPreviewSprite(rotationVariant, variant) {
const wireVariant = MetaWireBuilding.wireVariantToVariant[variant]; const wireVariant = MetaWireBuilding.wireVariantToVariant[variant];
switch (MetaWireBuilding.rotationVariantToType[rotationVariant]) { switch (MetaWireBuilding.rotationVariantToType[rotationVariant]) {
case enumWireType.forward: case enumWireType.forward: {
{ return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_forward.png");
return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_forward.png"); }
} case enumWireType.turn: {
case enumWireType.turn: return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_turn.png");
{ }
return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_turn.png"); case enumWireType.split: {
} return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_split.png");
case enumWireType.split: }
{ case enumWireType.cross: {
return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_split.png"); return Loader.getSprite("sprites/wires/sets/" + wireVariant + "_cross.png");
} }
case enumWireType.cross: default: {
{ assertAlways(false, "Invalid wire rotation variant");
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.type = MetaWireBuilding.rotationVariantToType[rotationVariant];
entity.components.Wire.variant = "second"; entity.components.Wire.variant = "second";
}, },
}; };

View File

@ -157,4 +157,4 @@ MetaWireTunnelBuilding.layerByVariant = {
MetaWireTunnelBuilding.componentVariations = { MetaWireTunnelBuilding.componentVariations = {
[defaultBuildingVariant]: (entity, rotationVariant) => {}, [defaultBuildingVariant]: (entity, rotationVariant) => {},
}; };

View File

@ -71,4 +71,4 @@ export function initComponentRegistry() {
); );
console.log("📦 There are", gComponentRegistry.getNumEntries(), "components"); console.log("📦 There are", gComponentRegistry.getNumEntries(), "components");
} }

View File

@ -66,18 +66,16 @@ export class BeltComponent extends Component {
assert(progress <= 1.02, "Invalid progress: " + progress); assert(progress <= 1.02, "Invalid progress: " + progress);
return new Vector(0, 0.5 - progress); return new Vector(0, 0.5 - progress);
case enumDirection.right: case enumDirection.right: {
{ assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 2: " + progress);
assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 2: " + progress); const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI;
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));
return new Vector(0.5 - 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress)); }
} case enumDirection.left: {
case enumDirection.left: assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 3: " + progress);
{ const arcProgress = (progress / BeltComponent.curvedBeltLength) * 0.5 * Math.PI;
assert(progress <= BeltComponent.curvedBeltLength + 0.02, "Invalid progress 3: " + progress); return new Vector(-0.5 + 0.5 * Math.cos(arcProgress), 0.5 - 0.5 * Math.sin(arcProgress));
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: default:
assertAlways(false, "Invalid belt direction: " + this.direction); assertAlways(false, "Invalid belt direction: " + this.direction);
return new Vector(0, 0); return new Vector(0, 0);
@ -115,4 +113,4 @@ BeltComponent.fake_belt_ejector_slot_by_direction = {
item: null, item: null,
progress: 0, progress: 0,
}, },
}; };

View File

@ -41,4 +41,4 @@ export class BeltReaderComponent extends Component {
*/ */
this.lastThroughputComputation = 0; this.lastThroughputComputation = 0;
} }
} }

View File

@ -201,38 +201,34 @@ export class StaticMapEntityComponent extends Component {
const size = this.getTileSize(); const size = this.getTileSize();
switch (this.rotation) { switch (this.rotation) {
case 0: case 0: {
{ x = this.origin.x;
x = this.origin.x; y = this.origin.y;
y = this.origin.y; w = size.x;
w = size.x; h = size.y;
h = size.y; break;
break; }
} case 90: {
case 90: x = this.origin.x - size.y + 1;
{ y = this.origin.y;
x = this.origin.x - size.y + 1; w = size.y;
y = this.origin.y; h = size.x;
w = size.y; break;
h = size.x; }
break; case 180: {
} x = this.origin.x - size.x + 1;
case 180: y = this.origin.y - size.y + 1;
{ w = size.x;
x = this.origin.x - size.x + 1; h = size.y;
y = this.origin.y - size.y + 1; break;
w = size.x; }
h = size.y; case 270: {
break; x = this.origin.x;
} y = this.origin.y - size.x + 1;
case 270: w = size.y;
{ h = size.x;
x = this.origin.x; break;
y = this.origin.y - size.x + 1; }
w = size.y;
h = size.x;
break;
}
default: default:
assert(false, "Invalid rotation"); assert(false, "Invalid rotation");
} }
@ -281,7 +277,9 @@ export class StaticMapEntityComponent extends Component {
parameters.context.translate(rotationCenterX, rotationCenterY); parameters.context.translate(rotationCenterX, rotationCenterY);
parameters.context.rotate(Math.radians(this.rotation)); parameters.context.rotate(Math.radians(this.rotation));
sprite.drawCached( 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.x + 2 * extrudePixels * size.x,
globalConfig.tileSize * size.y + 2 * extrudePixels * size.y, globalConfig.tileSize * size.y + 2 * extrudePixels * size.y,
false // no clipping possible here false // no clipping possible here
@ -290,4 +288,4 @@ export class StaticMapEntityComponent extends Component {
parameters.context.translate(-rotationCenterX, -rotationCenterY); parameters.context.translate(-rotationCenterX, -rotationCenterY);
} }
} }
} }

View File

@ -34,4 +34,4 @@ export class WireComponent extends Component {
*/ */
this.linkedNetwork = null; this.linkedNetwork = null;
} }
} }

View File

@ -422,7 +422,9 @@ export class GameCore {
// Transform to world space // Transform to world space
if (G_IS_DEV && globalConfig.debug.testClipping) { 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); root.camera.transform(context);
@ -521,11 +523,11 @@ export class GameCore {
context.fillStyle = "blue"; context.fillStyle = "blue";
context.fillText( context.fillText(
"Atlas: " + "Atlas: " +
desiredAtlasScale + desiredAtlasScale +
" / Zoom: " + " / Zoom: " +
round2Digits(zoomLevel) + round2Digits(zoomLevel) +
" / Effective Zoom: " + " / Effective Zoom: " +
round2Digits(effectiveZoomLevel), round2Digits(effectiveZoomLevel),
20, 20,
600 600
); );
@ -534,31 +536,31 @@ export class GameCore {
context.fillText( context.fillText(
"Maintained Buffers: " + "Maintained Buffers: " +
stats.rootKeys + stats.rootKeys +
" root keys / " + " root keys / " +
stats.subKeys + stats.subKeys +
" buffers / VRAM: " + " buffers / VRAM: " +
round2Digits(stats.vramBytes / (1024 * 1024)) + round2Digits(stats.vramBytes / (1024 * 1024)) +
" MB", " MB",
20, 20,
620 620
); );
const internalStats = getBufferStats(); const internalStats = getBufferStats();
context.fillText( context.fillText(
"Total Buffers: " + "Total Buffers: " +
internalStats.bufferCount + internalStats.bufferCount +
" buffers / " + " buffers / " +
internalStats.backlogSize + internalStats.backlogSize +
" backlog / " + " backlog / " +
internalStats.backlogKeys + internalStats.backlogKeys +
" keys in backlog / VRAM " + " keys in backlog / VRAM " +
round2Digits(internalStats.vramUsage / (1024 * 1024)) + round2Digits(internalStats.vramUsage / (1024 * 1024)) +
" MB / Backlog " + " MB / Backlog " +
round2Digits(internalStats.backlogVramUsage / (1024 * 1024)) + round2Digits(internalStats.backlogVramUsage / (1024 * 1024)) +
" MB / Created " + " MB / Created " +
internalStats.numCreated + internalStats.numCreated +
" / Reused " + " / Reused " +
internalStats.numReused, internalStats.numReused,
20, 20,
640 640
); );
@ -572,4 +574,4 @@ export class GameCore {
context.stroke(); context.stroke();
} }
} }
} }

View File

@ -235,4 +235,4 @@ export class Entity extends BasicSerializableObject {
drawImpl(parameters) { drawImpl(parameters) {
abstract; abstract;
} }
} }

View File

@ -238,4 +238,4 @@ export class EntityManager extends BasicSerializableObject {
assert(false, "Trying to destroy entity twice"); assert(false, "Trying to destroy entity twice");
} }
} }
} }

View File

@ -73,4 +73,4 @@ export class GameMode {
getIsFreeplayAvailable() { getIsFreeplayAvailable() {
return true; return true;
} }
} }

View File

@ -10,4 +10,4 @@ export function initGameModeRegistry() {
if (!shapezAPI.ingame.gamemodes.hasOwnProperty(gamemodeKey)) continue; if (!shapezAPI.ingame.gamemodes.hasOwnProperty(gamemodeKey)) continue;
gGameModeRegistry.register(shapezAPI.ingame.gamemodes[gamemodeKey]); gGameModeRegistry.register(shapezAPI.ingame.gamemodes[gamemodeKey]);
} }
} }

View File

@ -14,4 +14,4 @@ export function initGameSpeedRegistry() {
if (!shapezAPI.ingame.gamespeed.hasOwnProperty(gamespeedKey)) continue; if (!shapezAPI.ingame.gamespeed.hasOwnProperty(gamespeedKey)) continue;
gGameSpeedRegistry.register(shapezAPI.ingame.gamespeed[gamespeedKey]); gGameSpeedRegistry.register(shapezAPI.ingame.gamespeed[gamespeedKey]);
} }
} }

View File

@ -48,4 +48,4 @@ export class GameSystem {
startDraw(parameters) { startDraw(parameters) {
this.draw(parameters); this.draw(parameters);
} }
} }

View File

@ -164,4 +164,4 @@ export class GameSystemManager {
system.refreshCaches(); system.refreshCaches();
} }
} }
} }

View File

@ -134,4 +134,4 @@ export class GameSystemWithFilter extends GameSystem {
arrayDelete(this.allEntities, index); arrayDelete(this.allEntities, index);
} }
} }
} }

View File

@ -127,7 +127,8 @@ export class HubGoals extends BasicSerializableObject {
* @returns {boolean} * @returns {boolean}
*/ */
isEndOfDemoReached() { isEndOfDemoReached() {
return (!this.root.gameMode.getIsFreeplayAvailable() && return (
!this.root.gameMode.getIsFreeplayAvailable() &&
this.level >= this.root.gameMode.getLevelDefinitions().length this.level >= this.root.gameMode.getLevelDefinitions().length
); );
} }
@ -506,13 +507,13 @@ export class HubGoals extends BasicSerializableObject {
HubGoals.getProcessorBaseSpeed = { HubGoals.getProcessorBaseSpeed = {
trash: processorType => 1e30, trash: processorType => 1e30,
hub: processorType => 1e30, hub: processorType => 1e30,
balancer: function(processorType) { balancer: function (processorType) {
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2; return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
}, },
reader: function(processorType) { reader: function (processorType) {
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt; return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt;
}, },
mixer: function(processorType) { mixer: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -523,7 +524,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
painter: function(processorType) { painter: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -534,7 +535,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
painterDouble: function(processorType) { painterDouble: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -545,7 +546,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
painterQuad: function(processorType) { painterQuad: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in 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( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -568,7 +569,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
cutterQuad: function(processorType) { cutterQuad: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -579,7 +580,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
rotater: function(processorType) { rotater: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -590,7 +591,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
rotaterCCW: function(processorType) { rotaterCCW: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -601,7 +602,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
rotater180: function(processorType) { rotater180: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -612,7 +613,7 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
stacker: function(processorType) { stacker: function (processorType) {
assert( assert(
globalConfig.buildingSpeeds[processorType], globalConfig.buildingSpeeds[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds:()=> " + processorType
@ -623,4 +624,4 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType] globalConfig.buildingSpeeds[processorType]
); );
}, },
}; };

View File

@ -164,4 +164,4 @@ export class BaseHUDPart {
"mapMoveLeft", "mapMoveLeft",
]); ]);
} }
} }

View File

@ -342,4 +342,4 @@ export class GameHUD {
this.signals[key].removeAll(); this.signals[key].removeAll();
} }
} }
} }

View File

@ -18,7 +18,8 @@ export class HUDBaseToolbar extends BaseHUDPart {
* @param {Layer=} param0.layer * @param {Layer=} param0.layer
*/ */
constructor( constructor(
root, { primaryBuildings, secondaryBuildings = [], visibilityCondition, htmlElementId, layer = "regular" } root,
{ primaryBuildings, secondaryBuildings = [], visibilityCondition, htmlElementId, layer = "regular" }
) { ) {
super(root); super(root);
@ -81,7 +82,8 @@ export class HUDBaseToolbar extends BaseHUDPart {
const itemContainer = makeDiv( const itemContainer = makeDiv(
this.primaryBuildings.includes(allBuildings[i]) ? rowPrimary : rowSecondary, this.primaryBuildings.includes(allBuildings[i]) ? rowPrimary : rowSecondary,
null, ["building"] null,
["building"]
); );
itemContainer.setAttribute("data-icon", "building_icons/" + metaBuilding.getId() + ".png"); itemContainer.setAttribute("data-icon", "building_icons/" + metaBuilding.getId() + ".png");
itemContainer.setAttribute("data-id", metaBuilding.getId()); itemContainer.setAttribute("data-id", metaBuilding.getId());
@ -159,9 +161,9 @@ export class HUDBaseToolbar extends BaseHUDPart {
let newBuildingFound = false; let newBuildingFound = false;
let newIndex = this.lastSelectedIndex; let newIndex = this.lastSelectedIndex;
const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed ? const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed
-1 : ? -1
1; : 1;
for (let i = 0; i <= this.primaryBuildings.length; ++i) { for (let i = 0; i <= this.primaryBuildings.length; ++i) {
newIndex = safeModulo(newIndex + direction, this.primaryBuildings.length); newIndex = safeModulo(newIndex + direction, this.primaryBuildings.length);
@ -227,4 +229,4 @@ export class HUDBaseToolbar extends BaseHUDPart {
this.root.hud.signals.buildingSelectedForPlacement.dispatch(metaBuilding); this.root.hud.signals.buildingSelectedForPlacement.dispatch(metaBuilding);
this.onSelectedPlacementBuildingChanged(metaBuilding); this.onSelectedPlacementBuildingChanged(metaBuilding);
} }
} }

View File

@ -34,7 +34,8 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
this.buildingInfoElements.descText = makeDiv(this.buildingInfoElements.desc, null, ["text"], ""); this.buildingInfoElements.descText = makeDiv(this.buildingInfoElements.desc, null, ["text"], "");
this.buildingInfoElements.additionalInfo = makeDiv( this.buildingInfoElements.additionalInfo = makeDiv(
this.buildingInfoElements.desc, this.buildingInfoElements.desc,
null, ["additionalInfo"], null,
["additionalInfo"],
"" ""
); );
this.buildingInfoElements.hotkey = makeDiv(this.buildingInfoElements.desc, null, ["hotkey"], ""); this.buildingInfoElements.hotkey = makeDiv(this.buildingInfoElements.desc, null, ["hotkey"], "");
@ -135,9 +136,9 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
this.buildingInfoElements.tutorialImage.setAttribute( this.buildingInfoElements.tutorialImage.setAttribute(
"data-icon", "data-icon",
"building_tutorials/" + "building_tutorials/" +
metaBuilding.getId() + metaBuilding.getId() +
(variant === defaultBuildingVariant ? "" : "-" + variant) + (variant === defaultBuildingVariant ? "" : "-" + variant) +
".png" ".png"
); );
removeAllChildren(this.buildingInfoElements.additionalInfo); removeAllChildren(this.buildingInfoElements.additionalInfo);
@ -189,14 +190,15 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
makeDiv( makeDiv(
this.variantsElement, this.variantsElement,
null, ["explanation"], null,
["explanation"],
T.ingame.buildingPlacement.cycleBuildingVariants.replace( T.ingame.buildingPlacement.cycleBuildingVariants.replace(
"<key>", "<key>",
"<code class='keybinding'>" + "<code class='keybinding'>" +
this.root.keyMapper this.root.keyMapper
.getBinding(KEYMAPPINGS.placement.cycleBuildingVariants) .getBinding(KEYMAPPINGS.placement.cycleBuildingVariants)
.getKeyCodeString() + .getKeyCodeString() +
"</code>" "</code>"
) )
); );
@ -442,10 +444,12 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
parameters.context.translate(worldPos.x, worldPos.y); parameters.context.translate(worldPos.x, worldPos.y);
parameters.context.rotate(angle); parameters.context.rotate(angle);
parameters.context.drawImage( parameters.context.drawImage(
arrowSprite, -6, -globalConfig.halfTileSize - arrowSprite,
clamp((this.root.time.realtimeNow() * 1.5) % 1.0, 0, 1) * 1 * globalConfig.tileSize + -6,
globalConfig.halfTileSize - -globalConfig.halfTileSize -
6, clamp((this.root.time.realtimeNow() * 1.5) % 1.0, 0, 1) * 1 * globalConfig.tileSize +
globalConfig.halfTileSize -
6,
12, 12,
12 12
); );
@ -498,7 +502,8 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
// Go over all slots // Go over all slots
for ( for (
let acceptorDirectionIndex = 0; acceptorDirectionIndex < slot.directions.length; let acceptorDirectionIndex = 0;
acceptorDirectionIndex < slot.directions.length;
++acceptorDirectionIndex ++acceptorDirectionIndex
) { ) {
const direction = slot.directions[acceptorDirectionIndex]; const direction = slot.directions[acceptorDirectionIndex];
@ -529,7 +534,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
} else if ( } else if (
sourceBeltComp && sourceBeltComp &&
sourceStaticComp.localDirectionToWorld(sourceBeltComp.direction) === sourceStaticComp.localDirectionToWorld(sourceBeltComp.direction) ===
enumInvertedDirections[worldDirection] enumInvertedDirections[worldDirection]
) { ) {
// Belt connected // Belt connected
isConnected = true; isConnected = true;
@ -615,4 +620,4 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
} }
} }
} }

View File

@ -279,20 +279,20 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
* Tries to rotate the current building * Tries to rotate the current building
*/ */
tryRotate() { tryRotate() {
const selectedBuilding = this.currentMetaBuilding.get(); const selectedBuilding = this.currentMetaBuilding.get();
if (selectedBuilding) { if (selectedBuilding) {
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) { if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier).pressed) {
this.currentBaseRotation = (this.currentBaseRotation + 270) % 360; this.currentBaseRotation = (this.currentBaseRotation + 270) % 360;
} else { } else {
this.currentBaseRotation = (this.currentBaseRotation + 90) % 360; this.currentBaseRotation = (this.currentBaseRotation + 90) % 360;
}
const staticComp = this.fakeEntity.components.StaticMapEntity;
staticComp.rotation = this.currentBaseRotation;
} }
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() { deleteBelowCursor() {
const mousePosition = this.root.app.mousePosition; const mousePosition = this.root.app.mousePosition;
if (!mousePosition) { if (!mousePosition) {
@ -443,7 +443,8 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
} }
// Check if we should stop placement // Check if we should stop placement
if (!metaBuilding.getStayInPlacementMode() && if (
!metaBuilding.getStayInPlacementMode() &&
!this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).pressed && !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.placeMultiple).pressed &&
!this.root.app.settings.getAllSettings().alwaysMultiplace !this.root.app.settings.getAllSettings().alwaysMultiplace
) { ) {
@ -471,9 +472,9 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
console.warn("Invalid variant selected:", this.currentVariant.get()); console.warn("Invalid variant selected:", this.currentVariant.get());
} }
const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier) const direction = this.root.keyMapper.getBinding(KEYMAPPINGS.placement.rotateInverseModifier)
.pressed ? .pressed
-1 : ? -1
1; : 1;
const newIndex = safeModulo(index + direction, availableVariants.length); const newIndex = safeModulo(index + direction, availableVariants.length);
const newVariant = availableVariants[newIndex]; const newVariant = availableVariants[newIndex];
@ -804,4 +805,4 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
this.abortDragging(); this.abortDragging();
} }
} }

View File

@ -52,4 +52,4 @@ HUDBuildingsToolbar.bar = {
MetaDisplayBuilding, MetaDisplayBuilding,
], ],
htmlElementId: "ingame_HUD_BuildingsToolbar", htmlElementId: "ingame_HUD_BuildingsToolbar",
}; };

View File

@ -103,9 +103,9 @@ export class HUDMinerHighlight extends BaseHUDPart {
parameters.context.globalAlpha = 0.6; parameters.context.globalAlpha = 0.6;
parameters.context.font = "bold " + scale * 8 + "px GameFont"; parameters.context.font = "bold " + scale * 8 + "px GameFont";
parameters.context.fillText( parameters.context.fillText(
connectedEntities.length === 1 ? connectedEntities.length === 1
T.ingame.connectedMiners.one_miner : ? T.ingame.connectedMiners.one_miner
T.ingame.connectedMiners.n_miners.replace("<amount>", String(connectedEntities.length)), : T.ingame.connectedMiners.n_miners.replace("<amount>", String(connectedEntities.length)),
tooltipLocation.x + 10 * scale, tooltipLocation.x + 10 * scale,
tooltipLocation.y + 22 * scale tooltipLocation.y + 22 * scale
); );
@ -173,4 +173,4 @@ export class HUDMinerHighlight extends BaseHUDPart {
return results; return results;
} }
} }

View File

@ -15,7 +15,8 @@ export class HUDSettingsMenu extends BaseHUDPart {
this.statsElement = makeDiv( this.statsElement = makeDiv(
this.background, this.background,
null, ["statsElement"], null,
["statsElement"],
` `
<strong>${T.ingame.settingsMenu.beltsPlaced}</strong><span class="beltsPlaced"></span> <strong>${T.ingame.settingsMenu.beltsPlaced}</strong><span class="beltsPlaced"></span>
<strong>${T.ingame.settingsMenu.buildingsPlaced}</strong><span class="buildingsPlaced"></span> <strong>${T.ingame.settingsMenu.buildingsPlaced}</strong><span class="buildingsPlaced"></span>
@ -91,7 +92,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
buildingsPlacedElement.innerText = formatBigNumberFull( buildingsPlacedElement.innerText = formatBigNumberFull(
this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length - this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length -
this.root.entityMgr.getAllWithComponent(BeltComponent).length this.root.entityMgr.getAllWithComponent(BeltComponent).length
); );
beltsPlacedElement.innerText = formatBigNumberFull( beltsPlacedElement.innerText = formatBigNumberFull(
@ -110,7 +111,8 @@ export class HUDSettingsMenu extends BaseHUDPart {
} }
} }
HUDSettingsMenu.buttons = [{ HUDSettingsMenu.buttons = [
{
id: "continue", id: "continue",
action: hudSettingsMenu => () => hudSettingsMenu.close(), action: hudSettingsMenu => () => hudSettingsMenu.close(),
options: { options: {
@ -131,4 +133,4 @@ HUDSettingsMenu.buttons = [{
preventDefault: false, preventDefault: false,
}, },
}, },
]; ];

View File

@ -244,4 +244,4 @@ export class HUDShop extends BaseHUDPart {
isBlockingOverlay() { isBlockingOverlay() {
return this.visible; return this.visible;
} }
} }

View File

@ -44,12 +44,13 @@ export class HUDWaypoints extends BaseHUDPart {
* @param {HTMLElement} parent * @param {HTMLElement} parent
*/ */
createElements(parent) { createElements(parent) {
// Create the helper box on the lower right when zooming out // Create the helper box on the lower right when zooming out
if (this.root.app.settings.getAllSettings().offerHints) { if (this.root.app.settings.getAllSettings().offerHints) {
this.hintElement = makeDiv( this.hintElement = makeDiv(
parent, parent,
"ingame_HUD_Waypoints_Hint", [], "ingame_HUD_Waypoints_Hint",
` [],
`
<strong class='title'>${T.ingame.waypoints.waypoints}</strong> <strong class='title'>${T.ingame.waypoints.waypoints}</strong>
<span class='desc'>${T.ingame.waypoints.description.replace( <span class='desc'>${T.ingame.waypoints.description.replace(
"<keybinding>", "<keybinding>",
@ -643,4 +644,4 @@ export class HUDWaypoints extends BaseHUDPart {
parameters.context.textBaseline = "alphabetic"; parameters.context.textBaseline = "alphabetic";
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
} }
} }

View File

@ -36,7 +36,8 @@ export class HUDWireInfo extends BaseHUDPart {
return; return;
} }
if (!this.root.camera.getIsMapOverlayActive() && if (
!this.root.camera.getIsMapOverlayActive() &&
!this.root.logic.getIsEntityIntersectedWithMatrix(entity, worldPos) !this.root.logic.getIsEntityIntersectedWithMatrix(entity, worldPos)
) { ) {
// Detailed intersection check // Detailed intersection check
@ -115,4 +116,4 @@ export class HUDWireInfo extends BaseHUDPart {
} }
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
} }
} }

View File

@ -146,9 +146,9 @@ export class HUDWiresOverlay extends BaseHUDPart {
parameters.context.globalCompositeOperation = "source-over"; parameters.context.globalCompositeOperation = "source-over";
parameters.context.scale(scaleFactor, scaleFactor); parameters.context.scale(scaleFactor, scaleFactor);
parameters.context.fillStyle = hasTileGrid ? parameters.context.fillStyle = hasTileGrid
this.cachedPatternBackground : ? this.cachedPatternBackground
"rgba(78, 137, 125, 0.75)"; : "rgba(78, 137, 125, 0.75)";
parameters.context.fillRect( parameters.context.fillRect(
bounds.x / scaleFactor, bounds.x / scaleFactor,
bounds.y / scaleFactor, bounds.y / scaleFactor,
@ -159,4 +159,4 @@ export class HUDWiresOverlay extends BaseHUDPart {
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
} }
} }

View File

@ -45,4 +45,4 @@ HUDWiresToolbar.bar = {
MetaDisplayBuilding, MetaDisplayBuilding,
], ],
htmlElementId: "ingame_HUD_wires_toolbar", htmlElementId: "ingame_HUD_wires_toolbar",
}; };

View File

@ -15,4 +15,4 @@ export function initItemRegistry() {
const itemClass = shapezAPI.ingame.items[itemId]; const itemClass = shapezAPI.ingame.items[itemId];
gItemRegistry.register(itemClass); gItemRegistry.register(itemClass);
} }
} }

View File

@ -19,4 +19,4 @@ export function itemResolverSingleton(root, data) {
assertAlways(false, "Unknown item type: " + itemType); assertAlways(false, "Unknown item type: " + itemType);
} }
export const typeItemSingleton = types.obj(gItemRegistry, itemResolverSingleton); export const typeItemSingleton = types.obj(gItemRegistry, itemResolverSingleton);

View File

@ -93,7 +93,7 @@ export const BOOL_TRUE_SINGLETON = new BooleanItem(1);
* @returns {boolean} * @returns {boolean}
*/ */
export function isTrueItem(item) { 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") { if (item.getItemType() === "boolean") {
return !!( /** @type {BooleanItem} */ (item).value); return !!(/** @type {BooleanItem} */ (item).value);
} }
return true; return true;
} }

View File

@ -102,4 +102,4 @@ ColorItem.ITEM_SINGLETONS = {};
for (const color in enumColors) { for (const color in enumColors) {
ColorItem.ITEM_SINGLETONS[color] = new ColorItem(color); ColorItem.ITEM_SINGLETONS[color] = new ColorItem(color);
} }

View File

@ -79,4 +79,4 @@ export class ShapeItem extends BaseItem {
ShapeItem.resolveSingleton = (root, itemData) => { ShapeItem.resolveSingleton = (root, itemData) => {
return root.shapeDefinitionMgr.getShapeItemFromShortKey(itemData); return root.shapeDefinitionMgr.getShapeItemFromShortKey(itemData);
}; };

View File

@ -264,9 +264,9 @@ export function getStringForKeyCode(code) {
return "'"; return "'";
} }
return (48 <= code && code <= 57) || (65 <= code && code <= 90) ? return (48 <= code && code <= 57) || (65 <= code && code <= 90)
String.fromCharCode(code) : ? String.fromCharCode(code)
"[" + code + "]"; : "[" + code + "]";
} }
export class Keybinding { export class Keybinding {
@ -478,4 +478,4 @@ export class KeyActionMapper {
assert(this.keybindings[id], "Keybinding " + id + " not known!"); assert(this.keybindings[id], "Keybinding " + id + " not known!");
return this.keybindings[id]; return this.keybindings[id];
} }
} }

View File

@ -430,4 +430,4 @@ export class GameLogic {
} }
return { ejectors, acceptors }; return { ejectors, acceptors };
} }
} }

View File

@ -142,9 +142,9 @@ export class MapChunkView extends MapChunk {
*/ */
generateOverlayBuffer(canvas, context, w, h, dpi) { generateOverlayBuffer(canvas, context, w, h, dpi) {
context.fillStyle = context.fillStyle =
this.containedEntities.length > 0 ? this.containedEntities.length > 0
THEME.map.chunkOverview.filled : ? THEME.map.chunkOverview.filled
THEME.map.chunkOverview.empty; : THEME.map.chunkOverview.empty;
context.fillRect(0, 0, w, h); context.fillRect(0, 0, w, h);
if (this.root.app.settings.getAllSettings().displayChunkBorders) { if (this.root.app.settings.getAllSettings().displayChunkBorders) {
@ -350,4 +350,4 @@ export class MapChunkView extends MapChunk {
system.drawChunk_ForegroundLayer(parameters, this, layer); system.drawChunk_ForegroundLayer(parameters, this, layer);
} }
} }
} }

View File

@ -216,4 +216,4 @@ export class MapView extends BaseMap {
this.drawVisibleChunks(parameters, MapChunkView.prototype.drawBackgroundLayer); this.drawVisibleChunks(parameters, MapChunkView.prototype.drawBackgroundLayer);
} }
} }

View File

@ -142,9 +142,9 @@ export class MetaBuilding {
getPreviewSprite(rotationVariant = 0, variant = defaultBuildingVariant) { getPreviewSprite(rotationVariant = 0, variant = defaultBuildingVariant) {
return Loader.getSprite( return Loader.getSprite(
"sprites/buildings/" + "sprites/buildings/" +
this.id + this.id +
(variant === defaultBuildingVariant ? "" : "-" + variant) + (variant === defaultBuildingVariant ? "" : "-" + variant) +
".png" ".png"
); );
} }
@ -155,9 +155,9 @@ export class MetaBuilding {
getBlueprintSprite(rotationVariant = 0, variant = defaultBuildingVariant) { getBlueprintSprite(rotationVariant = 0, variant = defaultBuildingVariant) {
return Loader.getSprite( return Loader.getSprite(
"sprites/blueprints/" + "sprites/blueprints/" +
this.id + this.id +
(variant === defaultBuildingVariant ? "" : "-" + variant) + (variant === defaultBuildingVariant ? "" : "-" + variant) +
".png" ".png"
); );
} }
@ -232,9 +232,9 @@ export class MetaBuilding {
getSprite(rotationVariant, variant) { getSprite(rotationVariant, variant) {
return Loader.getSprite( return Loader.getSprite(
"sprites/buildings/" + "sprites/buildings/" +
this.id + this.id +
(variant === defaultBuildingVariant ? "" : "-" + variant) + (variant === defaultBuildingVariant ? "" : "-" + variant) +
".png" ".png"
); );
} }
@ -279,4 +279,4 @@ export class MetaBuilding {
setupEntityComponents(entity, root) { setupEntityComponents(entity, root) {
abstract; abstract;
} }
} }

View File

@ -187,4 +187,4 @@ export function initBuildingCodesAfterResourcesLoaded() {
variant.rotationVariant variant.rotationVariant
); );
} }
} }

View File

@ -43,7 +43,8 @@ function generateUpgrades(limitedVersion = false) {
} }
const upgrades = { const upgrades = {
belt: [{ belt: [
{
required: [{ shape: "CuCuCuCu", amount: 30 }], required: [{ shape: "CuCuCuCu", amount: 30 }],
}, },
{ {
@ -72,7 +73,8 @@ function generateUpgrades(limitedVersion = false) {
...generateInfiniteUnlocks(), ...generateInfiniteUnlocks(),
], ],
miner: [{ miner: [
{
required: [{ shape: "RuRuRuRu", amount: 300 }], required: [{ shape: "RuRuRuRu", amount: 300 }],
}, },
{ {
@ -101,7 +103,8 @@ function generateUpgrades(limitedVersion = false) {
...generateInfiniteUnlocks(), ...generateInfiniteUnlocks(),
], ],
processors: [{ processors: [
{
required: [{ shape: "SuSuSuSu", amount: 500 }], required: [{ shape: "SuSuSuSu", amount: 500 }],
}, },
{ {
@ -130,7 +133,8 @@ function generateUpgrades(limitedVersion = false) {
...generateInfiniteUnlocks(), ...generateInfiniteUnlocks(),
], ],
painting: [{ painting: [
{
required: [{ shape: "RbRb----", amount: 600 }], required: [{ shape: "RbRb----", amount: 600 }],
}, },
{ {
@ -317,115 +321,117 @@ export function generateLevelDefinitions(limitedVersion = false) {
}, },
// DEMO STOPS HERE // DEMO STOPS HERE
...(limitedVersion ? ...(limitedVersion
[{ ? [
shape: "RpRpRpRp:CwCwCwCw", {
required: 0, shape: "RpRpRpRp:CwCwCwCw",
reward: enumHubGoalRewards.reward_demo_end, required: 0,
}, ] : reward: enumHubGoalRewards.reward_demo_end,
[ },
// 14 ]
// Belt reader : [
{ // 14
shape: "--Cg----:--Cr----", // unused // Belt reader
required: 8, // Per second! {
reward: enumHubGoalRewards.reward_belt_reader, shape: "--Cg----:--Cr----", // unused
throughputOnly: true, required: 8, // Per second!
}, reward: enumHubGoalRewards.reward_belt_reader,
throughputOnly: true,
},
// 15 // 15
// Storage // Storage
{ {
shape: "SrSrSrSr:CyCyCyCy", // unused shape: "SrSrSrSr:CyCyCyCy", // unused
required: 10000, required: 10000,
reward: enumHubGoalRewards.reward_storage, reward: enumHubGoalRewards.reward_storage,
}, },
// 16 // 16
// Quad Cutter // Quad Cutter
{ {
shape: "SrSrSrSr:CyCyCyCy:SwSwSwSw", // belts t4 (two variants) shape: "SrSrSrSr:CyCyCyCy:SwSwSwSw", // belts t4 (two variants)
required: 6000, required: 6000,
reward: enumHubGoalRewards.reward_cutter_quad, reward: enumHubGoalRewards.reward_cutter_quad,
}, },
// 17 // 17
// Double painter // Double painter
{ {
shape: "CbRbRbCb:CwCwCwCw:WbWbWbWb", // miner t4 (two variants) shape: "CbRbRbCb:CwCwCwCw:WbWbWbWb", // miner t4 (two variants)
required: 20000, required: 20000,
reward: enumHubGoalRewards.reward_painter_double, reward: enumHubGoalRewards.reward_painter_double,
}, },
// 18 // 18
// Rotater (180deg) // Rotater (180deg)
{ {
shape: "Sg----Sg:CgCgCgCg:--CyCy--", // unused shape: "Sg----Sg:CgCgCgCg:--CyCy--", // unused
required: 20000, required: 20000,
reward: enumHubGoalRewards.reward_rotater_180, reward: enumHubGoalRewards.reward_rotater_180,
}, },
// 19 // 19
// Compact splitter // Compact splitter
{ {
shape: "CpRpCp--:SwSwSwSw", shape: "CpRpCp--:SwSwSwSw",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_splitter, reward: enumHubGoalRewards.reward_splitter,
}, },
// 20 // 20
// WIRES // WIRES
{ {
shape: finalGameShape, shape: finalGameShape,
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_wires_painter_and_levers, reward: enumHubGoalRewards.reward_wires_painter_and_levers,
}, },
// 21 // 21
// Filter // Filter
{ {
shape: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr", shape: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_filter, reward: enumHubGoalRewards.reward_filter,
}, },
// 22 // 22
// Constant signal // Constant signal
{ {
shape: "Cg----Cr:Cw----Cw:Sy------:Cy----Cy", shape: "Cg----Cr:Cw----Cw:Sy------:Cy----Cy",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_constant_signal, reward: enumHubGoalRewards.reward_constant_signal,
}, },
// 23 // 23
// Display // Display
{ {
shape: "CcSyCcSy:SyCcSyCc:CcSyCcSy", shape: "CcSyCcSy:SyCcSyCc:CcSyCcSy",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_display, reward: enumHubGoalRewards.reward_display,
}, },
// 24 Logic gates // 24 Logic gates
{ {
shape: "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy", shape: "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_logic_gates, reward: enumHubGoalRewards.reward_logic_gates,
}, },
// 25 Virtual Processing // 25 Virtual Processing
{ {
shape: "Rg--Rg--:CwRwCwRw:--Rg--Rg", shape: "Rg--Rg--:CwRwCwRw:--Rg--Rg",
required: 25000, required: 25000,
reward: enumHubGoalRewards.reward_virtual_processing, reward: enumHubGoalRewards.reward_virtual_processing,
}, },
// 26 Freeplay // 26 Freeplay
{ {
shape: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", shape: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw",
required: 50000, required: 50000,
reward: enumHubGoalRewards.reward_freeplay, reward: enumHubGoalRewards.reward_freeplay,
}, },
]), ]),
]; ];
if (G_IS_DEV) { if (G_IS_DEV) {
@ -457,9 +463,9 @@ export class RegularGameMode extends GameMode {
} }
getUpgrades() { getUpgrades() {
return this.root.app.restrictionMgr.getHasExtendedUpgrades() ? return this.root.app.restrictionMgr.getHasExtendedUpgrades()
fullVersionUpgrades : ? fullVersionUpgrades
demoVersionUpgrades; : demoVersionUpgrades;
} }
getIsFreeplayAvailable() { getIsFreeplayAvailable() {
@ -471,8 +477,8 @@ export class RegularGameMode extends GameMode {
} }
getLevelDefinitions() { getLevelDefinitions() {
return this.root.app.restrictionMgr.getHasExtendedLevelsAndFreeplay() ? return this.root.app.restrictionMgr.getHasExtendedLevelsAndFreeplay()
fullVersionLevels : ? fullVersionLevels
demoVersionLevels; : demoVersionLevels;
} }
} }

View File

@ -131,4 +131,4 @@ export class ProductionAnalytics extends BasicSerializableObject {
this.startNewSlice(); this.startNewSlice();
} }
} }
} }

View File

@ -222,4 +222,4 @@ export class GameRoot {
} }
} }
} }
} }

View File

@ -607,10 +607,12 @@ ShapeDefinition.renderQuad = {
context.beginPath(); context.beginPath();
context.moveTo(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize); context.moveTo(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize);
context.arc( context.arc(
insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize, insetPadding + -quadrantHalfSize,
quadrantSize * layerScale, -Math.PI * 0.5, -insetPadding + quadrantHalfSize,
quadrantSize * layerScale,
-Math.PI * 0.5,
0 0
); );
context.closePath(); context.closePath();
}, },
}; };

View File

@ -502,7 +502,7 @@ export class BeltSystem extends GameSystemWithFilter {
// 126 / 42 is the exact animation speed of the png animation // 126 / 42 is the exact animation speed of the png animation
const animationIndex = Math.floor( const animationIndex = Math.floor(
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) * ((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
globalConfig.itemSpacingOnBelts globalConfig.itemSpacingOnBelts
); );
const contents = chunk.containedEntitiesByLayer.regular; const contents = chunk.containedEntitiesByLayer.regular;
@ -555,4 +555,4 @@ export class BeltSystem extends GameSystemWithFilter {
this.beltPaths[i].drawDebug(parameters); this.beltPaths[i].drawDebug(parameters);
} }
} }
} }

View File

@ -30,9 +30,9 @@ export class BeltReaderSystem extends GameSystemWithFilter {
pinsComp.slots[1].value = readerComp.lastItem; pinsComp.slots[1].value = readerComp.lastItem;
pinsComp.slots[0].value = pinsComp.slots[0].value =
(readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) >
minimumTimeForThroughput ? minimumTimeForThroughput
BOOL_TRUE_SINGLETON : ? BOOL_TRUE_SINGLETON
BOOL_FALSE_SINGLETON; : BOOL_FALSE_SINGLETON;
if (now - readerComp.lastThroughputComputation > 0.5) { if (now - readerComp.lastThroughputComputation > 0.5) {
// Compute throughput // Compute throughput
@ -56,4 +56,4 @@ export class BeltReaderSystem extends GameSystemWithFilter {
} }
} }
} }
} }

View File

@ -252,12 +252,14 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter {
} }
// Culling, Part 2: Check if the overlay is visible // Culling, Part 2: Check if the overlay is visible
if (!parameters.visibleRect.containsRect4Params( if (
!parameters.visibleRect.containsRect4Params(
destX, destX,
destY, destY,
globalConfig.tileSize, globalConfig.tileSize,
globalConfig.tileSize globalConfig.tileSize
)) { )
) {
continue; continue;
} }
@ -280,14 +282,16 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter {
// SYNC with systems/belt.js:drawSingleEntity! // SYNC with systems/belt.js:drawSingleEntity!
const animationIndex = Math.floor( const animationIndex = Math.floor(
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) * ((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
globalConfig.itemSpacingOnBelts globalConfig.itemSpacingOnBelts
); );
parameters.context.translate(x, y); parameters.context.translate(x, y);
parameters.context.rotate(angleRadians); parameters.context.rotate(angleRadians);
this.underlayBeltSprites[ this.underlayBeltSprites[
animationIndex % this.underlayBeltSprites.length animationIndex % this.underlayBeltSprites.length
].drawCachedWithClipRect( ].drawCachedWithClipRect(
parameters, -globalConfig.halfTileSize, -globalConfig.halfTileSize, parameters,
-globalConfig.halfTileSize,
-globalConfig.halfTileSize,
globalConfig.tileSize, globalConfig.tileSize,
globalConfig.tileSize, globalConfig.tileSize,
clipRect clipRect
@ -297,4 +301,4 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter {
} }
} }
} }
} }

View File

@ -172,4 +172,4 @@ export class ConstantSignalSystem extends GameSystemWithFilter {
return null; return null;
} }
} }

View File

@ -86,7 +86,7 @@ DisplaySystem.displayItemType = {
DisplaySystem.displayItem = { DisplaySystem.displayItem = {
color: (parameters, value, origin, globalConfig) => color: (parameters, value, origin, globalConfig) =>
DisplaySystem.displaySprites[ /** @type {ColorItem} */ (value).color].drawCachedCentered( DisplaySystem.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(
parameters, parameters,
(origin.x + 0.5) * globalConfig.tileSize, (origin.x + 0.5) * globalConfig.tileSize,
(origin.y + 0.5) * globalConfig.tileSize, (origin.y + 0.5) * globalConfig.tileSize,
@ -104,4 +104,4 @@ DisplaySystem.displayItem = {
}; };
DisplaySystem.shapeRadius = () => 30; DisplaySystem.shapeRadius = () => 30;
DisplaySystem.shapeBackground = () => true; DisplaySystem.shapeBackground = () => true;

Some files were not shown because too many files have changed in this diff Show More