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

Fixed static and loading errors

This commit is contained in:
DJ1TJOO 2021-03-14 17:38:09 +01:00
parent 2f872af3e4
commit 07dff668d3
11 changed files with 503 additions and 573 deletions

View File

@ -51,19 +51,6 @@ if (typeof document.hidden !== "undefined") {
} }
export class Application { export class Application {
static trackClicks = undefined;
static getMainContentHTML = undefined;
static states = {
PreloadState,
MobileWarningState,
MainMenuState,
InGameState,
SettingsState,
KeybindingsState,
AboutState,
ChangelogState,
};
constructor() { constructor() {
assert(!GLOBAL_APP, "Tried to construct application twice"); assert(!GLOBAL_APP, "Tried to construct application twice");
logger.log("Creating application, platform =", getPlatformName()); logger.log("Creating application, platform =", getPlatformName());
@ -415,3 +402,16 @@ export class Application {
this.checkResize(true); this.checkResize(true);
} }
} }
Application.trackClicks = undefined;
Application.getMainContentHTML = undefined;
Application.states = {
PreloadState,
MobileWarningState,
MainMenuState,
InGameState,
SettingsState,
KeybindingsState,
AboutState,
ChangelogState,
};

View File

@ -318,7 +318,7 @@ export class ReadWriteProxy {
if (!data) { if (!data) {
return ExplainedResult.bad("Data is empty"); return ExplainedResult.bad("Data is empty");
} }
if (!savegameInterfaces[data.version]) { if (!savegameInterfaces[data.version] && data.version !== this.getCurrentVersion()) {
return ExplainedResult.bad( return ExplainedResult.bad(
`Data has invalid version: ${data.version} (expected ${this.getCurrentVersion()})` `Data has invalid version: ${data.version} (expected ${this.getCurrentVersion()})`
); );

View File

@ -503,8 +503,9 @@ export class HubGoals extends BasicSerializableObject {
return 1 / globalConfig.beltSpeedItemsPerSecond; return 1 / globalConfig.beltSpeedItemsPerSecond;
} }
}
static getProcessorBaseSpeed = { HubGoals.getProcessorBaseSpeed = {
trash: processorType => 1e30, trash: processorType => 1e30,
hub: processorType => 1e30, hub: processorType => 1e30,
balancer: function (processorType) { balancer: function (processorType) {
@ -625,4 +626,3 @@ export class HubGoals extends BasicSerializableObject {
); );
}, },
}; };
}

View File

@ -359,8 +359,8 @@ export class MapChunk {
} }
} }
} }
}
static predefined = [ MapChunk.predefined = [
(self, rng) => { (self, rng) => {
if (self.x === 0 && self.y === 0) { if (self.x === 0 && self.y === 0) {
self.internalGeneratePatch(rng, 2, ColorItem.ITEM_SINGLETONS[enumColors.red], 7, 7); self.internalGeneratePatch(rng, 2, ColorItem.ITEM_SINGLETONS[enumColors.red], 7, 7);
@ -402,7 +402,7 @@ export class MapChunk {
}, },
]; ];
static lowerLayers = [ MapChunk.lowerLayers = [
(self, rng, distanceToOriginInChunks) => { (self, rng, distanceToOriginInChunks) => {
// Determine how likely it is that there is a color patch // Determine how likely it is that there is a color patch
const colorPatchChance = 0.9 - clamp(distanceToOriginInChunks / 25, 0, 1) * 0.5; const colorPatchChance = 0.9 - clamp(distanceToOriginInChunks / 25, 0, 1) * 0.5;
@ -518,4 +518,3 @@ export class MapChunk {
} }
}, },
]; ];
}

View File

@ -568,17 +568,12 @@ export class ShapeDefinition extends BasicSerializableObject {
} }
return new ShapeDefinition({ layers: newLayers }); return new ShapeDefinition({ layers: newLayers });
} }
}
static renderQuad = { ShapeDefinition.renderQuad = {
[enumSubShape.rect]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => { [enumSubShape.rect]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => {
context.beginPath(); context.beginPath();
const dims = quadrantSize * layerScale; const dims = quadrantSize * layerScale;
context.rect( context.rect(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize - dims, dims, dims);
insetPadding + -quadrantHalfSize,
-insetPadding + quadrantHalfSize - dims,
dims,
dims
);
}, },
[enumSubShape.star]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => { [enumSubShape.star]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => {
context.beginPath(); context.beginPath();
@ -620,4 +615,3 @@ export class ShapeDefinition extends BasicSerializableObject {
context.closePath(); context.closePath();
}, },
}; };
}

