mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 19:51:50 +00:00
remove belt underlays component
This commit is contained in:
parent
654643c5b0
commit
10db2af21c
@ -8,7 +8,6 @@ import { GameRoot } from "../root";
|
|||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { T } from "../../translations";
|
import { T } from "../../translations";
|
||||||
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
|
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
|
||||||
import { BeltUnderlaysComponent } from "../components/belt_underlays";
|
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
export const enumBalancerVariants = {
|
export const enumBalancerVariants = {
|
||||||
@ -138,8 +137,6 @@ export class MetaBalancerBuilding extends MetaBuilding {
|
|||||||
renderFloatingItems: false,
|
renderFloatingItems: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
entity.addComponent(new BeltUnderlaysComponent({ underlays: [] }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,11 +164,6 @@ export class MetaBalancerBuilding extends MetaBuilding {
|
|||||||
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
entity.components.BeltUnderlays.underlays = [
|
|
||||||
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
||||||
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
|
||||||
];
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case enumBalancerVariants.merger:
|
case enumBalancerVariants.merger:
|
||||||
@ -195,10 +187,6 @@ export class MetaBalancerBuilding extends MetaBuilding {
|
|||||||
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
entity.components.BeltUnderlays.underlays = [
|
|
||||||
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
||||||
];
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case enumBalancerVariants.splitter:
|
case enumBalancerVariants.splitter:
|
||||||
@ -224,10 +212,6 @@ export class MetaBalancerBuilding extends MetaBuilding {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
entity.components.BeltUnderlays.underlays = [
|
|
||||||
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
||||||
];
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -6,7 +6,6 @@ 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 { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
import { BeltUnderlaysComponent } from "../components/belt_underlays";
|
|
||||||
import { BeltReaderComponent } from "../components/belt_reader";
|
import { BeltReaderComponent } from "../components/belt_reader";
|
||||||
import { enumHubGoalRewards } from "../tutorial_goals";
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
||||||
import { generateMatrixRotations } from "../../core/utils";
|
import { generateMatrixRotations } from "../../core/utils";
|
||||||
@ -99,17 +98,6 @@ export class MetaReaderBuilding extends MetaBuilding {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
entity.addComponent(
|
|
||||||
new BeltUnderlaysComponent({
|
|
||||||
underlays: [
|
|
||||||
{
|
|
||||||
pos: new Vector(0, 0),
|
|
||||||
direction: enumDirection.top,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
entity.addComponent(new BeltReaderComponent());
|
entity.addComponent(new BeltReaderComponent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import { UndergroundBeltComponent } from "./components/underground_belt";
|
|||||||
import { HubComponent } from "./components/hub";
|
import { HubComponent } from "./components/hub";
|
||||||
import { StorageComponent } from "./components/storage";
|
import { StorageComponent } from "./components/storage";
|
||||||
import { WiredPinsComponent } from "./components/wired_pins";
|
import { WiredPinsComponent } from "./components/wired_pins";
|
||||||
import { BeltUnderlaysComponent } from "./components/belt_underlays";
|
|
||||||
import { WireComponent } from "./components/wire";
|
import { WireComponent } from "./components/wire";
|
||||||
import { ConstantSignalComponent } from "./components/constant_signal";
|
import { ConstantSignalComponent } from "./components/constant_signal";
|
||||||
import { LogicGateComponent } from "./components/logic_gate";
|
import { LogicGateComponent } from "./components/logic_gate";
|
||||||
@ -32,7 +31,6 @@ export function initComponentRegistry() {
|
|||||||
gComponentRegistry.register(HubComponent);
|
gComponentRegistry.register(HubComponent);
|
||||||
gComponentRegistry.register(StorageComponent);
|
gComponentRegistry.register(StorageComponent);
|
||||||
gComponentRegistry.register(WiredPinsComponent);
|
gComponentRegistry.register(WiredPinsComponent);
|
||||||
gComponentRegistry.register(BeltUnderlaysComponent);
|
|
||||||
gComponentRegistry.register(WireComponent);
|
gComponentRegistry.register(WireComponent);
|
||||||
gComponentRegistry.register(ConstantSignalComponent);
|
gComponentRegistry.register(ConstantSignalComponent);
|
||||||
gComponentRegistry.register(LogicGateComponent);
|
gComponentRegistry.register(LogicGateComponent);
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
import { enumDirection, Vector } from "../../core/vector";
|
|
||||||
import { Component } from "../component";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store which type an underlay is, this is cached so we can easily
|
|
||||||
* render it.
|
|
||||||
*
|
|
||||||
* Full: Render underlay at top and bottom of tile
|
|
||||||
* Bottom Only: Only render underlay at the bottom half
|
|
||||||
* Top Only:
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export const enumClippedBeltUnderlayType = {
|
|
||||||
full: "full",
|
|
||||||
bottomOnly: "bottomOnly",
|
|
||||||
topOnly: "topOnly",
|
|
||||||
none: "none",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {{
|
|
||||||
* pos: Vector,
|
|
||||||
* direction: enumDirection,
|
|
||||||
* cachedType?: enumClippedBeltUnderlayType
|
|
||||||
* }} BeltUnderlayTile
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class BeltUnderlaysComponent extends Component {
|
|
||||||
static getId() {
|
|
||||||
return "BeltUnderlays";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {object} param0
|
|
||||||
* @param {Array<BeltUnderlayTile>=} param0.underlays Where to render belt underlays
|
|
||||||
*/
|
|
||||||
constructor({ underlays = [] }) {
|
|
||||||
super();
|
|
||||||
this.underlays = underlays;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
/* typehints:start */
|
/* typehints:start */
|
||||||
import { BeltComponent } from "./components/belt";
|
import { BeltComponent } from "./components/belt";
|
||||||
import { BeltUnderlaysComponent } from "./components/belt_underlays";
|
|
||||||
import { HubComponent } from "./components/hub";
|
import { HubComponent } from "./components/hub";
|
||||||
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "./components/item_ejector";
|
import { ItemEjectorComponent } from "./components/item_ejector";
|
||||||
@ -60,9 +59,6 @@ export class EntityComponentStorage {
|
|||||||
/** @type {WiredPinsComponent} */
|
/** @type {WiredPinsComponent} */
|
||||||
this.WiredPins;
|
this.WiredPins;
|
||||||
|
|
||||||
/** @type {BeltUnderlaysComponent} */
|
|
||||||
this.BeltUnderlays;
|
|
||||||
|
|
||||||
/** @type {WireComponent} */
|
/** @type {WireComponent} */
|
||||||
this.Wire;
|
this.Wire;
|
||||||
|
|
||||||
|
|||||||
@ -2,25 +2,12 @@ import { globalConfig } from "../../core/config";
|
|||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { Rectangle } from "../../core/rectangle";
|
import { Rectangle } from "../../core/rectangle";
|
||||||
import { FULL_CLIP_RECT } from "../../core/sprites";
|
|
||||||
import { enumDirectionToAngle, enumInvertedDirections } from "../../core/vector";
|
import { enumDirectionToAngle, enumInvertedDirections } from "../../core/vector";
|
||||||
import { enumClippedBeltUnderlayType } from "../components/belt_underlays";
|
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
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 { BELT_ANIM_COUNT } from "./belt";
|
import { BELT_ANIM_COUNT } from "./belt";
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from underlay type to clip rect
|
|
||||||
* @type {Object<enumClippedBeltUnderlayType, Rectangle>}
|
|
||||||
*/
|
|
||||||
const enumUnderlayTypeToClipRect = {
|
|
||||||
[enumClippedBeltUnderlayType.none]: null,
|
|
||||||
[enumClippedBeltUnderlayType.full]: FULL_CLIP_RECT,
|
|
||||||
[enumClippedBeltUnderlayType.topOnly]: new Rectangle(0, 0, 1, 0.5),
|
|
||||||
[enumClippedBeltUnderlayType.bottomOnly]: new Rectangle(0, 0.5, 1, 0.5),
|
|
||||||
};
|
|
||||||
|
|
||||||
export class AcceptorBeltSystem extends GameSystemWithFilter {
|
export class AcceptorBeltSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [ItemAcceptorComponent]);
|
super(root, [ItemAcceptorComponent]);
|
||||||
@ -86,12 +73,7 @@ export class AcceptorBeltSystem extends GameSystemWithFilter {
|
|||||||
const worldDirection = staticComp.localDirectionToWorld(direction);
|
const worldDirection = staticComp.localDirectionToWorld(direction);
|
||||||
const angle = enumDirectionToAngle[enumInvertedDirections[worldDirection]];
|
const angle = enumDirectionToAngle[enumInvertedDirections[worldDirection]];
|
||||||
|
|
||||||
const underlayType = enumClippedBeltUnderlayType.bottomOnly;
|
const clipRect = new Rectangle(0, 0.5, 1, 0.5);
|
||||||
const clipRect = enumUnderlayTypeToClipRect[underlayType];
|
|
||||||
if (!clipRect) {
|
|
||||||
// Empty
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually draw the sprite
|
// Actually draw the sprite
|
||||||
const x = destX + globalConfig.halfTileSize;
|
const x = destX + globalConfig.halfTileSize;
|
||||||
|
|||||||
@ -2,25 +2,12 @@ import { globalConfig } from "../../core/config";
|
|||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { Rectangle } from "../../core/rectangle";
|
import { Rectangle } from "../../core/rectangle";
|
||||||
import { FULL_CLIP_RECT } from "../../core/sprites";
|
|
||||||
import { enumDirectionToAngle } from "../../core/vector";
|
import { enumDirectionToAngle } from "../../core/vector";
|
||||||
import { enumClippedBeltUnderlayType } from "../components/belt_underlays";
|
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
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 { BELT_ANIM_COUNT } from "./belt";
|
import { BELT_ANIM_COUNT } from "./belt";
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping from underlay type to clip rect
|
|
||||||
* @type {Object<enumClippedBeltUnderlayType, Rectangle>}
|
|
||||||
*/
|
|
||||||
const enumUnderlayTypeToClipRect = {
|
|
||||||
[enumClippedBeltUnderlayType.none]: null,
|
|
||||||
[enumClippedBeltUnderlayType.full]: FULL_CLIP_RECT,
|
|
||||||
[enumClippedBeltUnderlayType.topOnly]: new Rectangle(0, 0, 1, 0.5),
|
|
||||||
[enumClippedBeltUnderlayType.bottomOnly]: new Rectangle(0, 0.5, 1, 0.5),
|
|
||||||
};
|
|
||||||
|
|
||||||
export class EjectorBeltSystem extends GameSystemWithFilter {
|
export class EjectorBeltSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [ItemEjectorComponent]);
|
super(root, [ItemEjectorComponent]);
|
||||||
@ -83,12 +70,7 @@ export class EjectorBeltSystem extends GameSystemWithFilter {
|
|||||||
const worldDirection = staticComp.localDirectionToWorld(direction);
|
const worldDirection = staticComp.localDirectionToWorld(direction);
|
||||||
const angle = enumDirectionToAngle[worldDirection];
|
const angle = enumDirectionToAngle[worldDirection];
|
||||||
|
|
||||||
const underlayType = enumClippedBeltUnderlayType.topOnly;
|
const clipRect = new Rectangle(0, 0, 1, 0.5);
|
||||||
const clipRect = enumUnderlayTypeToClipRect[underlayType];
|
|
||||||
if (!clipRect) {
|
|
||||||
// Empty
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually draw the sprite
|
// Actually draw the sprite
|
||||||
const x = destX + globalConfig.halfTileSize;
|
const x = destX + globalConfig.halfTileSize;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user