Refactor power connection to work with different electric poles

This commit is contained in:
hal8174 2025-03-05 18:35:52 +01:00
parent b4ab291884
commit 642f815f9d
8 changed files with 394 additions and 144 deletions

View file

@ -2,6 +2,7 @@ use clap::Parser;
use factorio_blueprint::{BlueprintString, encode};
use factorio_blueprint_generator::multistation::{StationSpec, multistation};
use factorio_core::beltoptions::Beltspeed;
use factorio_core::visualize::Visualize;
#[derive(Parser)]
struct Args {
@ -35,59 +36,60 @@ fn main() {
})
})
.collect();
let mut b = multistation(
&stations,
// &[
// StationSpec {
// locomotives: 2,
// wagons: 4,
// load: false,
// beltspeed: Beltspeed::Normal,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 8,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 2,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// StationSpec {
// locomotives: 1,
// wagons: 1,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// ],
8,
)
.0;
let b = BlueprintString::Blueprint(
multistation(
&stations,
// &[
// StationSpec {
// locomotives: 2,
// wagons: 4,
// load: false,
// beltspeed: Beltspeed::Normal,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 8,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 2,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// StationSpec {
// locomotives: 1,
// wagons: 1,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// ],
8,
)
.0
.to_blueprint(),
);
b.connect_power_networks();
b.print_visualization();
let b = BlueprintString::Blueprint(b.to_blueprint());
if args.json {
println!("{}", serde_json::to_string_pretty(&b).unwrap());

View file

@ -0,0 +1,19 @@
use factorio_blueprint::abstraction::{Blueprint, Entity};
use factorio_core::prelude::*;
use factorio_core::visualize::Visualize;
fn main() {
let mut b = Blueprint::new();
b.add_entity(Entity::new_electric_pole(
factorio_blueprint::abstraction::ElectricPoleType::Medium,
Position::new(1, 1),
));
b.add_entity(Entity::new_electric_pole(
factorio_blueprint::abstraction::ElectricPoleType::Medium,
Position::new(101, 3),
));
b.connect_power_networks();
b.print_visualization();
}