@@ 163,36 163,35 @@ export function evaluateNewPieces (newKey, gameData, gs) {
let newPieces = [];
const emit = (data, box, output = null) => {
output = output || box.outputs[0];
- const connection = gameData.connections.find(c => c.startBox === box && output === c.startOutput);
- if (!connection) {
- return []
- }
- const outputOffset = Math.floor(((box.outputs.indexOf(output) + 1) / (box.outputs.length + 1)) * box.width);
- const g = new PIXI.Graphics();
- const pos = box.pos.add(new Vec(outputOffset, box.height));
- const size = 1;
- g.beginFill(hsv(.8, .1, .2));
- g.drawRect(0, 0, size * TILE_SIZE, size * TILE_SIZE);
- const fullPos = pos.mul(TILE_SIZE)
- g.x = fullPos.x;
- g.y = fullPos.y;
- const pieceText = new PIXI.BitmapText('', {
- fontName: 'MatchupPro',
- tint: hsv(.8, .1, .95),
- fontSize: FONT_SIZE
- })
- pieceText.y = -3;
- pieceText.x = 1;
- pieceText.text = data;
- g.addChild(pieceText)
+ const connections = gameData.connections.filter(c => c.startBox === box && output === c.startOutput);
+ return connections.map(connection => {
+ const outputOffset = Math.floor(((box.outputs.indexOf(output) + 1) / (box.outputs.length + 1)) * box.width);
+ const g = new PIXI.Graphics();
+ const pos = box.pos.add(new Vec(outputOffset, box.height));
+ const size = 1;
+ g.beginFill(hsv(.8, .1, .2));
+ g.drawRect(0, 0, size * TILE_SIZE, size * TILE_SIZE);
+ const fullPos = pos.mul(TILE_SIZE)
+ g.x = fullPos.x;
+ g.y = fullPos.y;
+ const pieceText = new PIXI.BitmapText('', {
+ fontName: 'MatchupPro',
+ tint: hsv(.8, .1, .95),
+ fontSize: FONT_SIZE
+ })
+ pieceText.y = -3;
+ pieceText.x = 1;
+ pieceText.text = data;
+ g.addChild(pieceText)
- gs.dataPieces.addChild(g);
- return [{
- connection,
- pos: pos,
- data: data,
- g: g
- }];
+ gs.dataPieces.addChild(g);
+ return {
+ connection,
+ pos: pos,
+ data: data,
+ g: g
+ };
+ })
};
if (newKey) {
const keyBoxes = codeBoxes.filter(box => box.type === 'keyboard');
@@ 386,12 386,12 @@ function mouseup (e) {
);
// Clear existing connections
- gameData.connections.filter(connection => {
- return connection.startBox === gameData.drawingConnection.startBox
- && connection.startOutput === gameData.drawingConnection.startOutput
- || connection.endBox === gameData.drawingConnection.endBox
- && connection.endInput === gameData.drawingConnection.endInput
- }).forEach(c => removeConnection(c, gameData, gs));
+ // gameData.connections.filter(connection => {
+ // return connection.startBox === gameData.drawingConnection.startBox
+ // && connection.startOutput === gameData.drawingConnection.startOutput
+ // || connection.endBox === gameData.drawingConnection.endBox
+ // && connection.endInput === gameData.drawingConnection.endInput
+ // }).forEach(c => removeConnection(c, gameData, gs));
if (inputFound) {
addConnection({