Implement saving of logic gates and directional blocks
This commit is contained in:
parent
2849260672
commit
35f040c8d7
@ -4,6 +4,7 @@ export const DIRECTIONS = {
|
|||||||
north: {
|
north: {
|
||||||
movement: [0, -1],
|
movement: [0, -1],
|
||||||
bit: 0x01,
|
bit: 0x01,
|
||||||
|
index: 0,
|
||||||
action: 'up',
|
action: 'up',
|
||||||
left: 'west',
|
left: 'west',
|
||||||
right: 'east',
|
right: 'east',
|
||||||
@ -12,6 +13,7 @@ export const DIRECTIONS = {
|
|||||||
south: {
|
south: {
|
||||||
movement: [0, 1],
|
movement: [0, 1],
|
||||||
bit: 0x04,
|
bit: 0x04,
|
||||||
|
index: 2,
|
||||||
action: 'down',
|
action: 'down',
|
||||||
left: 'east',
|
left: 'east',
|
||||||
right: 'west',
|
right: 'west',
|
||||||
@ -20,6 +22,7 @@ export const DIRECTIONS = {
|
|||||||
west: {
|
west: {
|
||||||
movement: [-1, 0],
|
movement: [-1, 0],
|
||||||
bit: 0x08,
|
bit: 0x08,
|
||||||
|
index: 3,
|
||||||
action: 'left',
|
action: 'left',
|
||||||
left: 'south',
|
left: 'south',
|
||||||
right: 'north',
|
right: 'north',
|
||||||
@ -28,6 +31,7 @@ export const DIRECTIONS = {
|
|||||||
east: {
|
east: {
|
||||||
movement: [1, 0],
|
movement: [1, 0],
|
||||||
bit: 0x02,
|
bit: 0x02,
|
||||||
|
index: 1,
|
||||||
action: 'right',
|
action: 'right',
|
||||||
left: 'north',
|
left: 'north',
|
||||||
right: 'south',
|
right: 'south',
|
||||||
|
|||||||
@ -462,7 +462,34 @@ const TILE_ENCODING = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
encode(tile) {
|
encode(tile) {
|
||||||
// FIXME implement
|
let direction_offset = DIRECTIONS[tile.direction].index;
|
||||||
|
if (tile.gate_type === 'not') {
|
||||||
|
return 0 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'and') {
|
||||||
|
return 4 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'or') {
|
||||||
|
return 8 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'xor') {
|
||||||
|
return 12 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'latch-cw') {
|
||||||
|
return 16 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'nand') {
|
||||||
|
return 20 + direction_offset;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'counter') {
|
||||||
|
return 30 + tile.memory;
|
||||||
|
}
|
||||||
|
else if (tile.gate_type === 'latch-ccw') {
|
||||||
|
return 64 + direction_offset;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0xff;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -612,8 +639,11 @@ const TILE_ENCODING = {
|
|||||||
tile.arrows = arrows;
|
tile.arrows = arrows;
|
||||||
},
|
},
|
||||||
encode(tile) {
|
encode(tile) {
|
||||||
// TODO
|
let bits = 0;
|
||||||
return 0;
|
for (let direction of tile.arrows) {
|
||||||
|
bits |= DIRECTIONS[direction].bit;
|
||||||
|
}
|
||||||
|
return bits;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1007,6 +1007,7 @@ const EDITOR_PALETTE = [{
|
|||||||
// - wires, wire tunnels probably a dedicated tool, placing tunnels like a tile makes no sense
|
// - wires, wire tunnels probably a dedicated tool, placing tunnels like a tile makes no sense
|
||||||
// - canopy normal tile; layering problem
|
// - canopy normal tile; layering problem
|
||||||
// - thin walls special rotate logic, like force floors; layering problem
|
// - thin walls special rotate logic, like force floors; layering problem
|
||||||
|
// - light switches
|
||||||
// TODO should tiles that respond to wiring and/or gray buttons be highlighted, highlightable?
|
// TODO should tiles that respond to wiring and/or gray buttons be highlighted, highlightable?
|
||||||
}, {
|
}, {
|
||||||
title: "Logic",
|
title: "Logic",
|
||||||
@ -1045,7 +1046,7 @@ const SPECIAL_PALETTE_ENTRIES = {
|
|||||||
'logic_gate/nand': { name: 'logic_gate', direction: 'north', gate_type: 'nand' },
|
'logic_gate/nand': { name: 'logic_gate', direction: 'north', gate_type: 'nand' },
|
||||||
'logic_gate/latch-cw': { name: 'logic_gate', direction: 'north', gate_type: 'latch-cw' },
|
'logic_gate/latch-cw': { name: 'logic_gate', direction: 'north', gate_type: 'latch-cw' },
|
||||||
'logic_gate/latch-ccw': { name: 'logic_gate', direction: 'north', gate_type: 'latch-ccw' },
|
'logic_gate/latch-ccw': { name: 'logic_gate', direction: 'north', gate_type: 'latch-ccw' },
|
||||||
'logic_gate/counter': { name: 'logic_gate', direction: 'north', gate_type: 'counter' },
|
'logic_gate/counter': { name: 'logic_gate', direction: 'north', gate_type: 'counter', memory: 0 },
|
||||||
};
|
};
|
||||||
const _RAILROAD_ROTATED_LEFT = [3, 0, 1, 2, 5, 4];
|
const _RAILROAD_ROTATED_LEFT = [3, 0, 1, 2, 5, 4];
|
||||||
const _RAILROAD_ROTATED_RIGHT = [1, 2, 3, 0, 5, 4];
|
const _RAILROAD_ROTATED_RIGHT = [1, 2, 3, 0, 5, 4];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user