1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-28 02:39:20 +00:00

Shortened and simplified shape tooltip code

This commit is contained in:
Sense101 2021-07-01 14:01:21 +01:00
parent d0a580a685
commit 6ba12f094f

View File

@ -15,7 +15,6 @@ export class HUDShapeTooltip extends BaseHUDPart {
this.currentEntity = null;
this.isPlacingBuilding = false;
this.active = false;
this.root.signals.entityQueuedForDestroy.add(() => {
this.currentEntity = null;
@ -26,24 +25,28 @@ export class HUDShapeTooltip extends BaseHUDPart {
}, this);
}
update() {
// don't show the tooltip when any other placer is active
isActive() {
const hudParts = this.root.hud.parts;
this.active =
// return false if any other placer is active
return (
this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.showShapeTooltip).pressed &&
!this.isPlacingBuilding &&
!hudParts.massSelector.currentSelectionStartWorld &&
hudParts.massSelector.selectedUids.size < 1 &&
!hudParts.blueprintPlacer.currentBlueprint.get();
const mousePos = this.root.app.mousePosition;
if (!mousePos) {
// Not on screen
return;
!hudParts.blueprintPlacer.currentBlueprint.get()
);
}
/**
*
* @param {DrawParameters} parameters
*/
draw(parameters) {
if (this.isActive()) {
const mousePos = this.root.app.mousePosition;
if (mousePos) {
const tile = this.root.camera.screenToWorld(mousePos.copy()).toTileSpace();
if (!tile.equals(this.currentTile)) {
this.currentTile = tile;
@ -58,12 +61,10 @@ export class HUDShapeTooltip extends BaseHUDPart {
}
}
/**
*
* @param {DrawParameters} parameters
*/
draw(parameters) {
if (this.active && this.currentEntity) {
if (!this.currentEntity) {
return;
}
const ejectorComp = this.currentEntity.components.ItemEjector;
const staticComp = this.currentEntity.components.StaticMapEntity;