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:
parent
2f872af3e4
commit
07dff668d3
@ -51,19 +51,6 @@ if (typeof document.hidden !== "undefined") {
|
||||
}
|
||||
|
||||
export class Application {
|
||||
static trackClicks = undefined;
|
||||
static getMainContentHTML = undefined;
|
||||
static states = {
|
||||
PreloadState,
|
||||
MobileWarningState,
|
||||
MainMenuState,
|
||||
InGameState,
|
||||
SettingsState,
|
||||
KeybindingsState,
|
||||
AboutState,
|
||||
ChangelogState,
|
||||
};
|
||||
|
||||
constructor() {
|
||||
assert(!GLOBAL_APP, "Tried to construct application twice");
|
||||
logger.log("Creating application, platform =", getPlatformName());
|
||||
@ -415,3 +402,16 @@ export class Application {
|
||||
this.checkResize(true);
|
||||
}
|
||||
}
|
||||
|
||||
Application.trackClicks = undefined;
|
||||
Application.getMainContentHTML = undefined;
|
||||
Application.states = {
|
||||
PreloadState,
|
||||
MobileWarningState,
|
||||
MainMenuState,
|
||||
InGameState,
|
||||
SettingsState,
|
||||
KeybindingsState,
|
||||
AboutState,
|
||||
ChangelogState,
|
||||
};
|
||||
|
@ -318,7 +318,7 @@ export class ReadWriteProxy {
|
||||
if (!data) {
|
||||
return ExplainedResult.bad("Data is empty");
|
||||
}
|
||||
if (!savegameInterfaces[data.version]) {
|
||||
if (!savegameInterfaces[data.version] && data.version !== this.getCurrentVersion()) {
|
||||
return ExplainedResult.bad(
|
||||
`Data has invalid version: ${data.version} (expected ${this.getCurrentVersion()})`
|
||||
);
|
||||
|
@ -503,8 +503,9 @@ export class HubGoals extends BasicSerializableObject {
|
||||
|
||||
return 1 / globalConfig.beltSpeedItemsPerSecond;
|
||||
}
|
||||
}
|
||||
|
||||
static getProcessorBaseSpeed = {
|
||||
HubGoals.getProcessorBaseSpeed = {
|
||||
trash: processorType => 1e30,
|
||||
hub: processorType => 1e30,
|
||||
balancer: function (processorType) {
|
||||
@ -624,5 +625,4 @@ export class HubGoals extends BasicSerializableObject {
|
||||
globalConfig.buildingSpeeds[processorType]
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -359,8 +359,8 @@ export class MapChunk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static predefined = [
|
||||
}
|
||||
MapChunk.predefined = [
|
||||
(self, rng) => {
|
||||
if (self.x === 0 && self.y === 0) {
|
||||
self.internalGeneratePatch(rng, 2, ColorItem.ITEM_SINGLETONS[enumColors.red], 7, 7);
|
||||
@ -400,9 +400,9 @@ export class MapChunk {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
];
|
||||
];
|
||||
|
||||
static lowerLayers = [
|
||||
MapChunk.lowerLayers = [
|
||||
(self, rng, distanceToOriginInChunks) => {
|
||||
// Determine how likely it is that there is a color patch
|
||||
const colorPatchChance = 0.9 - clamp(distanceToOriginInChunks / 25, 0, 1) * 0.5;
|
||||
@ -517,5 +517,4 @@ export class MapChunk {
|
||||
internalGenerateShapePatch(rng, shapePatchSize, distanceToOriginInChunks);
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
];
|
||||
|
@ -568,17 +568,12 @@ export class ShapeDefinition extends BasicSerializableObject {
|
||||
}
|
||||
return new ShapeDefinition({ layers: newLayers });
|
||||
}
|
||||
|
||||
static renderQuad = {
|
||||
}
|
||||
ShapeDefinition.renderQuad = {
|
||||
[enumSubShape.rect]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => {
|
||||
context.beginPath();
|
||||
const dims = quadrantSize * layerScale;
|
||||
context.rect(
|
||||
insetPadding + -quadrantHalfSize,
|
||||
-insetPadding + quadrantHalfSize - dims,
|
||||
dims,
|
||||
dims
|
||||
);
|
||||
context.rect(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize - dims, dims, dims);
|
||||
},
|
||||
[enumSubShape.star]: (context, quadrantSize, quadrantHalfSize, layerScale, insetPadding) => {
|
||||
context.beginPath();
|
||||
@ -619,5 +614,4 @@ export class ShapeDefinition extends BasicSerializableObject {
|
||||
);
|
||||
context.closePath();
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -70,10 +70,10 @@ export class DisplaySystem extends GameSystemWithFilter {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static displaySprites = [];
|
||||
|
||||
static displayItemType = {
|
||||
DisplaySystem.displaySprites = [];
|
||||
DisplaySystem.displayItemType = {
|
||||
boolean: value => (isTrueItem(value) ? ColorItem.ITEM_SINGLETONS[enumColors.white] : null),
|
||||
|
||||
color: value =>
|
||||
@ -81,9 +81,9 @@ export class DisplaySystem extends GameSystemWithFilter {
|
||||
(value).color === enumColors.uncolored ? null : /**@type {ColorItem} */ (value),
|
||||
|
||||
shape: value => value,
|
||||
};
|
||||
};
|
||||
|
||||
static displayItem = {
|
||||
DisplaySystem.displayItem = {
|
||||
color: (parameters, value, origin, globalConfig) =>
|
||||
DisplaySystem.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(
|
||||
parameters,
|
||||
@ -100,8 +100,7 @@ export class DisplaySystem extends GameSystemWithFilter {
|
||||
DisplaySystem.shapeRadius(),
|
||||
DisplaySystem.shapeBackground()
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
static shapeRadius = () => 30;
|
||||
static shapeBackground = () => true;
|
||||
}
|
||||
DisplaySystem.shapeRadius = () => 30;
|
||||
DisplaySystem.shapeBackground = () => true;
|
||||
|
@ -365,8 +365,9 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static tryPassOverItemComponents = {
|
||||
ItemEjectorSystem.tryPassOverItemComponents = {
|
||||
Belt: (comp, item, receiver, slotIndex, itemEjector) => {
|
||||
const path = comp.assignedPath;
|
||||
assert(path, "belt has no path");
|
||||
@ -379,9 +380,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
||||
|
||||
ItemProcessor: (comp, item, receiver, slotIndex, itemEjector) => {
|
||||
// Check for potential filters
|
||||
if (
|
||||
!itemEjector.root.systemMgr.systems.itemProcessor.checkRequirements(receiver, item, slotIndex)
|
||||
) {
|
||||
if (!itemEjector.root.systemMgr.systems.itemProcessor.checkRequirements(receiver, item, slotIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -421,5 +420,4 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -497,15 +497,10 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
this.root.hubGoals.handleDefinitionDelivered(item.definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static checkRequirements = {
|
||||
[enumItemProcessorRequirements.painterQuad]: (
|
||||
entity,
|
||||
item,
|
||||
slotIndex,
|
||||
itemProcessorComp,
|
||||
pinsComp
|
||||
) => {
|
||||
ItemProcessorSystem.checkRequirements = {
|
||||
[enumItemProcessorRequirements.painterQuad]: (entity, item, slotIndex, itemProcessorComp, pinsComp) => {
|
||||
if (slotIndex === 0) {
|
||||
// Always accept the shape
|
||||
return true;
|
||||
@ -519,9 +514,9 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
static canProcess = {
|
||||
ItemProcessorSystem.canProcess = {
|
||||
[enumItemProcessorRequirements.painterQuad]: (entity, processorComp) => {
|
||||
const pinsComp = entity.components.WiredPins;
|
||||
|
||||
@ -575,5 +570,4 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -144,10 +144,10 @@ export class ItemProcessorOverlaysSystem extends GameSystem {
|
||||
|
||||
parameters.context.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static processorOverlayStatic = {
|
||||
ItemProcessorOverlaysSystem.processorOverlayStatic = {
|
||||
[enumItemProcessorRequirements.painterQuad]: function (parameters, chunk, entity, processorComp) {
|
||||
this.drawConnectedSlotRequirement(parameters, entity, { drawIfFalse: true });
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -80,77 +80,23 @@ window.onload = async () => {
|
||||
|
||||
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 instance = undefined;
|
||||
let modFolderContents = [];
|
||||
if (G_IS_STANDALONE) {
|
||||
const dirResult = await getIPCRenderer().invoke("fs-job", {
|
||||
modFolderContents = getIPCRenderer().sendSync("fs-sync-job", {
|
||||
folder: "mods",
|
||||
type: "readDir",
|
||||
filename: "",
|
||||
});
|
||||
if (dirResult.success) modFolderContents = dirResult.data;
|
||||
|
||||
}).data;
|
||||
if (modFolderContents.includes("modpack.json")) {
|
||||
const instanceResult = await getIPCRenderer().invoke("fs-job", {
|
||||
instance = getIPCRenderer().sendSync("fs-sync-job", {
|
||||
folder: "mods",
|
||||
type: "read",
|
||||
filename: "modpack.json",
|
||||
});
|
||||
if (instanceResult.success) instance = JSON.parse(instanceResult.data);
|
||||
}
|
||||
} else {
|
||||
} else if (!G_IS_DEV) {
|
||||
user = JSON.parse(localStorage.getItem("user"));
|
||||
instance = JSON.parse(localStorage.getItem("instance"));
|
||||
// instance = {
|
||||
@ -175,7 +121,7 @@ window.onload = async () => {
|
||||
if (mod.split(".").pop() !== "js") continue;
|
||||
modMgr.addMod(mod, true);
|
||||
}
|
||||
} else await modMgr.addModPackMods();
|
||||
} else if (modMgr.modPack) await modMgr.addModPackMods();
|
||||
modMgr.loadMods();
|
||||
|
||||
initDrawUtils();
|
||||
|
Loading…
Reference in New Issue
Block a user