Change position format for blueprint
This commit is contained in:
parent
e969ba848b
commit
fec7dd70db
6 changed files with 115 additions and 79 deletions
|
|
@ -56,8 +56,8 @@ impl ElectricPoleType {
|
|||
|
||||
fn size(&self) -> Position {
|
||||
match self {
|
||||
ElectricPoleType::Small | ElectricPoleType::Medium => Position::new(1, 1),
|
||||
ElectricPoleType::Big | ElectricPoleType::Substation => Position::new(2, 2),
|
||||
ElectricPoleType::Small | ElectricPoleType::Medium => Position::new(2, 2),
|
||||
ElectricPoleType::Big | ElectricPoleType::Substation => Position::new(4, 4),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -213,14 +213,14 @@ impl Entity {
|
|||
|
||||
pub fn size(&self) -> Position {
|
||||
match &self.entity {
|
||||
EntityType::Splitter(_) => Position::new(2, 1),
|
||||
EntityType::Splitter(_) => Position::new(4, 2),
|
||||
EntityType::Unknown {
|
||||
name: _,
|
||||
size,
|
||||
misc: _,
|
||||
} => *size,
|
||||
EntityType::ElectricPole(electric_pole_type) => electric_pole_type.size(),
|
||||
_ => Position::new(1, 1),
|
||||
_ => Position::new(2, 2),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,19 +268,23 @@ impl Blueprint {
|
|||
for &p in path {
|
||||
match p {
|
||||
PathField::Belt { pos, dir } => {
|
||||
self.add_entity(Entity::new_belt(beltspeed, pos, dir));
|
||||
self.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
2 * pos + Position::new(1, 1),
|
||||
dir,
|
||||
));
|
||||
}
|
||||
PathField::Underground { pos, dir, len } => {
|
||||
self.add_entity(Entity::new_underground_belt(
|
||||
beltspeed,
|
||||
UndergroundType::Input,
|
||||
pos,
|
||||
2 * pos + Position::new(1, 1),
|
||||
dir,
|
||||
));
|
||||
self.add_entity(Entity::new_underground_belt(
|
||||
beltspeed,
|
||||
UndergroundType::Output,
|
||||
pos.in_direction(&dir, len as PositionType),
|
||||
2 * pos.in_direction(&dir, len as PositionType) + Position::new(1, 1),
|
||||
dir,
|
||||
));
|
||||
}
|
||||
|
|
@ -304,15 +308,10 @@ impl Blueprint {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, (_, e))| {
|
||||
let size = (e.size() - Position::new(1, 1))
|
||||
.transform(Transformation::new(e.direction, Position::new(0, 0)));
|
||||
BlueprintEntity::builder(
|
||||
e.get_name(),
|
||||
i as u32 + 1,
|
||||
BlueprintPosition::new(
|
||||
e.position.x as f64 + 0.5 * size.x as f64 + 0.5,
|
||||
e.position.y as f64 + 0.5 * size.y as f64 + 0.5,
|
||||
),
|
||||
BlueprintPosition::new(0.5 * e.position.x as f64, 0.5 * e.position.y as f64),
|
||||
)
|
||||
.direction(match e.direction {
|
||||
Direction::Up => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue