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
@function strip-unit($number) {
@if type-of($number)=="number" and not unitless($number) {
@if type-of($number) == "number" and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
@ -25,13 +25,13 @@
$impSuffix: "!important";
}
$v1: D($v1);
@if $v2 !="" {
@if $v2 != "" {
$v2: D($v2);
}
@if $v3 !="" {
@if $v3 != "" {
$v3: D($v3);
}
@if $v4 !="" {
@if $v4 != "" {
$v4: D($v4);
}
#{$propName}: #{$v1} #{$v2} #{$v3} #{$v4} #{$impSuffix};

View File

@ -1,27 +1,6 @@
$buildings: belt,
cutter,
miner,
mixer,
painter,
rotater,
balancer,
stacker,
trash,
underground_belt,
wire,
constant_signal,
logic_gate,
lever,
filter,
wire_tunnel,
display,
virtual_processor,
reader,
storage,
transistor,
analyzer,
comparator,
item_producer;
$buildings: belt, cutter, miner, mixer, painter, rotater, balancer, stacker, trash, underground_belt, wire,
constant_signal, logic_gate, lever, filter, wire_tunnel, display, virtual_processor, reader, storage,
transistor, analyzer, comparator, item_producer;
@each $building in $buildings {
[data-icon="building_icons/#{$building}.png"] {
/* @load-async */
@ -29,41 +8,11 @@ item_producer;
}
}
$buildingsAndVariants: belt,
balancer,
underground_belt,
underground_belt-tier2,
miner,
miner-chainable,
cutter,
cutter-quad,
rotater,
rotater-ccw,
stacker,
mixer,
painter-double,
painter-quad,
trash,
storage,
reader,
rotater-rotate180,
display,
constant_signal,
wire,
wire_tunnel,
logic_gate-or,
logic_gate-not,
logic_gate-xor,
analyzer,
virtual_processor-rotater,
virtual_processor-unstacker,
item_producer,
virtual_processor-stacker,
virtual_processor-painter,
wire-second,
painter,
painter-mirrored,
comparator;
$buildingsAndVariants: belt, balancer, underground_belt, underground_belt-tier2, miner, miner-chainable,
cutter, cutter-quad, rotater, rotater-ccw, stacker, mixer, painter-double, painter-quad, trash, storage,
reader, rotater-rotate180, display, constant_signal, wire, wire_tunnel, logic_gate-or, logic_gate-not,
logic_gate-xor, analyzer, virtual_processor-rotater, virtual_processor-unstacker, item_producer,
virtual_processor-stacker, virtual_processor-painter, wire-second, painter, painter-mirrored, comparator;
@each $building in $buildingsAndVariants {
[data-icon="building_tutorials/#{$building}.png"] {
/* @load-async */
@ -108,9 +57,7 @@ comparator;
background-image: uiResource("res/ui/building_tutorials/virtual_processor-cutter.png") !important;
}
$icons: notification_saved,
notification_success,
notification_upgrade;
$icons: notification_saved, notification_success, notification_upgrade;
@each $icon in $icons {
[data-icon="icons/#{$icon}.png"] {
/* @load-async */
@ -118,34 +65,8 @@ notification_upgrade;
}
}
$languages: en,
de,
cs,
da,
et,
es-419,
fr,
it,
pt-BR,
sv,
tr,
el,
ru,
uk,
zh-TW,
zh-CN,
nb,
mt-MT,
ar,
nl,
vi,
th,
hu,
pl,
ja,
kor,
no,
pt-PT;
$languages: en, de, cs, da, et, es-419, fr, it, pt-BR, sv, tr, el, ru, uk, zh-TW, zh-CN, nb, mt-MT, ar, nl, vi,
th, hu, pl, ja, kor, no, pt-PT;
@each $language in $languages {
[data-languageicon="#{$language}"] {
/* @load-async */
@ -153,7 +74,6 @@ pt-PT;
}
}
/*
PRICE
*/

View File

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

View File

@ -1,36 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<title>shapez.io - Build automated factories to build, combine and color shapes!</title>
<head>
<title>shapez.io - Build automated factories to build, combine and color shapes!</title>
<!-- mobile stuff -->
<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 -->
<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" />
<!-- seo -->
<meta name="copyright" content="2020 Tobias Springer IT Solutions and .io Games" />
<meta name="author" content="Tobias Springer, tobias.springer1@gmail.com" />
<meta
name="description"
content="shapez.io is an open-source factory building game about combining and producing different types of shapes."
/>
<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 -->
<meta name="copyright" content="2020 Tobias Springer IT Solutions and .io Games" />
<meta name="author" content="Tobias Springer, tobias.springer1@gmail.com" />
<meta name="description" content="shapez.io is an open-source factory building game about combining and producing different types of shapes." />
<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" />
<!-- misc -->
<meta http-equiv="Cache-Control" content="private, max-age=0, no-store, no-cache, must-revalidate" />
<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>
<!-- misc -->
<meta http-equiv="Cache-Control" content="private, max-age=0, no-store, no-cache, must-revalidate" />
<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

@ -1,7 +1,8 @@
/**
* @type {Array<{version: string, date: string, entries: Array<String>}>} changelog
*/
export const CHANGELOG = [{
export const CHANGELOG = [
{
version: "1.2.3",
date: "unreleased",
entries: [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -334,9 +334,9 @@ export function formatBigNumberFull(num, divider = T.global.thousandsDivider) {
* @returns {Promise<void>}
*/
export function waitNextFrame() {
return new Promise(function(resolve) {
window.requestAnimationFrame(function() {
window.requestAnimationFrame(function() {
return new Promise(function (resolve) {
window.requestAnimationFrame(function () {
window.requestAnimationFrame(function () {
resolve();
});
});
@ -573,12 +573,12 @@ export function round1DigitLocalized(speed, separator = T.global.decimalSeparato
* @param {string=} separator The decimal separator for numbers like 50.1 (separator='.')
*/
export function formatItemsPerSecond(speed, double = false, separator = T.global.decimalSeparator) {
return speed === 1.0 ?
T.ingame.buildingPlacement.infoTexts.oneItemPerSecond :
T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace(
"<x>",
round2Digits(speed).toString().replace(".", separator)
) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : "");
return speed === 1.0
? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond
: T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace(
"<x>",
round2Digits(speed).toString().replace(".", separator)
) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : "");
}
/**

View File

@ -33,7 +33,7 @@ export const gBuildingVariants = {
*/
export function registerBuildingVariant(
meta,
variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */ ,
variant = "default" /* @TODO: Circular dependency, actually its defaultBuildingVariant */,
rotationVariant = 0
) {
// @ts-ignore

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,7 +93,7 @@ export const BOOL_TRUE_SINGLETON = new BooleanItem(1);
* @returns {boolean}
*/
export function isTrueItem(item) {
return item && item.getItemType() === "boolean" && !!( /** @type {BooleanItem} */ (item).value);
return item && item.getItemType() === "boolean" && !!(/** @type {BooleanItem} */ (item).value);
}
/**
@ -107,7 +107,7 @@ export function isTruthyItem(item) {
}
if (item.getItemType() === "boolean") {
return !!( /** @type {BooleanItem} */ (item).value);
return !!(/** @type {BooleanItem} */ (item).value);
}
return true;

View File

@ -264,9 +264,9 @@ export function getStringForKeyCode(code) {
return "'";
}
return (48 <= code && code <= 57) || (65 <= code && code <= 90) ?
String.fromCharCode(code) :
"[" + code + "]";
return (48 <= code && code <= 57) || (65 <= code && code <= 90)
? String.fromCharCode(code)
: "[" + code + "]";
}
export class Keybinding {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -84,6 +84,6 @@ export class FilterSystem extends GameSystemWithFilter {
}
FilterSystem.listToCheck = (entity, slot, item, filterComp, networkValue) =>
networkValue.equals(BOOL_TRUE_SINGLETON) || networkValue.equals(item) ?
filterComp.pendingItemsToLeaveThrough :
filterComp.pendingItemsToReject;
networkValue.equals(BOOL_TRUE_SINGLETON) || networkValue.equals(item)
? filterComp.pendingItemsToLeaveThrough
: filterComp.pendingItemsToReject;

View File

@ -35,23 +35,23 @@ export class HubSystem extends GameSystemWithFilter {
}
update() {
for (let i = 0; i < this.allEntities.length; ++i) {
// Set hub goal
const entity = this.allEntities[i];
const pinsComp = entity.components.WiredPins;
pinsComp.slots[0].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
this.root.hubGoals.currentGoal.definition
);
}
for (let i = 0; i < this.allEntities.length; ++i) {
// Set hub goal
const entity = this.allEntities[i];
const pinsComp = entity.components.WiredPins;
pinsComp.slots[0].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
this.root.hubGoals.currentGoal.definition
);
}
/**
*
* @param {HTMLCanvasElement} canvas
* @param {CanvasRenderingContext2D} context
* @param {number} w
* @param {number} h
* @param {number} dpi
*/
}
/**
*
* @param {HTMLCanvasElement} canvas
* @param {CanvasRenderingContext2D} context
* @param {number} w
* @param {number} h
* @param {number} dpi
*/
redrawHubBaseTexture(canvas, context, w, h, dpi) {
// This method is quite ugly, please ignore it!

View File

@ -147,7 +147,7 @@ export class ItemProcessorOverlaysSystem extends GameSystem {
}
ItemProcessorOverlaysSystem.processorOverlayStatic = {
[enumItemProcessorRequirements.painterQuad]: function(parameters, chunk, entity, processorComp) {
[enumItemProcessorRequirements.painterQuad]: function (parameters, chunk, entity, processorComp) {
this.drawConnectedSlotRequirement(parameters, entity, { drawIfFalse: true });
},
};

View File

@ -104,9 +104,9 @@ export class LogicGateSystem extends GameSystemWithFilter {
*/
compute_AND(parameters) {
assert(parameters.length === 2, "bad parameter count for AND");
return isTruthyItem(parameters[0]) && isTruthyItem(parameters[1]) ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
return isTruthyItem(parameters[0]) && isTruthyItem(parameters[1])
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
/**
@ -123,9 +123,9 @@ export class LogicGateSystem extends GameSystemWithFilter {
*/
compute_XOR(parameters) {
assert(parameters.length === 2, "bad parameter count for XOR");
return isTruthyItem(parameters[0]) !== isTruthyItem(parameters[1]) ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
return isTruthyItem(parameters[0]) !== isTruthyItem(parameters[1])
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
/**
@ -134,9 +134,9 @@ export class LogicGateSystem extends GameSystemWithFilter {
*/
compute_OR(parameters) {
assert(parameters.length === 2, "bad parameter count for OR");
return isTruthyItem(parameters[0]) || isTruthyItem(parameters[1]) ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
return isTruthyItem(parameters[0]) || isTruthyItem(parameters[1])
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
/**
@ -226,12 +226,12 @@ export class LogicGateSystem extends GameSystemWithFilter {
const definition = /** @type {ShapeItem} */ (item).definition;
const result = this.root.shapeDefinitionMgr.shapeActionCutHalf(definition);
return [
result[0].isEntirelyEmpty() ?
null :
this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]),
result[1].isEntirelyEmpty() ?
null :
this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]),
result[0].isEntirelyEmpty()
? null
: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]),
result[1].isEntirelyEmpty()
? null
: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]),
];
}
@ -258,9 +258,9 @@ export class LogicGateSystem extends GameSystemWithFilter {
lowerLayers.length > 0 ? new ShapeDefinition({ layers: lowerLayers }) : null;
return [
lowerLayerDefinition ?
this.root.shapeDefinitionMgr.getShapeItemFromDefinition(lowerLayerDefinition) :
null,
lowerLayerDefinition
? this.root.shapeDefinitionMgr.getShapeItemFromDefinition(lowerLayerDefinition)
: null,
this.root.shapeDefinitionMgr.getShapeItemFromDefinition(upperLayerDefinition),
];
}
@ -340,32 +340,28 @@ export class LogicGateSystem extends GameSystemWithFilter {
}
switch (itemA.getItemType()) {
case "shape":
{
return /** @type {ShapeItem} */ (itemA).definition.getHash() ===
/** @type {ShapeItem} */
(itemB).definition.getHash() ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
}
case "color":
{
return /** @type {ColorItem} */ (itemA).color === /** @type {ColorItem} */ (itemB).color ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
}
case "shape": {
return /** @type {ShapeItem} */ (itemA).definition.getHash() ===
/** @type {ShapeItem} */
(itemB).definition.getHash()
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
case "color": {
return /** @type {ColorItem} */ (itemA).color === /** @type {ColorItem} */ (itemB).color
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
case "boolean":
{
return /** @type {BooleanItem} */ (itemA).value === /** @type {BooleanItem} */ (itemB).value ?
BOOL_TRUE_SINGLETON :
BOOL_FALSE_SINGLETON;
}
case "boolean": {
return /** @type {BooleanItem} */ (itemA).value === /** @type {BooleanItem} */ (itemB).value
? BOOL_TRUE_SINGLETON
: BOOL_FALSE_SINGLETON;
}
default:
{
assertAlways(false, "Bad item type: " + itemA.getItemType());
}
default: {
assertAlways(false, "Bad item type: " + itemA.getItemType());
}
}
}
}

View File

@ -254,7 +254,8 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
// Search in the direction of the tunnel
for (
let searchOffset = 0; searchOffset < globalConfig.undergroundBeltMaxTilesByTier[undergroundComp.tier];
let searchOffset = 0;
searchOffset < globalConfig.undergroundBeltMaxTilesByTier[undergroundComp.tier];
++searchOffset
) {
currentTile = currentTile.add(searchVector);

View File

@ -217,10 +217,12 @@ export class WireSystem extends GameSystemWithFilter {
currentNetwork.uid,
")"
);
const entitiesToVisit = [{
entity: initialEntity,
slot,
}, ];
const entitiesToVisit = [
{
entity: initialEntity,
slot,
},
];
/**
* Once we occur a wire, we store its variant so we don't connect to
@ -245,13 +247,14 @@ export class WireSystem extends GameSystemWithFilter {
//// WIRE
if (wireComp) {
// Sanity check
assert(!wireComp.linkedNetwork || wireComp.linkedNetwork === currentNetwork,
assert(
!wireComp.linkedNetwork || wireComp.linkedNetwork === currentNetwork,
"Mismatching wire network on wire entity " +
(wireComp.linkedNetwork ? wireComp.linkedNetwork.uid : "<empty>") +
" vs " +
currentNetwork.uid +
" @ " +
staticComp.origin.toString()
(wireComp.linkedNetwork ? wireComp.linkedNetwork.uid : "<empty>") +
" vs " +
currentNetwork.uid +
" @ " +
staticComp.origin.toString()
);
if (!wireComp.linkedNetwork) {
@ -287,11 +290,12 @@ export class WireSystem extends GameSystemWithFilter {
}
// Sanity check
assert(!slot.linkedNetwork || slot.linkedNetwork === currentNetwork,
assert(
!slot.linkedNetwork || slot.linkedNetwork === currentNetwork,
"Mismatching wire network on pin slot entity " +
(slot.linkedNetwork ? slot.linkedNetwork.uid : "<empty>") +
" vs " +
currentNetwork.uid
(slot.linkedNetwork ? slot.linkedNetwork.uid : "<empty>") +
" vs " +
currentNetwork.uid
);
if (!slot.linkedNetwork) {
// This one is new

View File

@ -121,9 +121,11 @@ export class WiredPinsSystem extends GameSystemWithFilter {
if (collidingEntity) {
const staticComp = collidingEntity.components.StaticMapEntity;
const data = getBuildingDataFromCode(staticComp.code);
if (!collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(
if (
!collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(
data.variant
)) {
)
) {
return true;
}
}
@ -193,7 +195,9 @@ export class WiredPinsSystem extends GameSystemWithFilter {
const worldPos = tile.toWorldSpaceCenterOfTile();
// Culling
if (!parameters.visibleRect.containsCircle(worldPos.x, worldPos.y, globalConfig.halfTileSize)) {
if (
!parameters.visibleRect.containsCircle(worldPos.x, worldPos.y, globalConfig.halfTileSize)
) {
continue;
}

View File

@ -28,31 +28,15 @@ const typed = x => x;
* @enum {TutorialGoalReward?}
*/
export const enumHubGoalRewardsToContentUnlocked = {
[enumHubGoalRewards.reward_cutter_and_trash]: typed([
[MetaCutterBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_rotater]: typed([
[MetaRotaterBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_painter]: typed([
[MetaPainterBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_mixer]: typed([
[MetaMixerBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_stacker]: typed([
[MetaStackerBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_balancer]: typed([
[MetaBalancerBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_tunnel]: typed([
[MetaUndergroundBeltBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_cutter_and_trash]: typed([[MetaCutterBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_rotater]: typed([[MetaRotaterBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_painter]: typed([[MetaPainterBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_mixer]: typed([[MetaMixerBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_stacker]: typed([[MetaStackerBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_balancer]: typed([[MetaBalancerBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_tunnel]: typed([[MetaUndergroundBeltBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_rotater_ccw]: typed([
[MetaRotaterBuilding, MetaRotaterBuilding.variants.ccw]
]),
[enumHubGoalRewards.reward_rotater_ccw]: typed([[MetaRotaterBuilding, MetaRotaterBuilding.variants.ccw]]),
[enumHubGoalRewards.reward_rotater_180]: typed([
[MetaRotaterBuilding, MetaRotaterBuilding.variants.rotate180],
]),
@ -65,34 +49,20 @@ export const enumHubGoalRewardsToContentUnlocked = {
[enumHubGoalRewards.reward_splitter]: typed([
[MetaBalancerBuilding, MetaBalancerBuilding.variants.splitter],
]),
[enumHubGoalRewards.reward_merger]: typed([
[MetaBalancerBuilding, MetaBalancerBuilding.variants.merger]
]),
[enumHubGoalRewards.reward_cutter_quad]: typed([
[MetaCutterBuilding, MetaCutterBuilding.variants.quad]
]),
[enumHubGoalRewards.reward_merger]: typed([[MetaBalancerBuilding, MetaBalancerBuilding.variants.merger]]),
[enumHubGoalRewards.reward_cutter_quad]: typed([[MetaCutterBuilding, MetaCutterBuilding.variants.quad]]),
[enumHubGoalRewards.reward_painter_double]: typed([
[MetaPainterBuilding, MetaPainterBuilding.variants.double],
]),
[enumHubGoalRewards.reward_storage]: typed([
[MetaStorageBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_storage]: typed([[MetaStorageBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_belt_reader]: typed([
[MetaReaderBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_display]: typed([
[MetaDisplayBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_belt_reader]: typed([[MetaReaderBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_display]: typed([[MetaDisplayBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_constant_signal]: typed([
[MetaConstantSignalBuilding, defaultBuildingVariant],
]),
[enumHubGoalRewards.reward_logic_gates]: typed([
[MetaLogicGateBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_filter]: typed([
[MetaFilterBuilding, defaultBuildingVariant]
]),
[enumHubGoalRewards.reward_logic_gates]: typed([[MetaLogicGateBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_filter]: typed([[MetaFilterBuilding, defaultBuildingVariant]]),
[enumHubGoalRewards.reward_virtual_processing]: null,
[enumHubGoalRewards.reward_wires_painter_and_levers]: typed([

View File

@ -15,7 +15,7 @@ import { addVanillaSystemsToAPI } from "./game/game_system_manager";
import { addVanillaGameModesToAPI } from "./game/game_mode_registry";
import { getIPCRenderer } from "./core/utils";
const logger = createLogger("main");
window.onload = async() => {
window.onload = async () => {
if (window.coreThreadLoadedCb) {
logger.log("Javascript parsed, calling html thread");
window.coreThreadLoadedCb();

View File

@ -941,7 +941,8 @@ export class ShapezAPI {
sourceImage.crossOrigin = "anonymous";
sourceImage.onload = () => {
// @ts-ignore
Loader.internalParseAtlas({
Loader.internalParseAtlas(
{
meta: atlasData.atlasData.meta,
sourceData: atlasData.atlasData.frames,
},

View File

@ -112,14 +112,14 @@ export class ModManager {
});
} else
return Promise.race([
new Promise((resolve, reject) => {
setTimeout(reject, 60 * 1000);
}),
fetch(url, {
method: "GET",
cache: "no-cache",
}),
])
new Promise((resolve, reject) => {
setTimeout(reject, 60 * 1000);
}),
fetch(url, {
method: "GET",
cache: "no-cache",
}),
])
.then(res => res.text())
.catch(err => {
assert(this, "Failed to load mod:", err);
@ -208,9 +208,9 @@ export class ModManager {
if (isMissingDependecie) {
console.warn(
"Mod with mod id: " +
mod.id +
" is disabled because it's missings the dependecie " +
missingDependecie
mod.id +
" is disabled because it's missings the dependecie " +
missingDependecie
);
continue;
} else sorter.add(id, mod.dependencies);

View File

@ -24,7 +24,8 @@ export const enumCategories = {
debug: "debug",
};
export const uiScales = [{
export const uiScales = [
{
id: "super_small",
size: 0.6,
},
@ -46,7 +47,8 @@ export const uiScales = [{
},
];
export const scrollWheelSensitivities = [{
export const scrollWheelSensitivities = [
{
id: "super_slow",
scale: 0.25,
},
@ -68,7 +70,8 @@ export const scrollWheelSensitivities = [{
},
];
export const movementSpeeds = [{
export const movementSpeeds = [
{
id: "super_slow",
multiplier: 0.25,
},
@ -94,7 +97,8 @@ export const movementSpeeds = [{
},
];
export const autosaveIntervals = [{
export const autosaveIntervals = [
{
id: "one_minute",
seconds: 60,
},
@ -150,9 +154,9 @@ export const allApplicationSettings = () => {
category: enumCategories.userInterface,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
(app, id) => app.updateAfterUiScaleChanged(),
}),
@ -208,17 +212,17 @@ export const allApplicationSettings = () => {
category: enumCategories.userInterface,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
(app, id) => {
applyGameTheme(id);
document.documentElement.setAttribute("data-theme", id);
},
applyGameTheme(id);
document.documentElement.setAttribute("data-theme", id);
},
enabledCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
app => app.restrictionMgr.getHasExtendedSettings(),
}),
@ -229,9 +233,9 @@ export const allApplicationSettings = () => {
category: enumCategories.advanced,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
(app, id) => null,
}),
@ -242,9 +246,9 @@ export const allApplicationSettings = () => {
category: enumCategories.advanced,
restartRequired: false,
changeCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
(app, id) => app.updateAfterUiScaleChanged(),
}),
@ -278,9 +282,9 @@ export const allApplicationSettings = () => {
restartRequired: false,
changeCb: (app, id) => {},
enabledCb:
/**
* @param {Application} app
*/
/**
* @param {Application} app
*/
app => app.restrictionMgr.getHasExtendedSettings(),
}),
@ -372,7 +376,7 @@ export class ApplicationSettings extends ReadWriteProxy {
}
})
.then(() => this.writeAsync());
.then(() => this.writeAsync());
}
save() {
@ -510,12 +514,12 @@ export class ApplicationSettings extends ReadWriteProxy {
* @param {string} id
*/
resetKeybindingOverride(id) {
delete this.getAllSettings().keybindingOverrides[id];
return this.writeAsync();
}
/**
* Resets all keybinding overrides
*/
delete this.getAllSettings().keybindingOverrides[id];
return this.writeAsync();
}
/**
* Resets all keybinding overrides
*/
resetKeybindingOverrides() {
this.getAllSettings().keybindingOverrides = {};
return this.writeAsync();
@ -537,14 +541,14 @@ export class ApplicationSettings extends ReadWriteProxy {
if (!setting.validate(storedValue)) {
return ExplainedResult.bad(
"Bad setting value for " +
setting.id +
": " +
storedValue +
" @ settings version " +
data.version +
" (latest is " +
this.getCurrentVersion() +
")"
setting.id +
": " +
storedValue +
" @ settings version " +
data.version +
" (latest is " +
this.getCurrentVersion() +
")"
);
}
}

View File

@ -117,7 +117,8 @@ export class BaseSetting {
export class EnumSetting extends BaseSetting {
constructor(
id, {
id,
{
options,
valueGetter,
textGetter,
@ -145,8 +146,8 @@ export class EnumSetting extends BaseSetting {
* @param {Application} app
*/
getHtml(app) {
const available = this.getIsAvailable(app);
return `
const available = this.getIsAvailable(app);
return `
<div class="setting cardbox ${available ? "enabled" : "disabled"}">
${available ? "" : `<span class="standaloneOnlyHint">${T.demo.settingNotAvailable}</span>`}
<div class="row">

View File

@ -151,12 +151,12 @@ export class Savegame extends ReadWriteProxy {
* @returns {boolean}
*/
isSaveable() {
return true;
}
/**
* Returns the statistics of the savegame
* @returns {import("./savegame_typedefs").SavegameStats}
*/
return true;
}
/**
* Returns the statistics of the savegame
* @returns {import("./savegame_typedefs").SavegameStats}
*/
getStatistics() {
return this.currentData.stats;
}

View File

@ -150,7 +150,8 @@ export class SavegameManager extends ReadWriteProxy {
this.updateAfterSavegamesChanged();
return new Savegame(
this.app, {
this.app,
{
internalId: id,
metaDataRef: metaData,
},

View File

@ -699,7 +699,7 @@ export class TypeClassData extends BaseDataType {
for (let i = 0; i < entries.length; ++i) {
const entry = entries[i];
options.push(
schemaToJsonSchema( /** @type {typeof BasicSerializableObject} */ (entry).getCachedSchema())
schemaToJsonSchema(/** @type {typeof BasicSerializableObject} */ (entry).getCachedSchema())
);
}
return { oneOf: options };
@ -1197,7 +1197,8 @@ export class TypeNullable extends BaseDataType {
getAsJsonSchemaUncached() {
return {
oneOf: [{
oneOf: [
{
type: "null",
},
this.wrapped.getAsJsonSchema(),

View File

@ -155,7 +155,8 @@ export class KeybindingsState extends TextualGameState {
resetBindings() {
const { reset } = this.dialogs.showWarning(
T.dialogs.resetKeybindingsConfirmation.title,
T.dialogs.resetKeybindingsConfirmation.desc, ["cancel:good", "reset:bad"]
T.dialogs.resetKeybindingsConfirmation.desc,
["cancel:good", "reset:bad"]
);
reset.add(() => {

View File

@ -32,15 +32,15 @@ export class MainMenuState extends GameState {
}
getInnerHTML() {
const bannerHtml = `
const bannerHtml = `
<h3>${T.demoBanners.title}</h3>
<p>${T.demoBanners.intro}</p>
<a href="#" class="steamLink ${A_B_TESTING_LINK_TYPE}" target="_blank">Get the shapez.io standalone!</a>
`;
const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive();
const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive();
return `
return `
<div class="topButtons">
<button class="languageChoose" data-languageicon="${this.app.settings.getLanguage()}"></button>
<button class="settingsButton"></button>

View File

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

View File

@ -12,7 +12,7 @@ export class SettingsState extends TextualGameState {
}
getMainContentHTML() {
return `<div class="sidebar">
return `<div class="sidebar">
${this.getCategoryButtonsHtml()}
${
this.app.platformWrapper.getSupportsKeyboard()

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2018","WebWorker"]
"lib": ["ES2018", "WebWorker"]
},
"exclude": [],
"extends": "../tsconfig",