Refactor layouting into separate crate

This commit is contained in:
hal8174 2025-01-27 22:09:59 +01:00
parent c3bb980fcf
commit 5c8010c23b
15 changed files with 124 additions and 55 deletions

View file

@ -85,6 +85,7 @@ fn main() {
// ],
8,
)
.0
.to_blueprint(),
);

View file

@ -40,7 +40,10 @@ fn calculate_station_height(
station_height
}
pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint {
pub fn multistation(
stations: &[StationSpec],
stacker_size: usize,
) -> (Blueprint, PositionType, Vec<PositionType>) {
let longest_train = stations
.iter()
.map(|s| s.locomotives + s.wagons)
@ -144,6 +147,7 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
let inrail_x = 10 - 4 * stacker_length as PositionType;
let outrail_x = inrail_x + 52 + 4 * (7 * longest_train).div_ceil(2) as PositionType;
let mut output_heights = Vec::new();
let mut previous_station_heights = 0;
// station
for (i, station) in stations.iter().enumerate() {
@ -269,6 +273,8 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
let station_height =
calculate_station_height(output_height, station.lanes, station.beltspeed);
output_heights.push(30 + total_stacker_height + previous_station_heights + output_height);
// rail crossing
let (beltdirection, underground_left, underground_right) = match station.load {
true => (
@ -629,5 +635,5 @@ pub fn multistation(stations: &[StationSpec], stacker_size: usize) -> Blueprint
blueprint.transform(Transformation::new(Direction::Right, Position::new(0, 0)));
blueprint
(blueprint, outrail_x + 5, output_heights)
}