mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Remove enumLayer and enumItemType
This commit is contained in:
parent
75e729dac2
commit
6a447e3583
@ -1,12 +1,8 @@
|
|||||||
import { DrawParameters } from "../core/draw_parameters";
|
import { DrawParameters } from "../core/draw_parameters";
|
||||||
import { BasicSerializableObject } from "../savegame/serialization";
|
import { BasicSerializableObject } from "../savegame/serialization";
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @type {ItemType[]} **/
|
||||||
export const enumItemType = {
|
export const itemTypes = ["shape", "color", "boolean"];
|
||||||
shape: "shape",
|
|
||||||
color: "color",
|
|
||||||
boolean: "boolean",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for items on belts etc. Not an entity for performance reasons
|
* Class for items on belts etc. Not an entity for performance reasons
|
||||||
@ -25,10 +21,10 @@ export class BaseItem extends BasicSerializableObject {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {enumItemType} */
|
/** @returns {ItemType} **/
|
||||||
getItemType() {
|
getItemType() {
|
||||||
abstract;
|
abstract;
|
||||||
return "";
|
return "shape";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +8,7 @@ import { BasicSerializableObject, types } from "../savegame/serialization";
|
|||||||
import { BaseItem } from "./base_item";
|
import { BaseItem } from "./base_item";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { typeItemSingleton } from "./item_resolver";
|
import { typeItemSingleton } from "./item_resolver";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
|
|
||||||
const logger = createLogger("belt_path");
|
const logger = createLogger("belt_path");
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ export class BeltPath extends BasicSerializableObject {
|
|||||||
const targetEntity = this.root.map.getLayerContentXY(
|
const targetEntity = this.root.map.getLayerContentXY(
|
||||||
ejectSlotTargetWsTile.x,
|
ejectSlotTargetWsTile.x,
|
||||||
ejectSlotTargetWsTile.y,
|
ejectSlotTargetWsTile.y,
|
||||||
enumLayer.regular
|
"regular"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetEntity) {
|
if (targetEntity) {
|
||||||
|
@ -3,7 +3,7 @@ import { Loader } from "../core/loader";
|
|||||||
import { createLogger } from "../core/logging";
|
import { createLogger } from "../core/logging";
|
||||||
import { Vector } from "../core/vector";
|
import { Vector } from "../core/vector";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { GameRoot, enumLayer } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { findNiceIntegerValue } from "../core/utils";
|
import { findNiceIntegerValue } from "../core/utils";
|
||||||
import { blueprintShape } from "./upgrades";
|
import { blueprintShape } from "./upgrades";
|
||||||
import { globalConfig } from "../core/config";
|
import { globalConfig } from "../core/config";
|
||||||
@ -20,11 +20,11 @@ export class Blueprint {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the layer of this blueprint
|
* Returns the layer of this blueprint
|
||||||
* @returns {enumLayer}
|
* @returns {Layer}
|
||||||
*/
|
*/
|
||||||
get layer() {
|
get layer() {
|
||||||
if (this.entities.length === 0) {
|
if (this.entities.length === 0) {
|
||||||
return enumLayer.regular;
|
return "regular";
|
||||||
}
|
}
|
||||||
return this.entities[0].layer;
|
return this.entities[0].layer;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
|||||||
* @param {Vector} param0.tile
|
* @param {Vector} param0.tile
|
||||||
* @param {number} param0.rotation
|
* @param {number} param0.rotation
|
||||||
* @param {string} param0.variant
|
* @param {string} param0.variant
|
||||||
* @param {string} param0.layer
|
* @param {Layer} param0.layer
|
||||||
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
||||||
*/
|
*/
|
||||||
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
||||||
|
@ -2,7 +2,7 @@ import { enumDirection, Vector } from "../../core/vector";
|
|||||||
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding } from "../meta_building";
|
import { MetaBuilding } from "../meta_building";
|
||||||
import { enumLayer, GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { ConstantSignalComponent } from "../components/constant_signal";
|
import { ConstantSignalComponent } from "../components/constant_signal";
|
||||||
|
|
||||||
export class MetaConstantSignalBuilding extends MetaBuilding {
|
export class MetaConstantSignalBuilding extends MetaBuilding {
|
||||||
@ -22,8 +22,9 @@ export class MetaConstantSignalBuilding extends MetaBuilding {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"wires"} **/
|
||||||
getLayer() {
|
getLayer() {
|
||||||
return enumLayer.wires;
|
return "wires";
|
||||||
}
|
}
|
||||||
|
|
||||||
getDimensions() {
|
getDimensions() {
|
||||||
|
@ -8,7 +8,6 @@ import { Entity } from "../entity";
|
|||||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||||
import { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumCutterVariants = { quad: "quad" };
|
export const enumCutterVariants = { quad: "quad" };
|
||||||
@ -82,7 +81,7 @@ export class MetaCutterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { enumDirection, Vector } from "../../core/vector";
|
import { enumDirection, Vector } from "../../core/vector";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
import { HubComponent } from "../components/hub";
|
import { HubComponent } from "../components/hub";
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
@ -68,72 +67,72 @@ export class MetaHubBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.top, enumDirection.left],
|
directions: [enumDirection.top, enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.top],
|
directions: [enumDirection.top],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(2, 0),
|
pos: new Vector(2, 0),
|
||||||
directions: [enumDirection.top],
|
directions: [enumDirection.top],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 0),
|
pos: new Vector(3, 0),
|
||||||
directions: [enumDirection.top, enumDirection.right],
|
directions: [enumDirection.top, enumDirection.right],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 3),
|
pos: new Vector(0, 3),
|
||||||
directions: [enumDirection.bottom, enumDirection.left],
|
directions: [enumDirection.bottom, enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 3),
|
pos: new Vector(1, 3),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(2, 3),
|
pos: new Vector(2, 3),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 3),
|
pos: new Vector(3, 3),
|
||||||
directions: [enumDirection.bottom, enumDirection.right],
|
directions: [enumDirection.bottom, enumDirection.right],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 1),
|
pos: new Vector(0, 1),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 2),
|
pos: new Vector(0, 2),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 3),
|
pos: new Vector(0, 3),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 1),
|
pos: new Vector(3, 1),
|
||||||
directions: [enumDirection.right],
|
directions: [enumDirection.right],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 2),
|
pos: new Vector(3, 2),
|
||||||
directions: [enumDirection.right],
|
directions: [enumDirection.right],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 3),
|
pos: new Vector(3, 3),
|
||||||
directions: [enumDirection.right],
|
directions: [enumDirection.right],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,7 @@ import { enumDirection, Vector } from "../../core/vector";
|
|||||||
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
||||||
import { enumLayer, GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { enumLogicGateType, LogicGateComponent } from "../components/logic_gate";
|
import { enumLogicGateType, LogicGateComponent } from "../components/logic_gate";
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
@ -39,8 +39,9 @@ export class MetaLogicGateBuilding extends MetaBuilding {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"wires"} **/
|
||||||
getLayer() {
|
getLayer() {
|
||||||
return enumLayer.wires;
|
return "wires";
|
||||||
}
|
}
|
||||||
|
|
||||||
getDimensions() {
|
getDimensions() {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { formatItemsPerSecond } from "../../core/utils";
|
import { formatItemsPerSecond } from "../../core/utils";
|
||||||
import { enumDirection, Vector } from "../../core/vector";
|
import { enumDirection, Vector } from "../../core/vector";
|
||||||
import { T } from "../../translations";
|
import { T } from "../../translations";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
@ -63,12 +62,12 @@ export class MetaMixerBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,6 @@ import { Entity } from "../entity";
|
|||||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||||
import { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumPainterVariants = { mirrored: "mirrored", double: "double", quad: "quad" };
|
export const enumPainterVariants = { mirrored: "mirrored", double: "double", quad: "quad" };
|
||||||
@ -98,12 +97,12 @@ export class MetaPainterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.top],
|
directions: [enumDirection.top],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -124,14 +123,14 @@ export class MetaPainterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [
|
directions: [
|
||||||
variant === defaultBuildingVariant ? enumDirection.top : enumDirection.bottom,
|
variant === defaultBuildingVariant ? enumDirection.top : enumDirection.bottom,
|
||||||
],
|
],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -147,17 +146,17 @@ export class MetaPainterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 1),
|
pos: new Vector(0, 1),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.top],
|
directions: [enumDirection.top],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -174,27 +173,27 @@ export class MetaPainterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.left],
|
directions: [enumDirection.left],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(2, 0),
|
pos: new Vector(2, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(3, 0),
|
pos: new Vector(3, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.color,
|
filter: "color",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import { Entity } from "../entity";
|
|||||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||||
import { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumRotaterVariants = { ccw: "ccw", fl: "fl" };
|
export const enumRotaterVariants = { ccw: "ccw", fl: "fl" };
|
||||||
@ -89,7 +88,7 @@ export class MetaRotaterBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,6 @@ import { Entity } from "../entity";
|
|||||||
import { MetaBuilding } from "../meta_building";
|
import { MetaBuilding } from "../meta_building";
|
||||||
import { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { enumItemType } from "../base_item";
|
|
||||||
|
|
||||||
export class MetaStackerBuilding extends MetaBuilding {
|
export class MetaStackerBuilding extends MetaBuilding {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -63,12 +62,12 @@ export class MetaStackerBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 0),
|
pos: new Vector(1, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
filter: enumItemType.shape,
|
filter: "shape",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -5,7 +5,7 @@ import { ItemEjectorComponent } from "../components/item_ejector";
|
|||||||
import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components/underground_belt";
|
import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components/underground_belt";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
||||||
import { GameRoot, enumLayer } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
|
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
|
||||||
@ -171,7 +171,7 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
|||||||
* @param {Vector} param0.tile
|
* @param {Vector} param0.tile
|
||||||
* @param {number} param0.rotation
|
* @param {number} param0.rotation
|
||||||
* @param {string} param0.variant
|
* @param {string} param0.variant
|
||||||
* @param {string} param0.layer
|
* @param {Layer} param0.layer
|
||||||
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
||||||
*/
|
*/
|
||||||
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
||||||
@ -190,7 +190,7 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
|||||||
tile = tile.addScalars(searchVector.x, searchVector.y);
|
tile = tile.addScalars(searchVector.x, searchVector.y);
|
||||||
|
|
||||||
/* WIRES: FIXME */
|
/* WIRES: FIXME */
|
||||||
const contents = root.map.getTileContent(tile, enumLayer.regular);
|
const contents = root.map.getTileContent(tile, "regular");
|
||||||
if (contents) {
|
if (contents) {
|
||||||
const undergroundComp = contents.components.UndergroundBelt;
|
const undergroundComp = contents.components.UndergroundBelt;
|
||||||
if (undergroundComp && undergroundComp.tier === tier) {
|
if (undergroundComp && undergroundComp.tier === tier) {
|
||||||
|
@ -5,7 +5,7 @@ import { SOUNDS } from "../../platform/sound";
|
|||||||
import { enumWireType, WireComponent } from "../components/wire";
|
import { enumWireType, WireComponent } from "../components/wire";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding } from "../meta_building";
|
import { MetaBuilding } from "../meta_building";
|
||||||
import { enumLayer, GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
|
|
||||||
export const arrayWireRotationVariantToType = [
|
export const arrayWireRotationVariantToType = [
|
||||||
enumWireType.regular,
|
enumWireType.regular,
|
||||||
@ -50,8 +50,9 @@ export class MetaWireBuilding extends MetaBuilding {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"wires"} **/
|
||||||
getLayer() {
|
getLayer() {
|
||||||
return enumLayer.wires;
|
return "wires";
|
||||||
}
|
}
|
||||||
|
|
||||||
getSprite() {
|
getSprite() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Vector } from "../../core/vector";
|
import { Vector } from "../../core/vector";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
||||||
import { GameRoot, enumLayer } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { WireTunnelComponent } from "../components/wire_tunnel";
|
import { WireTunnelComponent } from "../components/wire_tunnel";
|
||||||
import { generateMatrixRotations } from "../../core/utils";
|
import { generateMatrixRotations } from "../../core/utils";
|
||||||
|
|
||||||
@ -55,8 +55,9 @@ export class MetaWireTunnelBuilding extends MetaBuilding {
|
|||||||
return [defaultBuildingVariant, enumWireTunnelVariants.coating];
|
return [defaultBuildingVariant, enumWireTunnelVariants.coating];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"wires"} **/
|
||||||
getLayer() {
|
getLayer() {
|
||||||
return enumLayer.wires;
|
return "wires";
|
||||||
}
|
}
|
||||||
|
|
||||||
getRotateAutomaticallyWhilePlacing() {
|
getRotateAutomaticallyWhilePlacing() {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { enumDirection, enumInvertedDirections, Vector } from "../../core/vector";
|
import { enumDirection, enumInvertedDirections, Vector } from "../../core/vector";
|
||||||
import { types } from "../../savegame/serialization";
|
import { types } from "../../savegame/serialization";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { Component } from "../component";
|
import { Component } from "../component";
|
||||||
|
|
||||||
/** @typedef {{
|
/** @typedef {{
|
||||||
* pos: Vector,
|
* pos: Vector,
|
||||||
* directions: enumDirection[],
|
* directions: enumDirection[],
|
||||||
* filter?: enumItemType
|
* filter?: ItemType
|
||||||
* }} ItemAcceptorSlot */
|
* }} ItemAcceptorSlot */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,7 @@ import { Component } from "../component";
|
|||||||
/** @typedef {{
|
/** @typedef {{
|
||||||
* pos: Vector,
|
* pos: Vector,
|
||||||
* directions: enumDirection[],
|
* directions: enumDirection[],
|
||||||
* filter?: enumItemType
|
* filter?: ItemType
|
||||||
* }} ItemAcceptorSlotConfig */
|
* }} ItemAcceptorSlotConfig */
|
||||||
|
|
||||||
export class ItemAcceptorComponent extends Component {
|
export class ItemAcceptorComponent extends Component {
|
||||||
@ -74,7 +74,7 @@ export class ItemAcceptorComponent extends Component {
|
|||||||
pos: slot.pos,
|
pos: slot.pos,
|
||||||
directions: slot.directions,
|
directions: slot.directions,
|
||||||
|
|
||||||
// Which type of item to accept (shape | color | all) @see enumItemType
|
// Which type of item to accept (shape | color | all) @see ItemType
|
||||||
filter: slot.filter,
|
filter: slot.filter,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { types } from "../../savegame/serialization";
|
import { types } from "../../savegame/serialization";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { Component } from "../component";
|
import { Component } from "../component";
|
||||||
import { typeItemSingleton } from "../item_resolver";
|
import { typeItemSingleton } from "../item_resolver";
|
||||||
import { ColorItem } from "../items/color_item";
|
import { ColorItem } from "../items/color_item";
|
||||||
@ -65,11 +65,11 @@ export class StorageComponent extends Component {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemType === enumItemType.color) {
|
if (itemType === "color") {
|
||||||
return /** @type {ColorItem} */ (this.storedItem).color === /** @type {ColorItem} */ (item).color;
|
return /** @type {ColorItem} */ (this.storedItem).color === /** @type {ColorItem} */ (item).color;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemType === enumItemType.shape) {
|
if (itemType === "shape") {
|
||||||
return (
|
return (
|
||||||
/** @type {ShapeItem} */ (this.storedItem).definition.getHash() ===
|
/** @type {ShapeItem} */ (this.storedItem).definition.getHash() ===
|
||||||
/** @type {ShapeItem} */ (item).definition.getHash()
|
/** @type {ShapeItem} */ (item).definition.getHash()
|
||||||
|
@ -26,7 +26,7 @@ import { GameLogic } from "./logic";
|
|||||||
import { MapView } from "./map_view";
|
import { MapView } from "./map_view";
|
||||||
import { defaultBuildingVariant } from "./meta_building";
|
import { defaultBuildingVariant } from "./meta_building";
|
||||||
import { ProductionAnalytics } from "./production_analytics";
|
import { ProductionAnalytics } from "./production_analytics";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { ShapeDefinitionManager } from "./shape_definition_manager";
|
import { ShapeDefinitionManager } from "./shape_definition_manager";
|
||||||
import { SoundProxy } from "./sound_proxy";
|
import { SoundProxy } from "./sound_proxy";
|
||||||
import { GameTime } from "./time/game_time";
|
import { GameTime } from "./time/game_time";
|
||||||
@ -411,7 +411,7 @@ export class GameCore {
|
|||||||
// Green wires overlay
|
// Green wires overlay
|
||||||
root.hud.parts.wiresOverlay.draw(params);
|
root.hud.parts.wiresOverlay.draw(params);
|
||||||
|
|
||||||
if (this.root.currentLayer === enumLayer.wires) {
|
if (this.root.currentLayer === "wires") {
|
||||||
// Static map entities
|
// Static map entities
|
||||||
root.map.drawWiresForegroundLayer(params);
|
root.map.drawWiresForegroundLayer(params);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { DrawParameters } from "../core/draw_parameters";
|
|||||||
import { Component } from "./component";
|
import { Component } from "./component";
|
||||||
/* typehints:end */
|
/* typehints:end */
|
||||||
|
|
||||||
import { GameRoot, enumLayer } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { globalConfig } from "../core/config";
|
import { globalConfig } from "../core/config";
|
||||||
import { enumDirectionToVector, enumDirectionToAngle } from "../core/vector";
|
import { enumDirectionToVector, enumDirectionToAngle } from "../core/vector";
|
||||||
import { BasicSerializableObject, types } from "../savegame/serialization";
|
import { BasicSerializableObject, types } from "../savegame/serialization";
|
||||||
@ -36,8 +36,9 @@ export class Entity extends BasicSerializableObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* On which layer this entity is
|
* On which layer this entity is
|
||||||
|
* @type {Layer}
|
||||||
*/
|
*/
|
||||||
this.layer = enumLayer.regular;
|
this.layer = "regular";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal entity unique id, set by the @see EntityManager
|
* Internal entity unique id, set by the @see EntityManager
|
||||||
|
@ -3,7 +3,7 @@ import { clamp, findNiceIntegerValue, randomChoice, randomInt } from "../core/ut
|
|||||||
import { BasicSerializableObject, types } from "../savegame/serialization";
|
import { BasicSerializableObject, types } from "../savegame/serialization";
|
||||||
import { enumColors } from "./colors";
|
import { enumColors } from "./colors";
|
||||||
import { enumItemProcessorTypes } from "./components/item_processor";
|
import { enumItemProcessorTypes } from "./components/item_processor";
|
||||||
import { GameRoot, enumLayer } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { enumSubShape, ShapeDefinition } from "./shape_definition";
|
import { enumSubShape, ShapeDefinition } from "./shape_definition";
|
||||||
import { enumHubGoalRewards, tutorialGoals } from "./tutorial_goals";
|
import { enumHubGoalRewards, tutorialGoals } from "./tutorial_goals";
|
||||||
import { UPGRADES } from "./upgrades";
|
import { UPGRADES } from "./upgrades";
|
||||||
|
@ -11,7 +11,6 @@ import { BaseHUDPart } from "../base_hud_part";
|
|||||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||||
import { Blueprint } from "../../blueprint";
|
import { Blueprint } from "../../blueprint";
|
||||||
import { SOUNDS } from "../../../platform/sound";
|
import { SOUNDS } from "../../../platform/sound";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
|
|
||||||
export class HUDBlueprintPlacer extends BaseHUDPart {
|
export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||||
createElements(parent) {
|
createElements(parent) {
|
||||||
@ -60,7 +59,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the layer was changed
|
* Called when the layer was changed
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
*/
|
*/
|
||||||
onEditModeChanged(layer) {
|
onEditModeChanged(layer) {
|
||||||
// Check if the layer of the blueprint differs and thus we have to deselect it
|
// 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 { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||||
import { HUDBuildingPlacerLogic } from "./building_placer_logic";
|
import { HUDBuildingPlacerLogic } from "./building_placer_logic";
|
||||||
import { makeOffscreenBuffer } from "../../../core/buffer_utils";
|
import { makeOffscreenBuffer } from "../../../core/buffer_utils";
|
||||||
import { enumLayer } from "../../root";
|
import { layers } from "../../root";
|
||||||
import { getCodeFromBuildingData } from "../../building_codes";
|
import { getCodeFromBuildingData } from "../../building_codes";
|
||||||
|
|
||||||
export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
||||||
@ -61,9 +61,9 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
|||||||
this.currentInterpolatedCornerTile = new Vector();
|
this.currentInterpolatedCornerTile = new Vector();
|
||||||
|
|
||||||
this.lockIndicatorSprites = {};
|
this.lockIndicatorSprites = {};
|
||||||
for (const layerId in enumLayer) {
|
layers.forEach(layer => {
|
||||||
this.lockIndicatorSprites[layerId] = this.makeLockIndicatorSprite(layerId);
|
this.lockIndicatorSprites[layer] = this.makeLockIndicatorSprite(layer);
|
||||||
}
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the lock indicator sprite for the given layer
|
* Makes the lock indicator sprite for the given layer
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
*/
|
*/
|
||||||
makeLockIndicatorSprite(layer) {
|
makeLockIndicatorSprite(layer) {
|
||||||
const dims = 48;
|
const dims = 48;
|
||||||
|
@ -12,7 +12,6 @@ import { BaseHUDPart } from "../base_hud_part";
|
|||||||
import { SOUNDS } from "../../../platform/sound";
|
import { SOUNDS } from "../../../platform/sound";
|
||||||
import { MetaMinerBuilding, enumMinerVariants } from "../../buildings/miner";
|
import { MetaMinerBuilding, enumMinerVariants } from "../../buildings/miner";
|
||||||
import { enumHubGoalRewards } from "../../tutorial_goals";
|
import { enumHubGoalRewards } from "../../tutorial_goals";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes";
|
import { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes";
|
||||||
import { MetaHubBuilding } from "../../buildings/hub";
|
import { MetaHubBuilding } from "../../buildings/hub";
|
||||||
|
|
||||||
@ -133,12 +132,12 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the edit mode got changed
|
* Called when the edit mode got changed
|
||||||
* @param {enumLayer} editMode
|
* @param {Layer} layer
|
||||||
*/
|
*/
|
||||||
onEditModeChanged(editMode) {
|
onEditModeChanged(layer) {
|
||||||
const metaBuilding = this.currentMetaBuilding.get();
|
const metaBuilding = this.currentMetaBuilding.get();
|
||||||
if (metaBuilding) {
|
if (metaBuilding) {
|
||||||
if (metaBuilding.getLayer() !== editMode) {
|
if (metaBuilding.getLayer() !== layer) {
|
||||||
// This layer doesn't fit the edit mode anymore
|
// This layer doesn't fit the edit mode anymore
|
||||||
this.currentMetaBuilding.set(null);
|
this.currentMetaBuilding.set(null);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import { MetaSplitterBuilding } from "../../buildings/splitter";
|
|||||||
import { MetaStackerBuilding } from "../../buildings/stacker";
|
import { MetaStackerBuilding } from "../../buildings/stacker";
|
||||||
import { MetaTrashBuilding } from "../../buildings/trash";
|
import { MetaTrashBuilding } from "../../buildings/trash";
|
||||||
import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
|
import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { HUDBaseToolbar } from "./base_toolbar";
|
import { HUDBaseToolbar } from "./base_toolbar";
|
||||||
import { MetaLeverBuilding } from "../../buildings/lever";
|
import { MetaLeverBuilding } from "../../buildings/lever";
|
||||||
import { MetaFilterBuilding } from "../../buildings/filter";
|
import { MetaFilterBuilding } from "../../buildings/filter";
|
||||||
@ -35,7 +34,7 @@ export class HUDBuildingsToolbar extends HUDBaseToolbar {
|
|||||||
super(root, {
|
super(root, {
|
||||||
supportedBuildings,
|
supportedBuildings,
|
||||||
visibilityCondition: () =>
|
visibilityCondition: () =>
|
||||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === enumLayer.regular,
|
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === "regular",
|
||||||
htmlElementId: "ingame_HUD_buildings_toolbar",
|
htmlElementId: "ingame_HUD_buildings_toolbar",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import { DrawParameters } from "../../../core/draw_parameters";
|
|||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
import { enumItemType } from "../../base_item";
|
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
|
|
||||||
export class HUDColorBlindHelper extends BaseHUDPart {
|
export class HUDColorBlindHelper extends BaseHUDPart {
|
||||||
createElements(parent) {
|
createElements(parent) {
|
||||||
@ -41,7 +39,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.root.currentLayer !== enumLayer.regular) {
|
if (this.root.currentLayer !== "regular") {
|
||||||
// Not in regular mode
|
// Not in regular mode
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -56,7 +54,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
|||||||
// Check if the belt has a color item
|
// Check if the belt has a color item
|
||||||
if (beltComp) {
|
if (beltComp) {
|
||||||
const item = beltComp.assignedPath.findItemAtTile(tile);
|
const item = beltComp.assignedPath.findItemAtTile(tile);
|
||||||
if (item && item.getItemType() === enumItemType.color) {
|
if (item && item.getItemType() === "color") {
|
||||||
return /** @type {ColorItem} */ (item).color;
|
return /** @type {ColorItem} */ (item).color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +64,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
|||||||
if (ejectorComp) {
|
if (ejectorComp) {
|
||||||
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
for (let i = 0; i < ejectorComp.slots.length; ++i) {
|
||||||
const slot = ejectorComp.slots[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;
|
return /** @type {ColorItem} */ (slot.item).color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +72,7 @@ export class HUDColorBlindHelper extends BaseHUDPart {
|
|||||||
} else {
|
} else {
|
||||||
// We hovered a lower layer, show the color there
|
// We hovered a lower layer, show the color there
|
||||||
const lowerLayer = this.root.map.getLowerLayerContentXY(tile.x, tile.y);
|
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;
|
return /** @type {ColorItem} */ (lowerLayer).color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { globalConfig } from "../../../core/config";
|
|||||||
import { Loader } from "../../../core/loader";
|
import { Loader } from "../../../core/loader";
|
||||||
import { Vector } from "../../../core/vector";
|
import { Vector } from "../../../core/vector";
|
||||||
import { MapChunkView } from "../../map_chunk_view";
|
import { MapChunkView } from "../../map_chunk_view";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ export class HUDLayerPreview extends BaseHUDPart {
|
|||||||
const tileX = dx + startTileX;
|
const tileX = dx + startTileX;
|
||||||
const tileY = dy + startTileY;
|
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) {
|
if (content) {
|
||||||
MapChunkView.drawSingleWiresOverviewTile({
|
MapChunkView.drawSingleWiresOverviewTile({
|
||||||
context: this.context,
|
context: this.context,
|
||||||
@ -104,7 +103,7 @@ export class HUDLayerPreview extends BaseHUDPart {
|
|||||||
* @param {number} scale 1 / zoomLevel
|
* @param {number} scale 1 / zoomLevel
|
||||||
*/
|
*/
|
||||||
renderPreview(parameters, worldPos, scale) {
|
renderPreview(parameters, worldPos, scale) {
|
||||||
if (this.root.currentLayer !== enumLayer.regular) {
|
if (this.root.currentLayer !== "regular") {
|
||||||
// Only supporting wires right now
|
// Only supporting wires right now
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||||
import { Vector } from "../../../core/vector";
|
import { Vector } from "../../../core/vector";
|
||||||
import { enumMouseButton } from "../../camera";
|
import { enumMouseButton } from "../../camera";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
|
||||||
export class HUDLeverToggle extends BaseHUDPart {
|
export class HUDLeverToggle extends BaseHUDPart {
|
||||||
@ -15,7 +14,7 @@ export class HUDLeverToggle extends BaseHUDPart {
|
|||||||
*/
|
*/
|
||||||
downPreHandler(pos, button) {
|
downPreHandler(pos, button) {
|
||||||
const tile = this.root.camera.screenToWorld(pos).toTileSpace();
|
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) {
|
if (contents) {
|
||||||
const leverComp = contents.components.Lever;
|
const leverComp = contents.components.Lever;
|
||||||
if (leverComp) {
|
if (leverComp) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { MapChunkView } from "../../map_chunk_view";
|
import { MapChunkView } from "../../map_chunk_view";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { WireNetwork } from "../../systems/wire";
|
import { WireNetwork } from "../../systems/wire";
|
||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
@ -17,7 +16,7 @@ export class HUDWireInfo extends BaseHUDPart {
|
|||||||
* @param {import("../../../core/draw_utils").DrawParameters} parameters
|
* @param {import("../../../core/draw_utils").DrawParameters} parameters
|
||||||
*/
|
*/
|
||||||
drawOverlays(parameters) {
|
drawOverlays(parameters) {
|
||||||
if (this.root.currentLayer !== enumLayer.wires) {
|
if (this.root.currentLayer !== "wires") {
|
||||||
// Not in the wires layer
|
// Not in the wires layer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -30,7 +29,7 @@ export class HUDWireInfo extends BaseHUDPart {
|
|||||||
|
|
||||||
const worldPos = this.root.camera.screenToWorld(mousePos);
|
const worldPos = this.root.camera.screenToWorld(mousePos);
|
||||||
const tile = worldPos.toTileSpace();
|
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) {
|
if (!entity) {
|
||||||
// No entity
|
// No entity
|
||||||
|
@ -2,7 +2,6 @@ import { makeOffscreenBuffer } from "../../../core/buffer_utils";
|
|||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { DrawParameters } from "../../../core/draw_parameters";
|
import { DrawParameters } from "../../../core/draw_parameters";
|
||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { enumLayer } from "../../root";
|
|
||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
import { Loader } from "../../../core/loader";
|
import { Loader } from "../../../core/loader";
|
||||||
@ -26,10 +25,10 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
|||||||
* Switches between layers
|
* Switches between layers
|
||||||
*/
|
*/
|
||||||
switchLayers() {
|
switchLayers() {
|
||||||
if (this.root.currentLayer === enumLayer.regular) {
|
if (this.root.currentLayer === "regular") {
|
||||||
this.root.currentLayer = enumLayer.wires;
|
this.root.currentLayer = "wires";
|
||||||
} else {
|
} else {
|
||||||
this.root.currentLayer = enumLayer.regular;
|
this.root.currentLayer = "regular";
|
||||||
}
|
}
|
||||||
this.root.signals.editModeChanged.dispatch(this.root.currentLayer);
|
this.root.signals.editModeChanged.dispatch(this.root.currentLayer);
|
||||||
}
|
}
|
||||||
@ -51,7 +50,7 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
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);
|
this.currentAlpha = lerp(this.currentAlpha, desiredAlpha, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { enumLayer } from "../../root";
|
|
||||||
import { HUDBaseToolbar } from "./base_toolbar";
|
import { HUDBaseToolbar } from "./base_toolbar";
|
||||||
import { MetaWireBuilding } from "../../buildings/wire";
|
import { MetaWireBuilding } from "../../buildings/wire";
|
||||||
import { MetaConstantSignalBuilding } from "../../buildings/constant_signal";
|
import { MetaConstantSignalBuilding } from "../../buildings/constant_signal";
|
||||||
@ -19,7 +18,7 @@ export class HUDWiresToolbar extends HUDBaseToolbar {
|
|||||||
super(root, {
|
super(root, {
|
||||||
supportedBuildings,
|
supportedBuildings,
|
||||||
visibilityCondition: () =>
|
visibilityCondition: () =>
|
||||||
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === enumLayer.wires,
|
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === "wires",
|
||||||
htmlElementId: "ingame_HUD_wires_toolbar",
|
htmlElementId: "ingame_HUD_wires_toolbar",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { GameRoot, enumLayer } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { Vector, mixVector } from "../../core/vector";
|
import { Vector, mixVector } from "../../core/vector";
|
||||||
import { lerp } from "../../core/utils";
|
import { lerp } from "../../core/utils";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { types } from "../../savegame/serialization";
|
import { types } from "../../savegame/serialization";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
|
|
||||||
export class BooleanItem extends BaseItem {
|
export class BooleanItem extends BaseItem {
|
||||||
static getId() {
|
static getId() {
|
||||||
@ -20,8 +20,9 @@ export class BooleanItem extends BaseItem {
|
|||||||
this.value = data;
|
this.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"boolean"} **/
|
||||||
getItemType() {
|
getItemType() {
|
||||||
return enumItemType.boolean;
|
return "boolean";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,7 @@ import { globalConfig } from "../../core/config";
|
|||||||
import { smoothenDpi } from "../../core/dpi_manager";
|
import { smoothenDpi } from "../../core/dpi_manager";
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { types } from "../../savegame/serialization";
|
import { types } from "../../savegame/serialization";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumColors, enumColorsToHexCode } from "../colors";
|
import { enumColors, enumColorsToHexCode } from "../colors";
|
||||||
import { THEME } from "../theme";
|
import { THEME } from "../theme";
|
||||||
|
|
||||||
@ -23,8 +23,9 @@ export class ColorItem extends BaseItem {
|
|||||||
this.color = data;
|
this.color = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"color"} **/
|
||||||
getItemType() {
|
getItemType() {
|
||||||
return enumItemType.color;
|
return "color";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { types } from "../../savegame/serialization";
|
import { types } from "../../savegame/serialization";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { ShapeDefinition } from "../shape_definition";
|
import { ShapeDefinition } from "../shape_definition";
|
||||||
import { THEME } from "../theme";
|
import { THEME } from "../theme";
|
||||||
|
|
||||||
@ -21,8 +21,9 @@ export class ShapeItem extends BaseItem {
|
|||||||
this.definition = ShapeDefinition.fromShortKey(data);
|
this.definition = ShapeDefinition.fromShortKey(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {"shape"} **/
|
||||||
getItemType() {
|
getItemType() {
|
||||||
return enumItemType.shape;
|
return "shape";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector }
|
|||||||
import { getBuildingDataFromCode } from "./building_codes";
|
import { getBuildingDataFromCode } from "./building_codes";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { MetaBuilding } from "./meta_building";
|
import { MetaBuilding } from "./meta_building";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { WireNetwork } from "./systems/wire";
|
import { WireNetwork } from "./systems/wire";
|
||||||
import { globalConfig } from "../core/config";
|
import { globalConfig } from "../core/config";
|
||||||
import { CHUNK_OVERLAY_RES } from "./map_chunk_view";
|
import { CHUNK_OVERLAY_RES } from "./map_chunk_view";
|
||||||
@ -347,7 +347,7 @@ export class GameLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now check if there's a connectable wire
|
// Now check if there's a connectable wire
|
||||||
const targetEntity = this.root.map.getTileContent(tile, enumLayer.wires);
|
const targetEntity = this.root.map.getTileContent(tile, "wires");
|
||||||
if (!targetEntity) {
|
if (!targetEntity) {
|
||||||
return enumWireEdgeFlag.empty;
|
return enumWireEdgeFlag.empty;
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ export class GameLogic {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entity = this.root.map.getLayerContentXY(tile.x + dx, tile.y + dy, enumLayer.regular);
|
const entity = this.root.map.getLayerContentXY(tile.x + dx, tile.y + dy, "regular");
|
||||||
if (entity) {
|
if (entity) {
|
||||||
let ejectorSlots = [];
|
let ejectorSlots = [];
|
||||||
let acceptorSlots = [];
|
let acceptorSlots = [];
|
||||||
|
@ -4,7 +4,7 @@ import { BasicSerializableObject, types } from "../savegame/serialization";
|
|||||||
import { BaseItem } from "./base_item";
|
import { BaseItem } from "./base_item";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { MapChunkView } from "./map_chunk_view";
|
import { MapChunkView } from "./map_chunk_view";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
|
|
||||||
export class BaseMap extends BasicSerializableObject {
|
export class BaseMap extends BasicSerializableObject {
|
||||||
static getId() {
|
static getId() {
|
||||||
@ -94,7 +94,7 @@ export class BaseMap extends BasicSerializableObject {
|
|||||||
/**
|
/**
|
||||||
* Returns the tile content of a given tile
|
* Returns the tile content of a given tile
|
||||||
* @param {Vector} tile
|
* @param {Vector} tile
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
* @returns {Entity} Entity or null
|
* @returns {Entity} Entity or null
|
||||||
*/
|
*/
|
||||||
getTileContent(tile, layer) {
|
getTileContent(tile, layer) {
|
||||||
@ -119,7 +119,7 @@ export class BaseMap extends BasicSerializableObject {
|
|||||||
* Returns the tile content of a given tile
|
* Returns the tile content of a given tile
|
||||||
* @param {number} x
|
* @param {number} x
|
||||||
* @param {number} y
|
* @param {number} y
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
* @returns {Entity} Entity or null
|
* @returns {Entity} Entity or null
|
||||||
*/
|
*/
|
||||||
getLayerContentXY(x, y, layer) {
|
getLayerContentXY(x, y, layer) {
|
||||||
@ -144,7 +144,7 @@ export class BaseMap extends BasicSerializableObject {
|
|||||||
/**
|
/**
|
||||||
* Checks if the tile is used
|
* Checks if the tile is used
|
||||||
* @param {Vector} tile
|
* @param {Vector} tile
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isTileUsed(tile, layer) {
|
isTileUsed(tile, layer) {
|
||||||
@ -159,7 +159,7 @@ export class BaseMap extends BasicSerializableObject {
|
|||||||
* Checks if the tile is used
|
* Checks if the tile is used
|
||||||
* @param {number} x
|
* @param {number} x
|
||||||
* @param {number} y
|
* @param {number} y
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isTileUsedXY(x, y, layer) {
|
isTileUsedXY(x, y, layer) {
|
||||||
|
@ -7,7 +7,7 @@ import { BaseItem } from "./base_item";
|
|||||||
import { enumColors } from "./colors";
|
import { enumColors } from "./colors";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { COLOR_ITEM_SINGLETONS } from "./items/color_item";
|
import { COLOR_ITEM_SINGLETONS } from "./items/color_item";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { enumSubShape } from "./shape_definition";
|
import { enumSubShape } from "./shape_definition";
|
||||||
import { Rectangle } from "../core/rectangle";
|
import { Rectangle } from "../core/rectangle";
|
||||||
|
|
||||||
@ -70,11 +70,11 @@ export class MapChunk {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Which entities this chunk contains, sorted by layer
|
* Which entities this chunk contains, sorted by layer
|
||||||
* @type {Object<string, Array<Entity>>}
|
* @type {Record<Layer, Array<Entity>>}
|
||||||
*/
|
*/
|
||||||
this.containedEntitiesByLayer = {
|
this.containedEntitiesByLayer = {
|
||||||
[enumLayer.regular]: [],
|
regular: [],
|
||||||
[enumLayer.wires]: [],
|
wires: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,7 +362,7 @@ export class MapChunk {
|
|||||||
* Returns the contents of this chunk from the given world space coordinates
|
* Returns the contents of this chunk from the given world space coordinates
|
||||||
* @param {number} worldX
|
* @param {number} worldX
|
||||||
* @param {number} worldY
|
* @param {number} worldY
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
* @returns {Entity=}
|
* @returns {Entity=}
|
||||||
*/
|
*/
|
||||||
getLayerContentFromWorldCoords(worldX, worldY, layer) {
|
getLayerContentFromWorldCoords(worldX, worldY, layer) {
|
||||||
@ -372,7 +372,7 @@ export class MapChunk {
|
|||||||
assert(localY >= 0, "Local Y is < 0");
|
assert(localY >= 0, "Local Y is < 0");
|
||||||
assert(localX < globalConfig.mapChunkSize, "Local X is >= chunk size");
|
assert(localX < globalConfig.mapChunkSize, "Local X is >= chunk size");
|
||||||
assert(localY < globalConfig.mapChunkSize, "Local Y is >= chunk size");
|
assert(localY < globalConfig.mapChunkSize, "Local Y is >= chunk size");
|
||||||
if (layer === enumLayer.regular) {
|
if (layer === "regular") {
|
||||||
return this.contents[localX][localY] || null;
|
return this.contents[localX][localY] || null;
|
||||||
} else {
|
} else {
|
||||||
return this.wireContents[localX][localY] || null;
|
return this.wireContents[localX][localY] || null;
|
||||||
@ -425,7 +425,7 @@ export class MapChunk {
|
|||||||
* @param {number} tileX
|
* @param {number} tileX
|
||||||
* @param {number} tileY
|
* @param {number} tileY
|
||||||
* @param {Entity=} contents
|
* @param {Entity=} contents
|
||||||
* @param {enumLayer} layer
|
* @param {Layer} layer
|
||||||
*/
|
*/
|
||||||
setLayerContentFromWorldCords(tileX, tileY, contents, layer) {
|
setLayerContentFromWorldCords(tileX, tileY, contents, layer) {
|
||||||
const localX = tileX - this.tileX;
|
const localX = tileX - this.tileX;
|
||||||
@ -436,7 +436,7 @@ export class MapChunk {
|
|||||||
assert(localY < globalConfig.mapChunkSize, "Local Y is >= chunk size");
|
assert(localY < globalConfig.mapChunkSize, "Local Y is >= chunk size");
|
||||||
|
|
||||||
let oldContents;
|
let oldContents;
|
||||||
if (layer === enumLayer.regular) {
|
if (layer === "regular") {
|
||||||
oldContents = this.contents[localX][localY];
|
oldContents = this.contents[localX][localY];
|
||||||
} else {
|
} else {
|
||||||
oldContents = this.wireContents[localX][localY];
|
oldContents = this.wireContents[localX][localY];
|
||||||
@ -450,7 +450,7 @@ export class MapChunk {
|
|||||||
fastArrayDeleteValueIfContained(this.containedEntitiesByLayer[layer], oldContents);
|
fastArrayDeleteValueIfContained(this.containedEntitiesByLayer[layer], oldContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer === enumLayer.regular) {
|
if (layer === "regular") {
|
||||||
this.contents[localX][localY] = contents;
|
this.contents[localX][localY] = contents;
|
||||||
} else {
|
} else {
|
||||||
this.wireContents[localX][localY] = contents;
|
this.wireContents[localX][localY] = contents;
|
||||||
|
@ -3,7 +3,7 @@ import { DrawParameters } from "../core/draw_parameters";
|
|||||||
import { getBuildingDataFromCode } from "./building_codes";
|
import { getBuildingDataFromCode } from "./building_codes";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { MapChunk } from "./map_chunk";
|
import { MapChunk } from "./map_chunk";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { THEME } from "./theme";
|
import { THEME } from "./theme";
|
||||||
import { drawSpriteClipped } from "../core/draw_utils";
|
import { drawSpriteClipped } from "../core/draw_utils";
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ export class MapChunkView extends MapChunk {
|
|||||||
parameters.context.imageSmoothingEnabled = true;
|
parameters.context.imageSmoothingEnabled = true;
|
||||||
|
|
||||||
// Draw patch items
|
// Draw patch items
|
||||||
if (this.root.currentLayer === enumLayer.regular) {
|
if (this.root.currentLayer === "regular") {
|
||||||
for (let i = 0; i < this.patches.length; ++i) {
|
for (let i = 0; i < this.patches.length; ++i) {
|
||||||
const patch = this.patches[i];
|
const patch = this.patches[i];
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ export class MapChunkView extends MapChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.root.currentLayer === enumLayer.wires) {
|
if (this.root.currentLayer === "wires") {
|
||||||
// Draw wires overlay
|
// Draw wires overlay
|
||||||
|
|
||||||
context.fillStyle = THEME.map.wires.overlayColor;
|
context.fillStyle = THEME.map.wires.overlayColor;
|
||||||
|
@ -4,7 +4,7 @@ import { Vector } from "../core/vector";
|
|||||||
import { SOUNDS } from "../platform/sound";
|
import { SOUNDS } from "../platform/sound";
|
||||||
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
||||||
import { Entity } from "./entity";
|
import { Entity } from "./entity";
|
||||||
import { enumLayer, GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { getCodeFromBuildingData } from "./building_codes";
|
import { getCodeFromBuildingData } from "./building_codes";
|
||||||
|
|
||||||
export const defaultBuildingVariant = "default";
|
export const defaultBuildingVariant = "default";
|
||||||
@ -27,10 +27,10 @@ export class MetaBuilding {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the edit layer of the building
|
* Returns the edit layer of the building
|
||||||
* @returns {enumLayer}
|
* @returns {Layer}
|
||||||
*/
|
*/
|
||||||
getLayer() {
|
getLayer() {
|
||||||
return enumLayer.regular;
|
return "regular";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,7 +236,7 @@ export class MetaBuilding {
|
|||||||
* @param {Vector} param0.tile
|
* @param {Vector} param0.tile
|
||||||
* @param {number} param0.rotation
|
* @param {number} param0.rotation
|
||||||
* @param {string} param0.variant
|
* @param {string} param0.variant
|
||||||
* @param {string} param0.layer
|
* @param {Layer} param0.layer
|
||||||
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
||||||
*/
|
*/
|
||||||
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { GameRoot } from "./root";
|
import { GameRoot } from "./root";
|
||||||
import { ShapeDefinition } from "./shape_definition";
|
import { ShapeDefinition } from "./shape_definition";
|
||||||
import { globalConfig } from "../core/config";
|
import { globalConfig } from "../core/config";
|
||||||
import { BaseItem, enumItemType } from "./base_item";
|
import { BaseItem } from "./base_item";
|
||||||
import { ShapeItem } from "./items/shape_item";
|
import { ShapeItem } from "./items/shape_item";
|
||||||
import { BasicSerializableObject } from "../savegame/serialization";
|
import { BasicSerializableObject } from "../savegame/serialization";
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ export class ProductionAnalytics extends BasicSerializableObject {
|
|||||||
* @param {BaseItem} item
|
* @param {BaseItem} item
|
||||||
*/
|
*/
|
||||||
onItemProduced(item) {
|
onItemProduced(item) {
|
||||||
if (item.getItemType() === enumItemType.shape) {
|
if (item.getItemType() === "shape") {
|
||||||
const definition = /** @type {ShapeItem} */ (item).definition;
|
const definition = /** @type {ShapeItem} */ (item).definition;
|
||||||
const key = definition.getHash();
|
const key = definition.getHash();
|
||||||
const entry = this.history[enumAnalyticsDataSource.produced];
|
const entry = this.history[enumAnalyticsDataSource.produced];
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
|
|
||||||
import { Signal } from "../core/signal";
|
import { Signal } from "../core/signal";
|
||||||
import { RandomNumberGenerator } from "../core/rng";
|
import { RandomNumberGenerator } from "../core/rng";
|
||||||
import { createLogger } from "../core/logging";
|
import { createLogger } from "../core/logging";
|
||||||
@ -32,14 +31,8 @@ import { Vector } from "../core/vector";
|
|||||||
|
|
||||||
const logger = createLogger("game/root");
|
const logger = createLogger("game/root");
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @type {Array<Layer>} */
|
||||||
export const enumLayer = {
|
export const layers = ["regular", "wires"];
|
||||||
regular: "regular",
|
|
||||||
wires: "wires",
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @type {Array<enumLayer>} */
|
|
||||||
export const arrayLayers = [enumLayer.regular, enumLayer.wires];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The game root is basically the whole game state at a given point,
|
* The game root is basically the whole game state at a given point,
|
||||||
@ -134,8 +127,8 @@ export class GameRoot {
|
|||||||
/** @type {DynamicTickrate} */
|
/** @type {DynamicTickrate} */
|
||||||
this.dynamicTickrate = null;
|
this.dynamicTickrate = null;
|
||||||
|
|
||||||
/** @type {enumLayer} */
|
/** @type {Layer} */
|
||||||
this.currentLayer = enumLayer.regular;
|
this.currentLayer = "regular";
|
||||||
|
|
||||||
this.signals = {
|
this.signals = {
|
||||||
// Entities
|
// Entities
|
||||||
@ -167,7 +160,7 @@ export class GameRoot {
|
|||||||
|
|
||||||
bulkOperationFinished: /** @type {TypedSignal<[]>} */ (new Signal()),
|
bulkOperationFinished: /** @type {TypedSignal<[]>} */ (new Signal()),
|
||||||
|
|
||||||
editModeChanged: /** @type {TypedSignal<[enumLayer]>} */ (new Signal()),
|
editModeChanged: /** @type {TypedSignal<[Layer]>} */ (new Signal()),
|
||||||
|
|
||||||
// Called to check if an entity can be placed, second parameter is an additional offset.
|
// Called to check if an entity can be placed, second parameter is an additional offset.
|
||||||
// Use to introduce additional placement checks
|
// Use to introduce additional placement checks
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumColors } from "../colors";
|
import { enumColors } from "../colors";
|
||||||
import { DisplayComponent } from "../components/display";
|
import { DisplayComponent } from "../components/display";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
|
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
import { BooleanItem } from "../items/boolean_item";
|
import { BooleanItem } from "../items/boolean_item";
|
||||||
|
|
||||||
export class DisplaySystem extends GameSystemWithFilter {
|
export class DisplaySystem extends GameSystemWithFilter {
|
||||||
@ -35,18 +34,18 @@ export class DisplaySystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (value.getItemType()) {
|
switch (value.getItemType()) {
|
||||||
case enumItemType.boolean: {
|
case "boolean": {
|
||||||
return /** @type {BooleanItem} */ (value).value
|
return /** @type {BooleanItem} */ (value).value
|
||||||
? COLOR_ITEM_SINGLETONS[enumColors.white]
|
? COLOR_ITEM_SINGLETONS[enumColors.white]
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
case enumItemType.color: {
|
case "color": {
|
||||||
const item = /**@type {ColorItem} */ (value);
|
const item = /**@type {ColorItem} */ (value);
|
||||||
return item.color === enumColors.uncolored ? null : item;
|
return item.color === enumColors.uncolored ? null : item;
|
||||||
}
|
}
|
||||||
|
|
||||||
case enumItemType.shape: {
|
case "shape": {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ export class DisplaySystem extends GameSystemWithFilter {
|
|||||||
* @param {MapChunkView} chunk
|
* @param {MapChunkView} chunk
|
||||||
*/
|
*/
|
||||||
drawChunk(parameters, chunk) {
|
drawChunk(parameters, chunk) {
|
||||||
const contents = chunk.containedEntitiesByLayer[enumLayer.regular];
|
const contents = chunk.containedEntitiesByLayer.regular;
|
||||||
for (let i = 0; i < contents.length; ++i) {
|
for (let i = 0; i < contents.length; ++i) {
|
||||||
const entity = contents[i];
|
const entity = contents[i];
|
||||||
if (entity && entity.components.Display) {
|
if (entity && entity.components.Display) {
|
||||||
@ -77,15 +76,15 @@ export class DisplaySystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const origin = entity.components.StaticMapEntity.origin;
|
const origin = entity.components.StaticMapEntity.origin;
|
||||||
if (value.getItemType() === enumItemType.color) {
|
if (value.getItemType() === "color") {
|
||||||
this.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(
|
this.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(
|
||||||
parameters,
|
parameters,
|
||||||
(origin.x + 0.5) * globalConfig.tileSize,
|
(origin.x + 0.5) * globalConfig.tileSize,
|
||||||
(origin.y + 0.5) * globalConfig.tileSize,
|
(origin.y + 0.5) * globalConfig.tileSize,
|
||||||
globalConfig.tileSize
|
globalConfig.tileSize
|
||||||
);
|
);
|
||||||
} else if (value.getItemType() === enumItemType.shape) {
|
} else if (value.getItemType() === "shape") {
|
||||||
value.drawCentered(
|
value.draw(
|
||||||
(origin.x + 0.5) * globalConfig.tileSize,
|
(origin.x + 0.5) * globalConfig.tileSize,
|
||||||
(origin.y + 0.5) * globalConfig.tileSize,
|
(origin.y + 0.5) * globalConfig.tileSize,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -5,7 +5,6 @@ import { enumDirectionToVector } from "../../core/vector";
|
|||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
|
|
||||||
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
export class ItemAcceptorSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
|
@ -4,7 +4,6 @@ import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON } from "../items/boolean_item
|
|||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
|
|
||||||
export class LeverSystem extends GameSystemWithFilter {
|
export class LeverSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
@ -32,7 +31,7 @@ export class LeverSystem extends GameSystemWithFilter {
|
|||||||
* @param {MapChunkView} chunk
|
* @param {MapChunkView} chunk
|
||||||
*/
|
*/
|
||||||
drawChunk(parameters, chunk) {
|
drawChunk(parameters, chunk) {
|
||||||
const contents = chunk.containedEntitiesByLayer[enumLayer.regular];
|
const contents = chunk.containedEntitiesByLayer.regular;
|
||||||
for (let i = 0; i < contents.length; ++i) {
|
for (let i = 0; i < contents.length; ++i) {
|
||||||
const entity = contents[i];
|
const entity = contents[i];
|
||||||
if (entity && entity.components.Lever) {
|
if (entity && entity.components.Lever) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { LogicGateComponent, enumLogicGateType } from "../components/logic_gate";
|
import { LogicGateComponent, enumLogicGateType } from "../components/logic_gate";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumPinSlotType } from "../components/wired_pins";
|
import { enumPinSlotType } from "../components/wired_pins";
|
||||||
import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON, BooleanItem } from "../items/boolean_item";
|
import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON, BooleanItem } from "../items/boolean_item";
|
||||||
import { enumItemProcessorTypes } from "../components/item_processor";
|
import { enumItemProcessorTypes } from "../components/item_processor";
|
||||||
@ -72,7 +72,7 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
|||||||
return BOOL_FALSE_SINGLETON;
|
return BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemType === enumItemType.boolean) {
|
if (itemType === "boolean") {
|
||||||
return /** @type {BooleanItem} */ (param1).value && /** @type {BooleanItem} */ (param2).value
|
return /** @type {BooleanItem} */ (param1).value && /** @type {BooleanItem} */ (param2).value
|
||||||
? BOOL_TRUE_SINGLETON
|
? BOOL_TRUE_SINGLETON
|
||||||
: BOOL_FALSE_SINGLETON;
|
: BOOL_FALSE_SINGLETON;
|
||||||
@ -91,7 +91,7 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
|||||||
return BOOL_TRUE_SINGLETON;
|
return BOOL_TRUE_SINGLETON;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemType() !== enumItemType.boolean) {
|
if (item.getItemType() !== "boolean") {
|
||||||
// Not a boolean actually
|
// Not a boolean actually
|
||||||
return BOOL_FALSE_SINGLETON;
|
return BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
@ -115,11 +115,11 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for the right types
|
// Check for the right types
|
||||||
if (param1 && param1.getItemType() !== enumItemType.boolean) {
|
if (param1 && param1.getItemType() !== "boolean") {
|
||||||
return BOOL_FALSE_SINGLETON;
|
return BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param2 && param2.getItemType() !== enumItemType.boolean) {
|
if (param2 && param2.getItemType() !== "boolean") {
|
||||||
return BOOL_FALSE_SINGLETON;
|
return BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,13 +144,9 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const valueParam1 =
|
const valueParam1 =
|
||||||
param1 && param1.getItemType() === enumItemType.boolean
|
param1 && param1.getItemType() === "boolean" ? /** @type {BooleanItem} */ (param1).value : 0;
|
||||||
? /** @type {BooleanItem} */ (param1).value
|
|
||||||
: 0;
|
|
||||||
const valueParam2 =
|
const valueParam2 =
|
||||||
param2 && param2.getItemType() === enumItemType.boolean
|
param2 && param2.getItemType() === "boolean" ? /** @type {BooleanItem} */ (param2).value : 0;
|
||||||
? /** @type {BooleanItem} */ (param2).value
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
return valueParam1 || valueParam2 ? BOOL_TRUE_SINGLETON : BOOL_FALSE_SINGLETON;
|
return valueParam1 || valueParam2 ? BOOL_TRUE_SINGLETON : BOOL_FALSE_SINGLETON;
|
||||||
}
|
}
|
||||||
@ -169,7 +165,7 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag.getItemType() !== enumItemType.boolean) {
|
if (flag.getItemType() !== "boolean") {
|
||||||
// Flag is not a boolean
|
// Flag is not a boolean
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import { MinerComponent } from "../components/miner";
|
|||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
|
|
||||||
export class MinerSystem extends GameSystemWithFilter {
|
export class MinerSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
@ -75,7 +74,7 @@ export class MinerSystem extends GameSystemWithFilter {
|
|||||||
const ejectingDirection = staticComp.localDirectionToWorld(ejectingSlot.direction);
|
const ejectingDirection = staticComp.localDirectionToWorld(ejectingSlot.direction);
|
||||||
|
|
||||||
const targetTile = ejectingPos.add(enumDirectionToVector[ejectingDirection]);
|
const targetTile = ejectingPos.add(enumDirectionToVector[ejectingDirection]);
|
||||||
const targetContents = this.root.map.getTileContent(targetTile, enumLayer.regular);
|
const targetContents = this.root.map.getTileContent(targetTile, "regular");
|
||||||
|
|
||||||
// Check if we are connected to another miner and thus do not eject directly
|
// Check if we are connected to another miner and thus do not eject directly
|
||||||
if (targetContents) {
|
if (targetContents) {
|
||||||
|
@ -13,7 +13,6 @@ import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components
|
|||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { fastArrayDelete } from "../../core/utils";
|
import { fastArrayDelete } from "../../core/utils";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
|
|
||||||
const logger = createLogger("tunnels");
|
const logger = createLogger("tunnels");
|
||||||
|
|
||||||
@ -298,7 +297,7 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
|
|||||||
) {
|
) {
|
||||||
currentTile = currentTile.add(searchVector);
|
currentTile = currentTile.add(searchVector);
|
||||||
|
|
||||||
const potentialReceiver = this.root.map.getTileContent(currentTile, enumLayer.regular);
|
const potentialReceiver = this.root.map.getTileContent(currentTile, "regular");
|
||||||
if (!potentialReceiver) {
|
if (!potentialReceiver) {
|
||||||
// Empty tile
|
// Empty tile
|
||||||
continue;
|
continue;
|
||||||
|
@ -12,7 +12,8 @@ import {
|
|||||||
enumInvertedDirections,
|
enumInvertedDirections,
|
||||||
Vector,
|
Vector,
|
||||||
} from "../../core/vector";
|
} from "../../core/vector";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
|
import { BooleanItem } from "../items/boolean_item";
|
||||||
import { arrayWireRotationVariantToType, MetaWireBuilding } from "../buildings/wire";
|
import { arrayWireRotationVariantToType, MetaWireBuilding } from "../buildings/wire";
|
||||||
import { getCodeFromBuildingData } from "../building_codes";
|
import { getCodeFromBuildingData } from "../building_codes";
|
||||||
import { enumWireType, WireComponent } from "../components/wire";
|
import { enumWireType, WireComponent } from "../components/wire";
|
||||||
@ -577,17 +578,17 @@ export class WireSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const valueType = value.getItemType();
|
const valueType = value.getItemType();
|
||||||
if (valueType === enumItemType.shape) {
|
if (valueType === "shape") {
|
||||||
return {
|
return {
|
||||||
spriteSet: this.wireSprites.shape,
|
spriteSet: this.wireSprites.shape,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
};
|
};
|
||||||
} else if (valueType === enumItemType.color) {
|
} else if (valueType === "color") {
|
||||||
return {
|
return {
|
||||||
spriteSet: this.wireSprites.color,
|
spriteSet: this.wireSprites.color,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
};
|
};
|
||||||
} else if (valueType === enumItemType.boolean) {
|
} else if (valueType === "boolean") {
|
||||||
return {
|
return {
|
||||||
spriteSet: this.wireSprites.regular,
|
spriteSet: this.wireSprites.regular,
|
||||||
opacity: /** @type {BooleanItem} */ (value).value ? 1 : 0.5,
|
opacity: /** @type {BooleanItem} */ (value).value ? 1 : 0.5,
|
||||||
|
@ -5,7 +5,6 @@ import { Vector, enumDirectionToAngle } from "../../core/vector";
|
|||||||
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { enumLayer } from "../root";
|
|
||||||
import { STOP_PROPAGATION } from "../../core/signal";
|
import { STOP_PROPAGATION } from "../../core/signal";
|
||||||
import { drawRotatedSprite } from "../../core/draw_utils";
|
import { drawRotatedSprite } from "../../core/draw_utils";
|
||||||
import { GLOBAL_APP } from "../../core/globals";
|
import { GLOBAL_APP } from "../../core/globals";
|
||||||
@ -38,7 +37,7 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
// If this entity is placed on the wires layer, make sure we don't
|
// If this entity is placed on the wires layer, make sure we don't
|
||||||
// place it above a pin
|
// place it above a pin
|
||||||
if (entity.layer === enumLayer.wires) {
|
if (entity.layer === "wires") {
|
||||||
for (let x = rect.x; x < rect.x + rect.w; ++x) {
|
for (let x = rect.x; x < rect.x + rect.w; ++x) {
|
||||||
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
||||||
// Find which entities are in same tiles of both layers
|
// Find which entities are in same tiles of both layers
|
||||||
@ -103,7 +102,7 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is any entity on that tile (Wired pins are always on the wires layer)
|
// Check if there is any entity on that tile (Wired pins are always on the wires layer)
|
||||||
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, enumLayer.wires);
|
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, "wires");
|
||||||
|
|
||||||
// If there's an entity, and it can't get removed -> That's a collision
|
// If there's an entity, and it can't get removed -> That's a collision
|
||||||
if (collidingEntity) {
|
if (collidingEntity) {
|
||||||
@ -130,7 +129,7 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
|||||||
for (let i = 0; i < pinsComp.slots.length; ++i) {
|
for (let i = 0; i < pinsComp.slots.length; ++i) {
|
||||||
const slot = pinsComp.slots[i];
|
const slot = pinsComp.slots[i];
|
||||||
const worldPos = entity.components.StaticMapEntity.localTileToWorld(slot.pos);
|
const worldPos = entity.components.StaticMapEntity.localTileToWorld(slot.pos);
|
||||||
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, enumLayer.wires);
|
const collidingEntity = this.root.map.getLayerContentXY(worldPos.x, worldPos.y, "wires");
|
||||||
if (collidingEntity) {
|
if (collidingEntity) {
|
||||||
assertAlways(
|
assertAlways(
|
||||||
collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(),
|
collidingEntity.components.StaticMapEntity.getMetaBuilding().getIsReplaceable(),
|
||||||
|
3
src/js/globals.d.ts
vendored
3
src/js/globals.d.ts
vendored
@ -193,6 +193,9 @@ declare interface TypedSignal<T extends Array<any>> {
|
|||||||
removeAll();
|
removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare type Layer = "regular" | "wires";
|
||||||
|
declare type ItemType = "shape" | "color" | "boolean";
|
||||||
|
|
||||||
declare module "worker-loader?inline=true&fallback=false!*" {
|
declare module "worker-loader?inline=true&fallback=false!*" {
|
||||||
class WebpackWorker extends Worker {
|
class WebpackWorker extends Worker {
|
||||||
constructor();
|
constructor();
|
||||||
|
@ -456,7 +456,7 @@ export class TypeEnum extends BaseDataType {
|
|||||||
*/
|
*/
|
||||||
constructor(enumeration = {}) {
|
constructor(enumeration = {}) {
|
||||||
super();
|
super();
|
||||||
this.availableValues = Object.keys(enumeration);
|
this.availableValues = Object.values(enumeration);
|
||||||
}
|
}
|
||||||
|
|
||||||
serialize(value) {
|
serialize(value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user