View File

@ -70,10 +70,10 @@ export class DisplaySystem extends GameSystemWithFilter {
} }
} }
} }
}
static displaySprites = []; DisplaySystem.displaySprites = [];
DisplaySystem.displayItemType = {
static displayItemType = {
boolean: value => (isTrueItem(value) ? ColorItem.ITEM_SINGLETONS[enumColors.white] : null), boolean: value => (isTrueItem(value) ? ColorItem.ITEM_SINGLETONS[enumColors.white] : null),
color: value => color: value =>
@ -83,7 +83,7 @@ export class DisplaySystem extends GameSystemWithFilter {
shape: value => value, shape: value => value,
}; };
static displayItem = { DisplaySystem.displayItem = {
color: (parameters, value, origin, globalConfig) => color: (parameters, value, origin, globalConfig) =>
DisplaySystem.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered( DisplaySystem.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(
parameters, parameters,
@ -102,6 +102,5 @@ export class DisplaySystem extends GameSystemWithFilter {
), ),
}; };
static shapeRadius = () => 30; DisplaySystem.shapeRadius = () => 30;
static shapeBackground = () => true; DisplaySystem.shapeBackground = () => true;
}

View File

@ -365,8 +365,9 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
} }
} }
} }
}
static tryPassOverItemComponents = { ItemEjectorSystem.tryPassOverItemComponents = {
Belt: (comp, item, receiver, slotIndex, itemEjector) => { Belt: (comp, item, receiver, slotIndex, itemEjector) => {
const path = comp.assignedPath; const path = comp.assignedPath;
assert(path, "belt has no path"); assert(path, "belt has no path");
@ -379,9 +380,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
ItemProcessor: (comp, item, receiver, slotIndex, itemEjector) => { ItemProcessor: (comp, item, receiver, slotIndex, itemEjector) => {
// Check for potential filters // Check for potential filters
if ( if (!itemEjector.root.systemMgr.systems.itemProcessor.checkRequirements(receiver, item, slotIndex)) {
!itemEjector.root.systemMgr.systems.itemProcessor.checkRequirements(receiver, item, slotIndex)
) {
return false; return false;
} }
@ -422,4 +421,3 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
} }
}, },
}; };
}

View File

@ -497,15 +497,10 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
this.root.hubGoals.handleDefinitionDelivered(item.definition); this.root.hubGoals.handleDefinitionDelivered(item.definition);
} }
} }
}
static checkRequirements = { ItemProcessorSystem.checkRequirements = {
[enumItemProcessorRequirements.painterQuad]: ( [enumItemProcessorRequirements.painterQuad]: (entity, item, slotIndex, itemProcessorComp, pinsComp) => {
entity,
item,
slotIndex,
itemProcessorComp,
pinsComp
) => {
if (slotIndex === 0) { if (slotIndex === 0) {
// Always accept the shape // Always accept the shape
return true; return true;
@ -521,7 +516,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
}, },
}; };
static canProcess = { ItemProcessorSystem.canProcess = {
[enumItemProcessorRequirements.painterQuad]: (entity, processorComp) => { [enumItemProcessorRequirements.painterQuad]: (entity, processorComp) => {
const pinsComp = entity.components.WiredPins; const pinsComp = entity.components.WiredPins;
@ -576,4 +571,3 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
return true; return true;
}, },
}; };
}

View File

@ -144,10 +144,10 @@ export class ItemProcessorOverlaysSystem extends GameSystem {
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
} }
}
static processorOverlayStatic = { ItemProcessorOverlaysSystem.processorOverlayStatic = {
[enumItemProcessorRequirements.painterQuad]: function (parameters, chunk, entity, processorComp) { [enumItemProcessorRequirements.painterQuad]: function (parameters, chunk, entity, processorComp) {
this.drawConnectedSlotRequirement(parameters, entity, { drawIfFalse: true }); this.drawConnectedSlotRequirement(parameters, entity, { drawIfFalse: true });
}, },
}; };
}

