rename gate to comparator
This commit is contained in:
parent
e98ad65ec3
commit
9792410f02
4 changed files with 49 additions and 48 deletions
|
@ -31,7 +31,7 @@ pub enum OpenTile {
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum PTile {
|
||||
Gate(GateType),
|
||||
Comparator(Comparison),
|
||||
Math(MathOp),
|
||||
Silo,
|
||||
Flipper,
|
||||
|
@ -54,7 +54,7 @@ pub enum MathOp {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum GateType {
|
||||
pub enum Comparison {
|
||||
LessThan,
|
||||
GreaterThan,
|
||||
Equal,
|
||||
|
@ -94,10 +94,10 @@ impl Tile {
|
|||
'v' => Tile::Arrow(Direction::Down),
|
||||
'<' => Tile::Arrow(Direction::Left),
|
||||
'>' => Tile::Arrow(Direction::Right),
|
||||
'=' => Tile::Powerable(PTile::Gate(GateType::Equal), false),
|
||||
'!' => Tile::Powerable(PTile::Gate(GateType::NotEqual), false),
|
||||
'L' => Tile::Powerable(PTile::Gate(GateType::LessThan), false),
|
||||
'G' => Tile::Powerable(PTile::Gate(GateType::GreaterThan), false),
|
||||
'=' => Tile::Powerable(PTile::Comparator(Comparison::Equal), false),
|
||||
'!' => Tile::Powerable(PTile::Comparator(Comparison::NotEqual), false),
|
||||
'L' => Tile::Powerable(PTile::Comparator(Comparison::LessThan), false),
|
||||
'G' => Tile::Powerable(PTile::Comparator(Comparison::GreaterThan), false),
|
||||
'I' | 'P' => Tile::Powerable(PTile::IO, false),
|
||||
'F' => Tile::Powerable(PTile::Flipper, false),
|
||||
'A' => Tile::Powerable(PTile::Math(MathOp::Add), false),
|
||||
|
@ -135,11 +135,11 @@ impl Tile {
|
|||
WireType::Cross => '+',
|
||||
},
|
||||
Tile::Powerable(tile, _) => match tile {
|
||||
PTile::Gate(gate) => match gate {
|
||||
GateType::LessThan => 'L',
|
||||
GateType::GreaterThan => 'G',
|
||||
GateType::Equal => '=',
|
||||
GateType::NotEqual => '!',
|
||||
PTile::Comparator(comp) => match comp {
|
||||
Comparison::LessThan => 'L',
|
||||
Comparison::GreaterThan => 'G',
|
||||
Comparison::Equal => '=',
|
||||
Comparison::NotEqual => '!',
|
||||
},
|
||||
PTile::Math(math) => match math {
|
||||
MathOp::Add => 'A',
|
||||
|
@ -191,7 +191,7 @@ impl Tile {
|
|||
}
|
||||
Tile::Powerable(tile, state) => {
|
||||
let root = match tile {
|
||||
PTile::Gate(gate) => gate.texture_name(),
|
||||
PTile::Comparator(comp) => comp.texture_name(),
|
||||
PTile::Math(math_op) => math_op.texture_name(),
|
||||
PTile::Silo => "silo",
|
||||
PTile::Flipper => "flipper",
|
||||
|
@ -370,31 +370,31 @@ impl MathOp {
|
|||
}
|
||||
}
|
||||
|
||||
impl GateType {
|
||||
impl Comparison {
|
||||
pub const fn texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
GateType::LessThan => "lt",
|
||||
GateType::GreaterThan => "gt",
|
||||
GateType::Equal => "eq",
|
||||
GateType::NotEqual => "neq",
|
||||
Comparison::LessThan => "lt",
|
||||
Comparison::GreaterThan => "gt",
|
||||
Comparison::Equal => "eq",
|
||||
Comparison::NotEqual => "neq",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next(&mut self) {
|
||||
*self = match self {
|
||||
GateType::LessThan => GateType::GreaterThan,
|
||||
GateType::GreaterThan => GateType::Equal,
|
||||
GateType::Equal => GateType::NotEqual,
|
||||
GateType::NotEqual => GateType::LessThan,
|
||||
Comparison::LessThan => Comparison::GreaterThan,
|
||||
Comparison::GreaterThan => Comparison::Equal,
|
||||
Comparison::Equal => Comparison::NotEqual,
|
||||
Comparison::NotEqual => Comparison::LessThan,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prev(&mut self) {
|
||||
*self = match self {
|
||||
GateType::LessThan => GateType::NotEqual,
|
||||
GateType::GreaterThan => GateType::LessThan,
|
||||
GateType::Equal => GateType::GreaterThan,
|
||||
GateType::NotEqual => GateType::Equal,
|
||||
Comparison::LessThan => Comparison::NotEqual,
|
||||
Comparison::GreaterThan => Comparison::LessThan,
|
||||
Comparison::Equal => Comparison::GreaterThan,
|
||||
Comparison::NotEqual => Comparison::Equal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue