mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Remove enumLayer and enumItemType
This commit is contained in:
@@ -11,7 +11,6 @@ import { BaseHUDPart } from "../base_hud_part";
|
||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||
import { Blueprint } from "../../blueprint";
|
||||
import { SOUNDS } from "../../../platform/sound";
|
||||
import { enumLayer } from "../../root";
|
||||
|
||||
export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
@@ -60,7 +59,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
|
||||
/**
|
||||
* Called when the layer was changed
|
||||
* @param {enumLayer} layer
|
||||
* @param {Layer} layer
|
||||
*/
|
||||
onEditModeChanged(layer) {
|
||||
// Check if the layer of the blueprint differs and thus we have to deselect it
|
||||
|
||||
@@ -18,7 +18,7 @@ import { THEME } from "../../theme";
|
||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||
import { HUDBuildingPlacerLogic } from "./building_placer_logic";
|
||||
import { makeOffscreenBuffer } from "../../../core/buffer_utils";
|
||||
import { enumLayer } from "../../root";
|
||||
import { layers } from "../../root";
|
||||
import { getCodeFromBuildingData } from "../../building_codes";
|
||||
|
||||
export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
||||
@@ -61,9 +61,9 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
||||
this.currentInterpolatedCornerTile = new Vector();
|
||||
|
||||
this.lockIndicatorSprites = {};
|
||||
for (const layerId in enumLayer) {
|
||||
this.lockIndicatorSprites[layerId] = this.makeLockIndicatorSprite(layerId);
|
||||
}
|
||||
layers.forEach(layer => {
|
||||
this.lockIndicatorSprites[layer] = this.makeLockIndicatorSprite(layer);
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
@@ -76,7 +76,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
||||
|
||||
/**
|
||||
* Makes the lock indicator sprite for the given layer
|
||||
* @param {enumLayer} layer
|
||||
* @param {Layer} layer
|
||||
*/
|
||||
makeLockIndicatorSprite(layer) {
|
||||
const dims = 48;
|
||||
|
||||
@@ -12,7 +12,6 @@ import { BaseHUDPart } from "../base_hud_part";
|
||||
import { SOUNDS } from "../../../platform/sound";
|
||||
import { MetaMinerBuilding, enumMinerVariants } from "../../buildings/miner";
|
||||
import { enumHubGoalRewards } from "../../tutorial_goals";
|
||||
import { enumLayer } from "../../root";
|
||||
import { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes";
|
||||
import { MetaHubBuilding } from "../../buildings/hub";
|
||||
|
||||
@@ -133,12 +132,12 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
|
||||
/**
|
||||
* Called when the edit mode got changed
|
||||
* @param {enumLayer} editMode
|
||||
* @param {Layer} layer
|
||||
*/
|
||||
onEditModeChanged(editMode) {
|
||||
onEditModeChanged(layer) {
|
||||
const metaBuilding = this.currentMetaBuilding.get();
|
||||
if (metaBuilding) {
|
||||
if (metaBuilding.getLayer() !== editMode) {
|
||||
if (metaBuilding.getLayer() !== layer) {
|
||||
// This layer doesn't fit the edit mode anymore
|
||||
this.currentMetaBuilding.set(null);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { MetaSplitterBuilding } from "../../buildings/splitter";
|
||||
import { MetaStackerBuilding } from "../../buildings/stacker";
|
||||
import { MetaTrashBuilding } from "../../buildings/trash";
|
||||
import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
|
||||
import { enumLayer } from "../../root";
|
||||
import { HUDBaseToolbar } from "./base_toolbar";
|
||||
import { MetaLeverBuilding } from "../../buildings/lever";
|
||||
import { MetaFilterBuilding } from "../../buildings/filter";
|
||||
@@ -35,7 +34,7 @@ export class HUDBuildingsToolbar extends HUDBaseToolbar {
|
||||
super(root, {
|
||||
supportedBuildings,
|
||||
visibilityCondition: () =>
|
||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === enumLayer.regular,
|
||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === "regular",
|
||||
htmlElementId: "ingame_HUD_buildings_toolbar",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import { DrawParameters } from "../../../core/draw_parameters";
|
||||
import { THEME } from "../../theme";
|
||||
import { globalConfig } from "../../../core/config";
|
||||
import { T } from "../../../translations";
|
||||
import { enumItemType } from "../../base_item";
|
||||
import { enumLayer } from "../../root";
|
||||
|
||||
export class HUDColorBlindHelper extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
@@ -41,7 +39,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.root.currentLayer !== enumLayer.regular) {
|
||||
if (this.root.currentLayer !== "regular") {
|
||||
// Not in regular mode
|
||||
return null;
|
||||
}
|
||||
@@ -56,7 +54,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
||||
// Check if the belt has a color item
|
||||
if (beltComp) {
|
||||
const item = beltComp.assignedPath.findItemAtTile(tile);
|
||||
if (item && item.getItemType() === enumItemType.color) {
|
||||
if (item && item.getItemType() === "color") {
|
||||
return /** @type {ColorItem} */ (item).color;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +64,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
||||
if (ejectorComp) {
|
||||
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
||||
const slot = ejectorComp.slots[i];
|
||||
if (slot.item && slot.item.getItemType() === enumItemType.color) {
|
||||
if (slot.item && slot.item.getItemType() === "color") {
|
||||
return /** @type {ColorItem} */ (slot.item).color;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +72,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
||||
} else {
|
||||
// We hovered a lower layer, show the color there
|
||||
const lowerLayer = this.root.map.getLowerLayerContentXY(tile.x, tile.y);
|
||||
if (lowerLayer && lowerLayer.getItemType() === enumItemType.color) {
|
||||
if (lowerLayer && lowerLayer.getItemType() === "color") {
|
||||
return /** @type {ColorItem} */ (lowerLayer).color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { globalConfig } from "../../../core/config";
|
||||
import { Loader } from "../../../core/loader";
|
||||
import { Vector } from "../../../core/vector";
|
||||
import { MapChunkView } from "../../map_chunk_view";
|
||||
import { enumLayer } from "../../root";
|
||||
import { THEME } from "../../theme";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
@@ -76,7 +75,7 @@ export class HUDLayerPreview extends BaseHUDPart {
|
||||
const tileX = dx + startTileX;
|
||||
const tileY = dy + startTileY;
|
||||
|
||||
const content = this.root.map.getLayerContentXY(tileX, tileY, enumLayer.wires);
|
||||
const content = this.root.map.getLayerContentXY(tileX, tileY, "wires");
|
||||
if (content) {
|
||||
MapChunkView.drawSingleWiresOverviewTile({
|
||||
context: this.context,
|
||||
@@ -104,7 +103,7 @@ export class HUDLayerPreview extends BaseHUDPart {
|
||||
* @param {number} scale 1 / zoomLevel
|
||||
*/
|
||||
renderPreview(parameters, worldPos, scale) {
|
||||
if (this.root.currentLayer !== enumLayer.regular) {
|
||||
if (this.root.currentLayer !== "regular") {
|
||||
// Only supporting wires right now
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||
import { Vector } from "../../../core/vector";
|
||||
import { enumMouseButton } from "../../camera";
|
||||
import { enumLayer } from "../../root";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
export class HUDLeverToggle extends BaseHUDPart {
|
||||
@@ -15,7 +14,7 @@ export class HUDLeverToggle extends BaseHUDPart {
|
||||
*/
|
||||
downPreHandler(pos, button) {
|
||||
const tile = this.root.camera.screenToWorld(pos).toTileSpace();
|
||||
const contents = this.root.map.getLayerContentXY(tile.x, tile.y, enumLayer.regular);
|
||||
const contents = this.root.map.getLayerContentXY(tile.x, tile.y, "regular");
|
||||
if (contents) {
|
||||
const leverComp = contents.components.Lever;
|
||||
if (leverComp) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { globalConfig } from "../../../core/config";
|
||||
import { MapChunkView } from "../../map_chunk_view";
|
||||
import { enumLayer } from "../../root";
|
||||
import { WireNetwork } from "../../systems/wire";
|
||||
import { THEME } from "../../theme";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
@@ -17,7 +16,7 @@ export class HUDWireInfo extends BaseHUDPart {
|
||||
* @param {import("../../../core/draw_utils").DrawParameters} parameters
|
||||
*/
|
||||
drawOverlays(parameters) {
|
||||
if (this.root.currentLayer !== enumLayer.wires) {
|
||||
if (this.root.currentLayer !== "wires") {
|
||||
// Not in the wires layer
|
||||
return;
|
||||
}
|
||||
@@ -30,7 +29,7 @@ export class HUDWireInfo extends BaseHUDPart {
|
||||
|
||||
const worldPos = this.root.camera.screenToWorld(mousePos);
|
||||
const tile = worldPos.toTileSpace();
|
||||
const entity = this.root.map.getLayerContentXY(tile.x, tile.y, enumLayer.wires);
|
||||
const entity = this.root.map.getLayerContentXY(tile.x, tile.y, "wires");
|
||||
|
||||
if (!entity) {
|
||||
// No entity
|
||||
|
||||
@@ -2,7 +2,6 @@ import { makeOffscreenBuffer } from "../../../core/buffer_utils";
|
||||
import { globalConfig } from "../../../core/config";
|
||||
import { DrawParameters } from "../../../core/draw_parameters";
|
||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||
import { enumLayer } from "../../root";
|
||||
import { THEME } from "../../theme";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { Loader } from "../../../core/loader";
|
||||
@@ -26,10 +25,10 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
||||
* Switches between layers
|
||||
*/
|
||||
switchLayers() {
|
||||
if (this.root.currentLayer === enumLayer.regular) {
|
||||
this.root.currentLayer = enumLayer.wires;
|
||||
if (this.root.currentLayer === "regular") {
|
||||
this.root.currentLayer = "wires";
|
||||
} else {
|
||||
this.root.currentLayer = enumLayer.regular;
|
||||
this.root.currentLayer = "regular";
|
||||
}
|
||||
this.root.signals.editModeChanged.dispatch(this.root.currentLayer);
|
||||
}
|
||||
@@ -51,7 +50,7 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
||||
}
|
||||
|
||||
update() {
|
||||
const desiredAlpha = this.root.currentLayer === enumLayer.wires ? 1.0 : 0.0;
|
||||
const desiredAlpha = this.root.currentLayer === "wires" ? 1.0 : 0.0;
|
||||
this.currentAlpha = lerp(this.currentAlpha, desiredAlpha, 0.12);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { enumLayer } from "../../root";
|
||||
import { HUDBaseToolbar } from "./base_toolbar";
|
||||
import { MetaWireBuilding } from "../../buildings/wire";
|
||||
import { MetaConstantSignalBuilding } from "../../buildings/constant_signal";
|
||||
@@ -19,7 +18,7 @@ export class HUDWiresToolbar extends HUDBaseToolbar {
|
||||
super(root, {
|
||||
supportedBuildings,
|
||||
visibilityCondition: () =>
|
||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === enumLayer.wires,
|
||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === "wires",
|
||||
htmlElementId: "ingame_HUD_wires_toolbar",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GameRoot, enumLayer } from "../root";
|
||||
import { GameRoot } from "../root";
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { Vector, mixVector } from "../../core/vector";
|
||||
import { lerp } from "../../core/utils";
|
||||
|
||||
Reference in New Issue
Block a user