Improve visibility of color items

This commit is contained in:
tobspr 2020-08-29 21:45:32 +02:00
parent cf0f02826b
commit 12892dcf54
2 changed files with 67 additions and 57 deletions

View File

@ -1,52 +1,56 @@
import { enumDirection, Vector } from "../../core/vector"; 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 { 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 {
constructor() { constructor() {
super("constant_signal"); super("constant_signal");
} }
getSilhouetteColor() { getSilhouetteColor() {
return "#2bafda"; return "#2bafda";
} }
/** /**
* @param {GameRoot} root * @param {GameRoot} root
*/ */
getIsUnlocked(root) { getIsUnlocked(root) {
// @todo // @todo
return true; return true;
} }
/** @returns {"wires"} **/ /** @returns {"wires"} **/
getLayer() { getLayer() {
return "wires"; return "wires";
} }
getDimensions() { getDimensions() {
return new Vector(1, 1); return new Vector(1, 1);
} }
/** getRenderPins() {
* Creates the entity at the given location return false;
* @param {Entity} entity }
*/
setupEntityComponents(entity) { /**
entity.addComponent( * Creates the entity at the given location
new WiredPinsComponent({ * @param {Entity} entity
slots: [ */
{ setupEntityComponents(entity) {
pos: new Vector(0, 0), entity.addComponent(
direction: enumDirection.top, new WiredPinsComponent({
type: enumPinSlotType.logicalEjector, slots: [
}, {
], pos: new Vector(0, 0),
}) direction: enumDirection.top,
); type: enumPinSlotType.logicalEjector,
entity.addComponent(new ConstantSignalComponent({})); },
} ],
} })
);
entity.addComponent(new ConstantSignalComponent({}));
}
}

View File

@ -9,6 +9,13 @@ 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";
/** @type {Object<ItemType, number>} */
const enumTypeToSize = {
boolean: 9,
shape: 9,
color: 14,
};
export class WiredPinsSystem extends GameSystemWithFilter { export class WiredPinsSystem extends GameSystemWithFilter {
constructor(root) { constructor(root) {
super(root, [WiredPinsComponent]); super(root, [WiredPinsComponent]);
@ -142,9 +149,7 @@ export class WiredPinsSystem extends GameSystemWithFilter {
} }
} }
update() { update() {}
// TODO
}
/** /**
* Draws a given entity * Draws a given entity
@ -201,12 +206,13 @@ export class WiredPinsSystem extends GameSystemWithFilter {
// Draw contained item to visualize whats emitted // Draw contained item to visualize whats emitted
const value = slot.value; const value = slot.value;
if (value) { if (value) {
const offset = new Vector(0, -9).rotated(effectiveRotation); const offset = new Vector(0, -9.1).rotated(effectiveRotation);
value.drawItemCenteredClipped( value.drawItemCenteredClipped(
worldPos.x + offset.x, worldPos.x + offset.x,
worldPos.y + offset.y, worldPos.y + offset.y,
parameters, parameters,
9 enumTypeToSize[value.getItemType()]
); );
} }