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

View File

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