Add output signals
This commit is contained in:
parent
ce76626f79
commit
aabd9486e0
3 changed files with 90 additions and 32 deletions
|
|
@ -12,36 +12,64 @@ struct Args {
|
|||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let stations: Vec<_> = (0..8)
|
||||
.map(|_| StationSpec {
|
||||
locomotives: 1,
|
||||
wagons: 2,
|
||||
load: false,
|
||||
beltspeed: Beltspeed::Normal,
|
||||
lanes: 1,
|
||||
})
|
||||
.collect();
|
||||
// let stations: Vec<_> = (0..2)
|
||||
// .map(|_| StationSpec {
|
||||
// locomotives: 1,
|
||||
// wagons: 2,
|
||||
// load: false,
|
||||
// beltspeed: Beltspeed::Turbo,
|
||||
// lanes: 2,
|
||||
// })
|
||||
// .collect();
|
||||
|
||||
let b = BlueprintString::Blueprint(
|
||||
multistation(
|
||||
&stations,
|
||||
// &[
|
||||
// StationSpec {
|
||||
// locomotives: 1,
|
||||
// wagons: 1,
|
||||
// load: false,
|
||||
// beltspeed: Beltspeed::Normal,
|
||||
// lanes: 1,
|
||||
// },
|
||||
// StationSpec {
|
||||
// locomotives: 1,
|
||||
// wagons: 1,
|
||||
// load: false,
|
||||
// beltspeed: Beltspeed::Express,
|
||||
// lanes: 1,
|
||||
// },
|
||||
// ],
|
||||
16,
|
||||
// &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,
|
||||
)
|
||||
.to_blueprint(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -202,10 +202,9 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
|
|||
9,
|
||||
));
|
||||
|
||||
for j in 0..dbg!(
|
||||
(7 * longest_train).div_ceil(2)
|
||||
- (7 * (station.locomotives + station.wagons)).div_ceil(2)
|
||||
) {
|
||||
for j in 0..((7 * longest_train).div_ceil(2)
|
||||
- (7 * (station.locomotives + station.wagons)).div_ceil(2))
|
||||
{
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
RailType::Straight,
|
||||
Position::new(
|
||||
|
|
@ -225,7 +224,7 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
|
|||
factorio_core::beltoptions::Belttype::Full,
|
||||
);
|
||||
|
||||
let station_height = PositionType::max(16, 16);
|
||||
let station_height = PositionType::max(12, 4 + ((3 - b.bounding_box().min().y) / 4) * 4);
|
||||
assert!(station_height % 4 == 0);
|
||||
|
||||
b.transform(Transformation::new(
|
||||
|
|
@ -301,6 +300,16 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
|
|||
),
|
||||
6,
|
||||
));
|
||||
if i % 4 == 0 {
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
RailType::RailSignal,
|
||||
Position::new(
|
||||
outrail_x - 7 - 4 * i as PositionType,
|
||||
total_stacker_height - 19 - 4 * i as PositionType,
|
||||
),
|
||||
6,
|
||||
));
|
||||
}
|
||||
}
|
||||
let remaining_offset = total_stacker_height - 34 - out_diagonal_length * 4;
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
|
|
@ -313,12 +322,24 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
|
|||
Position::new(38, remaining_offset + 4),
|
||||
8,
|
||||
));
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
RailType::RailSignal,
|
||||
Position::new(41, remaining_offset + 7),
|
||||
7,
|
||||
));
|
||||
for i in 0..(remaining_offset / 4) {
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
RailType::Straight,
|
||||
Position::new(38, 2 + 4 * i as PositionType),
|
||||
0,
|
||||
));
|
||||
if i % 8 == 7 {
|
||||
blueprint.add_entity(Entity::new_rail(
|
||||
RailType::RailSignal,
|
||||
Position::new(41, 3 + 4 * i as PositionType),
|
||||
8,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
blueprint
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use factorio_core::{
|
||||
aabb::AABB,
|
||||
beltoptions::Beltspeed,
|
||||
direction,
|
||||
pathfield::PathField,
|
||||
|
|
@ -459,6 +460,14 @@ impl Blueprint {
|
|||
e.transform(transform);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self) -> AABB {
|
||||
self.entities
|
||||
.iter()
|
||||
.map(|(_, e)| AABB::new(e.position, e.position))
|
||||
.reduce(|a, b| a.combine(b))
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Blueprint {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue