Change position format for blueprint
This commit is contained in:
parent
e969ba848b
commit
fec7dd70db
6 changed files with 115 additions and 79 deletions
|
|
@ -79,7 +79,7 @@ fn balancer_path() -> Vec<PathField> {
|
|||
pub fn generate_4_lane_balancer2() -> Blueprint {
|
||||
let mut b = abstraction::Blueprint::new();
|
||||
|
||||
let splitter_pos = [(0, 0), (2, 0), (1, 1), (1, 4), (0, 7), (2, 7)];
|
||||
let splitter_pos = [(2, 1), (6, 1), (4, 3), (4, 9), (2, 15), (6, 15)];
|
||||
|
||||
for (x, y) in splitter_pos {
|
||||
b.add_entity(Entity::new_splitter(
|
||||
|
|
@ -91,7 +91,7 @@ pub fn generate_4_lane_balancer2() -> Blueprint {
|
|||
|
||||
b.add_path(&balancer_path(), Beltspeed::Normal);
|
||||
|
||||
b.transform(Transformation::new(Direction::Right, Position::new(0, 0)));
|
||||
// b.transform(Transformation::new(Direction::Right, Position::new(0, 0)));
|
||||
b.to_blueprint()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ use factorio_core::beltoptions::{Beltspeed, Belttype};
|
|||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[arg(short, long)]
|
||||
json: bool,
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
|
@ -13,12 +15,13 @@ struct Args {
|
|||
enum Command {
|
||||
Book,
|
||||
Single {
|
||||
#[arg(long)]
|
||||
load: bool,
|
||||
locomotives: usize,
|
||||
length: usize,
|
||||
outputs: usize,
|
||||
beltspeed: Beltspeed,
|
||||
#[arg(default_value = "full")]
|
||||
#[arg(short, long, default_value = "full")]
|
||||
belttype: Belttype,
|
||||
},
|
||||
}
|
||||
|
|
@ -109,6 +112,9 @@ fn main() {
|
|||
.build(),
|
||||
);
|
||||
|
||||
if args.json {
|
||||
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||
}
|
||||
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||
}
|
||||
Command::Single {
|
||||
|
|
@ -124,7 +130,9 @@ fn main() {
|
|||
.to_blueprint(),
|
||||
);
|
||||
|
||||
// println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||
if args.json {
|
||||
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||
}
|
||||
|
||||
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@ pub fn merger(
|
|||
for j in 0..depth {
|
||||
b.add_entity(Entity::new_belt(
|
||||
stubspeed,
|
||||
Position::new(
|
||||
(intervall * (i + o * section_size)) as PositionType,
|
||||
-(j as PositionType),
|
||||
),
|
||||
Position::new(1, 1)
|
||||
+ 2 * Position::new(
|
||||
(intervall * (i + o * section_size)) as PositionType,
|
||||
-(j as PositionType),
|
||||
),
|
||||
match reverse {
|
||||
true => Direction::Down,
|
||||
false => Direction::Up,
|
||||
|
|
@ -38,10 +39,11 @@ pub fn merger(
|
|||
|
||||
b.add_entity(Entity::new_belt(
|
||||
stubspeed,
|
||||
Position::new(
|
||||
(intervall * (i + o * section_size)) as PositionType,
|
||||
-(depth as PositionType),
|
||||
),
|
||||
Position::new(1, 1)
|
||||
+ 2 * Position::new(
|
||||
(intervall * (i + o * section_size)) as PositionType,
|
||||
-(depth as PositionType),
|
||||
),
|
||||
match reverse {
|
||||
true => Direction::Down,
|
||||
false => Direction::Left,
|
||||
|
|
@ -59,9 +61,10 @@ pub fn merger(
|
|||
b.add_entity(Entity::new_splitter(
|
||||
mergespeed,
|
||||
Position::new(
|
||||
(intervall * (j * p + o * section_size)) as PositionType
|
||||
- i as PositionType,
|
||||
0 - i as PositionType - depth as PositionType + !reverse as PositionType,
|
||||
2 * ((intervall * (j * p + o * section_size)) as PositionType
|
||||
- i as PositionType)
|
||||
+ 1,
|
||||
2 * (1 - i as PositionType - depth as PositionType),
|
||||
),
|
||||
match reverse {
|
||||
true => Direction::Right,
|
||||
|
|
@ -72,11 +75,12 @@ pub fn merger(
|
|||
for l in 0..(7 * p / 2) {
|
||||
b.add_entity(Entity::new_belt(
|
||||
mergespeed.halve(),
|
||||
Position::new(
|
||||
(intervall * (j * p + o * section_size) + l + 1) as PositionType
|
||||
- i as PositionType,
|
||||
0 - i as PositionType - depth as PositionType,
|
||||
),
|
||||
Position::new(1, 1)
|
||||
+ 2 * Position::new(
|
||||
(intervall * (j * p + o * section_size) + l + 1) as PositionType
|
||||
- i as PositionType,
|
||||
0 - i as PositionType - depth as PositionType,
|
||||
),
|
||||
match reverse {
|
||||
true => Direction::Right,
|
||||
false => Direction::Left,
|
||||
|
|
@ -91,10 +95,11 @@ pub fn merger(
|
|||
for l in 0..(7 * o * section_size) {
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(
|
||||
l as PositionType - section_size.ilog2() as PositionType,
|
||||
-(step as PositionType),
|
||||
),
|
||||
Position::new(1, 1)
|
||||
+ 2 * Position::new(
|
||||
l as PositionType - section_size.ilog2() as PositionType,
|
||||
-(step as PositionType),
|
||||
),
|
||||
match reverse {
|
||||
true => Direction::Right,
|
||||
false => Direction::Left,
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
if beltspeed == Beltspeed::Normal {
|
||||
b.add_entity(Entity::new_belt(
|
||||
Beltspeed::Fast,
|
||||
Position::new(3, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(3, -2),
|
||||
Direction::Up,
|
||||
));
|
||||
|
||||
if belttype.contains_left() {
|
||||
b.add_entity(Entity::new_unknown(
|
||||
"steel-chest",
|
||||
Position::new(5, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(5, -2),
|
||||
Direction::Up,
|
||||
Position::new(1, 1),
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
None,
|
||||
Position::new(5, -1),
|
||||
Position::new(1, 1) + 2 * Position::new(5, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Fast,
|
||||
None,
|
||||
Position::new(4, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(4, -2),
|
||||
Direction::Right,
|
||||
));
|
||||
}
|
||||
|
|
@ -41,21 +41,21 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
if belttype.contains_right() {
|
||||
b.add_entity(Entity::new_unknown(
|
||||
"steel-chest",
|
||||
Position::new(1, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(1, -2),
|
||||
Direction::Up,
|
||||
Position::new(1, 1),
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
None,
|
||||
Position::new(1, -1),
|
||||
Position::new(1, 1) + 2 * Position::new(1, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Fast,
|
||||
None,
|
||||
Position::new(2, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(2, -2),
|
||||
Direction::Left,
|
||||
));
|
||||
}
|
||||
|
|
@ -71,31 +71,35 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(3, -4),
|
||||
Position::new(1, 1) + 2 * Position::new(3, -4),
|
||||
Direction::Up,
|
||||
));
|
||||
|
||||
let mut s = |x, beltdir| {
|
||||
b.add_entity(Entity::new_belt(beltspeed, Position::new(x, -4), beltdir));
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(1, 1) + 2 * Position::new(x, -4),
|
||||
beltdir,
|
||||
));
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
belt_inserter,
|
||||
stack_size,
|
||||
Position::new(x, -3),
|
||||
Position::new(1, 1) + 2 * Position::new(x, -3),
|
||||
Direction::Down,
|
||||
)
|
||||
.quality(quality),
|
||||
);
|
||||
b.add_entity(Entity::new_unknown(
|
||||
"steel-chest",
|
||||
Position::new(x, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(x, -2),
|
||||
Direction::Up,
|
||||
Position::new(1, 1),
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
None,
|
||||
Position::new(x, -1),
|
||||
Position::new(1, 1) + 2 * Position::new(x, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
};
|
||||
|
|
@ -126,36 +130,45 @@ pub fn one_loader(beltspeed: Beltspeed) -> (Blueprint, PositionType) {
|
|||
|
||||
b.add_entity(Entity::new_splitter(
|
||||
beltspeed,
|
||||
Position::new(4, -5),
|
||||
Position::new(8, -9),
|
||||
Direction::Down,
|
||||
));
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(3, -4),
|
||||
Position::new(1, 1) + 2 * Position::new(3, -4),
|
||||
Direction::Left,
|
||||
));
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(4, -4),
|
||||
Position::new(1, 1) + 2 * Position::new(4, -4),
|
||||
Direction::Right,
|
||||
));
|
||||
|
||||
let mut s = |x, beltdir| {
|
||||
b.add_entity(Entity::new_belt(beltspeed, Position::new(x, -4), beltdir));
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(1, 1) + 2 * Position::new(x, -4),
|
||||
beltdir,
|
||||
));
|
||||
b.add_entity(
|
||||
Entity::new_inserter(belt_inserter, None, Position::new(x, -3), Direction::Up)
|
||||
.quality(quality),
|
||||
Entity::new_inserter(
|
||||
belt_inserter,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(x, -3),
|
||||
Direction::Up,
|
||||
)
|
||||
.quality(quality),
|
||||
);
|
||||
b.add_entity(Entity::new_unknown(
|
||||
"steel-chest",
|
||||
Position::new(x, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(x, -2),
|
||||
Direction::Up,
|
||||
Position::new(1, 1),
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
None,
|
||||
Position::new(x, -1),
|
||||
Position::new(1, 1) + 2 * Position::new(x, -1),
|
||||
Direction::Up,
|
||||
));
|
||||
};
|
||||
|
|
@ -188,7 +201,7 @@ pub fn basic_station(
|
|||
for l in 1..=(length + locomotives) {
|
||||
poles.push(blueprint.add_entity(Entity::new_electric_pole(
|
||||
ElectricPoleType::Medium,
|
||||
Position::new(7 * l as PositionType, -2),
|
||||
Position::new(1, 1) + 2 * Position::new(7 * l as PositionType, -2),
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +229,7 @@ pub fn basic_station(
|
|||
|
||||
unloader.transform(Transformation::new(
|
||||
Direction::Up,
|
||||
Position::new((7 * l + global_x_offset) as PositionType, 0),
|
||||
2 * Position::new((7 * l + global_x_offset) as PositionType, 0),
|
||||
));
|
||||
|
||||
blueprint.add_blueprint(unloader);
|
||||
|
|
@ -225,18 +238,18 @@ pub fn basic_station(
|
|||
// train stop
|
||||
blueprint.add_entity(Entity::new_unknown(
|
||||
"train-stop",
|
||||
Position::new(0, -2),
|
||||
Position::new(2, -2),
|
||||
Direction::Left,
|
||||
Position::new(2, 2),
|
||||
Position::new(4, 4),
|
||||
));
|
||||
|
||||
// rails
|
||||
for l in 0..((length * 7 + global_x_offset + 1) / 2) {
|
||||
blueprint.add_entity(Entity::new_unknown(
|
||||
"straight-rail",
|
||||
Position::new(2 * l as PositionType, 0),
|
||||
Direction::Right,
|
||||
Position::new(2, 2),
|
||||
Position::new(2 + 4 * l as PositionType, 2),
|
||||
Direction::Left,
|
||||
Position::new(4, 4),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -246,20 +259,12 @@ pub fn basic_station(
|
|||
|
||||
m.transform(Transformation::new(
|
||||
Direction::Up,
|
||||
Position::new(global_x_offset as PositionType + 3, output_y),
|
||||
2 * Position::new(global_x_offset as PositionType + 3, output_y),
|
||||
));
|
||||
|
||||
blueprint.add_blueprint(m);
|
||||
// e.extend(merger(
|
||||
// load,
|
||||
// beltspeed,
|
||||
// global_x_offset as f64 + 3.5,
|
||||
// output_y,
|
||||
// e.len() as u32,
|
||||
// 7,
|
||||
// outputs,
|
||||
// length,
|
||||
// ));
|
||||
|
||||
// blueprint.transform(Transformation::new(Direction::Right, Position::new(0, 0)));
|
||||
|
||||
blueprint
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue