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:
parent
ca5218561f
commit
dd23eb741d
@ -49,6 +49,19 @@ 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());
|
||||||
@ -396,18 +409,3 @@ 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,
|
|
||||||
};
|
|
||||||
|
|||||||
@ -503,8 +503,8 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
|
|
||||||
return 1 / globalConfig.beltSpeedItemsPerSecond;
|
return 1 / globalConfig.beltSpeedItemsPerSecond;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
HubGoals.getProcessorBaseSpeed = {
|
static getProcessorBaseSpeed = {
|
||||||
trash: processorType => 1e30,
|
trash: processorType => 1e30,
|
||||||
hub: processorType => 1e30,
|
hub: processorType => 1e30,
|
||||||
balancer: function (processorType) {
|
balancer: function (processorType) {
|
||||||
@ -625,3 +625,4 @@ HubGoals.getProcessorBaseSpeed = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -359,9 +359,8 @@ export class MapChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MapChunk.predefined = [
|
static 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);
|
||||||
@ -403,7 +402,7 @@ MapChunk.predefined = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
MapChunk.lowerLayers = [
|
static 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;
|
||||||
@ -519,3 +518,4 @@ MapChunk.lowerLayers = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|||||||
@ -568,13 +568,17 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
}
|
}
|
||||||
return new ShapeDefinition({ layers: newLayers });
|
return new ShapeDefinition({ layers: newLayers });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ShapeDefinition.renderQuad = {
|
static 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(insetPadding + -quadrantHalfSize, -insetPadding + quadrantHalfSize - dims, dims, dims);
|
context.rect(
|
||||||
|
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();
|
||||||
@ -616,3 +620,4 @@ ShapeDefinition.renderQuad = {
|
|||||||
context.closePath();
|
context.closePath();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -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),
|
boolean: value => (isTrueItem(value) ? ColorItem.ITEM_SINGLETONS[enumColors.white] : null),
|
||||||
|
|
||||||
color: value =>
|
color: value =>
|
||||||
@ -84,7 +83,7 @@ DisplaySystem.displayItemType = {
|
|||||||
shape: value => value,
|
shape: value => value,
|
||||||
};
|
};
|
||||||
|
|
||||||
DisplaySystem.displayItem = {
|
static 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,
|
||||||
@ -103,5 +102,6 @@ DisplaySystem.displayItem = {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
DisplaySystem.shapeRadius = () => 30;
|
static shapeRadius = () => 30;
|
||||||
DisplaySystem.shapeBackground = () => true;
|
static shapeBackground = () => true;
|
||||||
|
}
|
||||||
|
|||||||
@ -364,9 +364,8 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ItemEjectorSystem.tryPassOverItemComponents = {
|
static 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,7 +378,9 @@ ItemEjectorSystem.tryPassOverItemComponents = {
|
|||||||
|
|
||||||
ItemProcessor: (comp, item, receiver, slotIndex, itemEjector) => {
|
ItemProcessor: (comp, item, receiver, slotIndex, itemEjector) => {
|
||||||
// Check for potential filters
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,3 +421,4 @@ ItemEjectorSystem.tryPassOverItemComponents = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -497,10 +497,15 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
this.root.hubGoals.handleDefinitionDelivered(item.definition);
|
this.root.hubGoals.handleDefinitionDelivered(item.definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ItemProcessorSystem.checkRequirements = {
|
static checkRequirements = {
|
||||||
[enumItemProcessorRequirements.painterQuad]: (entity, item, slotIndex, itemProcessorComp, pinsComp) => {
|
[enumItemProcessorRequirements.painterQuad]: (
|
||||||
|
entity,
|
||||||
|
item,
|
||||||
|
slotIndex,
|
||||||
|
itemProcessorComp,
|
||||||
|
pinsComp
|
||||||
|
) => {
|
||||||
if (slotIndex === 0) {
|
if (slotIndex === 0) {
|
||||||
// Always accept the shape
|
// Always accept the shape
|
||||||
return true;
|
return true;
|
||||||
@ -516,7 +521,7 @@ ItemProcessorSystem.checkRequirements = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ItemProcessorSystem.canProcess = {
|
static canProcess = {
|
||||||
[enumItemProcessorRequirements.painterQuad]: (entity, processorComp) => {
|
[enumItemProcessorRequirements.painterQuad]: (entity, processorComp) => {
|
||||||
const pinsComp = entity.components.WiredPins;
|
const pinsComp = entity.components.WiredPins;
|
||||||
|
|
||||||
@ -571,3 +576,4 @@ ItemProcessorSystem.canProcess = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -144,10 +144,10 @@ export class ItemProcessorOverlaysSystem extends GameSystem {
|
|||||||
|
|
||||||
parameters.context.globalAlpha = 1;
|
parameters.context.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ItemProcessorOverlaysSystem.processorOverlayStatic = {
|
static 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 });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user