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

Fixed some static declarations

This commit is contained in:
DJ1TJOO 2021-03-02 13:50:09 +01:00
parent ca5218561f
commit dd23eb741d
9 changed files with 499 additions and 487 deletions

View File

@ -49,6 +49,19 @@ 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());
@ -396,18 +409,3 @@ export class Application {
this.checkResize(true);
}
}
Application.trackClicks = undefined;
Application.getMainContentHTML = undefined;
Application.states = {
PreloadState,
MobileWarningState,
MainMenuState,
InGameState,
SettingsState,
KeybindingsState,
AboutState,
ChangelogState,
};

View File

@ -503,8 +503,8 @@ export class HubGoals extends BasicSerializableObject {
return 1 / globalConfig.beltSpeedItemsPerSecond;
}
}
HubGoals.getProcessorBaseSpeed = {
static getProcessorBaseSpeed = {
trash: processorType => 1e30,
hub: processorType => 1e30,
balancer: function (processorType) {
@ -624,4 +624,5 @@ HubGoals.getProcessorBaseSpeed = {
globalConfig.buildingSpeeds[processorType]
);
},
};
};
}

View File

@ -359,9 +359,8 @@ export class MapChunk {
}
}
}
}
MapChunk.predefined = [
static predefined = [
(self, rng) => {
if (self.x === 0 && self.y === 0) {
self.internalGeneratePatch(rng, 2, ColorItem.ITEM_SINGLETONS[enumColors.red], 7, 7);
@ -401,9 +400,9 @@ MapChunk.predefined = [
return true;
}
},
];
];
MapChunk.lowerLayers = [
static 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;
@ -518,4 +517,5 @@ MapChunk.lowerLayers = [
internalGenerateShapePatch(rng, shapePatchSize, distanceToOriginInChunks);
}
},
];
];
}

View File

@ -568,13 +568,17 @@ export class ShapeDefinition extends BasicSerializableObject {
}
return new ShapeDefinition({ layers: newLayers });
}
}
ShapeDefinition.renderQuad = {
static 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();
@ -615,4 +619,5 @@ ShapeDefinition.renderQuad = {
);
context.closePath();
},
};
};
}

View File

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

View File

@ -364,9 +364,8 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
}
}
}
}
ItemEjectorSystem.tryPassOverItemComponents = {
static tryPassOverItemComponents = {
Belt: (comp, item, receiver, slotIndex, itemEjector) => {
const path = comp.assignedPath;
assert(path, "belt has no path");
@ -379,7 +378,9 @@ ItemEjectorSystem.tryPassOverItemComponents = {
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;
}
@ -419,4 +420,5 @@ ItemEjectorSystem.tryPassOverItemComponents = {
return true;
}
},
};
};
}

View File

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

View File

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

View File

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