View File

@ -763,6 +763,6 @@ export class WireSystem extends GameSystemWithFilter {
} }
} }
} }
static getForwardedTile = (tunnelComp, staticComp, offset) => staticComp.origin.add(offset);
} }
WireSystem.getForwardedTile = (tunnelComp, staticComp, offset) => staticComp.origin.add(offset);

View File

@ -80,77 +80,23 @@ window.onload = async () => {
logSection("Boot Process", "#f9a825"); logSection("Boot Process", "#f9a825");
// var modpack = {
// mods: [{
// url: "http://localhost:3006/mod",
// id: "a18121cf-fc7c-4f23-906d-b7ab0512bbc8",
// config: {},
// settings: {
// hasMakeModButton: {
// value: true,
// },
// // enum: {
// // value: "new test",
// // },
// // range: {
// // value: 10,
// // },
// },
// },
// // {
// // url: "http://localhost:3010/mod",
// // id: "cbae38a0-7ac5-4a0a-9985-da3110b1a6e8",
// // config: {},
// // settings: {
// // hasHubPlacement: { value: true },
// // },
// // },
// // {
// // url: "http://localhost:3011/mod",
// // id: "cba4229f-851b-4f01-807f-2a0c86c3aed7",
// // config: {},
// // settings: {},
// // },
// // {
// // url: "http://localhost:3012/mod",
// // id: "b6eaf06b-a0f7-48ac-b219-4e97fd275beb",
// // config: {},
// // settings: {},
// // },
// // {
// // url: "http://localhost:3013/mod",
// // id: "ca2fb74a-3827-4805-b5fe-8a23bf913c65",
// // config: {},
// // settings: {},
// // },
// // {
// // url: "http://localhost:3014/mod",
// // id: "3ae3751d-6dfb-4504-92dc-99a38a3d8c06",
// // config: {},
// // settings: {},
// // },
// ],
// };
let user = undefined; let user = undefined;
let instance = undefined; let instance = undefined;
let modFolderContents = []; let modFolderContents = [];
if (G_IS_STANDALONE) { if (G_IS_STANDALONE) {
const dirResult = await getIPCRenderer().invoke("fs-job", { modFolderContents = getIPCRenderer().sendSync("fs-sync-job", {
folder: "mods", folder: "mods",
type: "readDir", type: "readDir",
filename: "", filename: "",
}); }).data;
if (dirResult.success) modFolderContents = dirResult.data;
if (modFolderContents.includes("modpack.json")) { if (modFolderContents.includes("modpack.json")) {
const instanceResult = await getIPCRenderer().invoke("fs-job", { instance = getIPCRenderer().sendSync("fs-sync-job", {
folder: "mods", folder: "mods",
type: "read", type: "read",
filename: "modpack.json", filename: "modpack.json",
}); });
if (instanceResult.success) instance = JSON.parse(instanceResult.data);
} }
} else { } else if (!G_IS_DEV) {
user = JSON.parse(localStorage.getItem("user")); user = JSON.parse(localStorage.getItem("user"));
instance = JSON.parse(localStorage.getItem("instance")); instance = JSON.parse(localStorage.getItem("instance"));
// instance = { // instance = {
@ -175,7 +121,7 @@ window.onload = async () => {
if (mod.split(".").pop() !== "js") continue; if (mod.split(".").pop() !== "js") continue;
modMgr.addMod(mod, true); modMgr.addMod(mod, true);
} }
} else await modMgr.addModPackMods(); } else if (modMgr.modPack) await modMgr.addModPackMods();
modMgr.loadMods(); modMgr.loadMods();
initDrawUtils(); initDrawUtils();