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 {
|
pub fn generate_4_lane_balancer2() -> Blueprint {
|
||||||
let mut b = abstraction::Blueprint::new();
|
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 {
|
for (x, y) in splitter_pos {
|
||||||
b.add_entity(Entity::new_splitter(
|
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.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()
|
b.to_blueprint()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ use factorio_core::beltoptions::{Beltspeed, Belttype};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
#[arg(short, long)]
|
||||||
|
json: bool,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Command,
|
command: Command,
|
||||||
}
|
}
|
||||||
|
|
@ -13,12 +15,13 @@ struct Args {
|
||||||
enum Command {
|
enum Command {
|
||||||
Book,
|
Book,
|
||||||
Single {
|
Single {
|
||||||
|
#[arg(long)]
|
||||||
load: bool,
|
load: bool,
|
||||||
locomotives: usize,
|
locomotives: usize,
|
||||||
length: usize,
|
length: usize,
|
||||||
outputs: usize,
|
outputs: usize,
|
||||||
beltspeed: Beltspeed,
|
beltspeed: Beltspeed,
|
||||||
#[arg(default_value = "full")]
|
#[arg(short, long, default_value = "full")]
|
||||||
belttype: Belttype,
|
belttype: Belttype,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +112,9 @@ fn main() {
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if args.json {
|
||||||
|
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||||
|
}
|
||||||
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||||
}
|
}
|
||||||
Command::Single {
|
Command::Single {
|
||||||
|
|
@ -124,7 +130,9 @@ fn main() {
|
||||||
.to_blueprint(),
|
.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()));
|
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ pub fn merger(
|
||||||
for j in 0..depth {
|
for j in 0..depth {
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
stubspeed,
|
stubspeed,
|
||||||
Position::new(
|
Position::new(1, 1)
|
||||||
|
+ 2 * Position::new(
|
||||||
(intervall * (i + o * section_size)) as PositionType,
|
(intervall * (i + o * section_size)) as PositionType,
|
||||||
-(j as PositionType),
|
-(j as PositionType),
|
||||||
),
|
),
|
||||||
|
|
@ -38,7 +39,8 @@ pub fn merger(
|
||||||
|
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
stubspeed,
|
stubspeed,
|
||||||
Position::new(
|
Position::new(1, 1)
|
||||||
|
+ 2 * Position::new(
|
||||||
(intervall * (i + o * section_size)) as PositionType,
|
(intervall * (i + o * section_size)) as PositionType,
|
||||||
-(depth as PositionType),
|
-(depth as PositionType),
|
||||||
),
|
),
|
||||||
|
|
@ -59,9 +61,10 @@ pub fn merger(
|
||||||
b.add_entity(Entity::new_splitter(
|
b.add_entity(Entity::new_splitter(
|
||||||
mergespeed,
|
mergespeed,
|
||||||
Position::new(
|
Position::new(
|
||||||
(intervall * (j * p + o * section_size)) as PositionType
|
2 * ((intervall * (j * p + o * section_size)) as PositionType
|
||||||
- i as PositionType,
|
- i as PositionType)
|
||||||
0 - i as PositionType - depth as PositionType + !reverse as PositionType,
|
+ 1,
|
||||||
|
2 * (1 - i as PositionType - depth as PositionType),
|
||||||
),
|
),
|
||||||
match reverse {
|
match reverse {
|
||||||
true => Direction::Right,
|
true => Direction::Right,
|
||||||
|
|
@ -72,7 +75,8 @@ pub fn merger(
|
||||||
for l in 0..(7 * p / 2) {
|
for l in 0..(7 * p / 2) {
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
mergespeed.halve(),
|
mergespeed.halve(),
|
||||||
Position::new(
|
Position::new(1, 1)
|
||||||
|
+ 2 * Position::new(
|
||||||
(intervall * (j * p + o * section_size) + l + 1) as PositionType
|
(intervall * (j * p + o * section_size) + l + 1) as PositionType
|
||||||
- i as PositionType,
|
- i as PositionType,
|
||||||
0 - i as PositionType - depth as PositionType,
|
0 - i as PositionType - depth as PositionType,
|
||||||
|
|
@ -91,7 +95,8 @@ pub fn merger(
|
||||||
for l in 0..(7 * o * section_size) {
|
for l in 0..(7 * o * section_size) {
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
Position::new(
|
Position::new(1, 1)
|
||||||
|
+ 2 * Position::new(
|
||||||
l as PositionType - section_size.ilog2() as PositionType,
|
l as PositionType - section_size.ilog2() as PositionType,
|
||||||
-(step as PositionType),
|
-(step as PositionType),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -12,28 +12,28 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
||||||
if beltspeed == Beltspeed::Normal {
|
if beltspeed == Beltspeed::Normal {
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
Beltspeed::Fast,
|
Beltspeed::Fast,
|
||||||
Position::new(3, -2),
|
Position::new(1, 1) + 2 * Position::new(3, -2),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
));
|
));
|
||||||
|
|
||||||
if belttype.contains_left() {
|
if belttype.contains_left() {
|
||||||
b.add_entity(Entity::new_unknown(
|
b.add_entity(Entity::new_unknown(
|
||||||
"steel-chest",
|
"steel-chest",
|
||||||
Position::new(5, -2),
|
Position::new(1, 1) + 2 * Position::new(5, -2),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
Position::new(1, 1),
|
Position::new(2, 2),
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Bulk,
|
InserterType::Bulk,
|
||||||
None,
|
None,
|
||||||
Position::new(5, -1),
|
Position::new(1, 1) + 2 * Position::new(5, -1),
|
||||||
Direction::Down,
|
Direction::Down,
|
||||||
));
|
));
|
||||||
|
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Fast,
|
InserterType::Fast,
|
||||||
None,
|
None,
|
||||||
Position::new(4, -2),
|
Position::new(1, 1) + 2 * Position::new(4, -2),
|
||||||
Direction::Right,
|
Direction::Right,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -41,21 +41,21 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
||||||
if belttype.contains_right() {
|
if belttype.contains_right() {
|
||||||
b.add_entity(Entity::new_unknown(
|
b.add_entity(Entity::new_unknown(
|
||||||
"steel-chest",
|
"steel-chest",
|
||||||
Position::new(1, -2),
|
Position::new(1, 1) + 2 * Position::new(1, -2),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
Position::new(1, 1),
|
Position::new(2, 2),
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Bulk,
|
InserterType::Bulk,
|
||||||
None,
|
None,
|
||||||
Position::new(1, -1),
|
Position::new(1, 1) + 2 * Position::new(1, -1),
|
||||||
Direction::Down,
|
Direction::Down,
|
||||||
));
|
));
|
||||||
|
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Fast,
|
InserterType::Fast,
|
||||||
None,
|
None,
|
||||||
Position::new(2, -2),
|
Position::new(1, 1) + 2 * Position::new(2, -2),
|
||||||
Direction::Left,
|
Direction::Left,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -71,31 +71,35 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
||||||
|
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
Position::new(3, -4),
|
Position::new(1, 1) + 2 * Position::new(3, -4),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut s = |x, beltdir| {
|
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(
|
b.add_entity(
|
||||||
Entity::new_inserter(
|
Entity::new_inserter(
|
||||||
belt_inserter,
|
belt_inserter,
|
||||||
stack_size,
|
stack_size,
|
||||||
Position::new(x, -3),
|
Position::new(1, 1) + 2 * Position::new(x, -3),
|
||||||
Direction::Down,
|
Direction::Down,
|
||||||
)
|
)
|
||||||
.quality(quality),
|
.quality(quality),
|
||||||
);
|
);
|
||||||
b.add_entity(Entity::new_unknown(
|
b.add_entity(Entity::new_unknown(
|
||||||
"steel-chest",
|
"steel-chest",
|
||||||
Position::new(x, -2),
|
Position::new(1, 1) + 2 * Position::new(x, -2),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
Position::new(1, 1),
|
Position::new(2, 2),
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Bulk,
|
InserterType::Bulk,
|
||||||
None,
|
None,
|
||||||
Position::new(x, -1),
|
Position::new(1, 1) + 2 * Position::new(x, -1),
|
||||||
Direction::Down,
|
Direction::Down,
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
@ -126,36 +130,45 @@ pub fn one_loader(beltspeed: Beltspeed) -> (Blueprint, PositionType) {
|
||||||
|
|
||||||
b.add_entity(Entity::new_splitter(
|
b.add_entity(Entity::new_splitter(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
Position::new(4, -5),
|
Position::new(8, -9),
|
||||||
Direction::Down,
|
Direction::Down,
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
Position::new(3, -4),
|
Position::new(1, 1) + 2 * Position::new(3, -4),
|
||||||
Direction::Left,
|
Direction::Left,
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
Position::new(4, -4),
|
Position::new(1, 1) + 2 * Position::new(4, -4),
|
||||||
Direction::Right,
|
Direction::Right,
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut s = |x, beltdir| {
|
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(
|
b.add_entity(
|
||||||
Entity::new_inserter(belt_inserter, None, Position::new(x, -3), Direction::Up)
|
Entity::new_inserter(
|
||||||
|
belt_inserter,
|
||||||
|
None,
|
||||||
|
Position::new(1, 1) + 2 * Position::new(x, -3),
|
||||||
|
Direction::Up,
|
||||||
|
)
|
||||||
.quality(quality),
|
.quality(quality),
|
||||||
);
|
);
|
||||||
b.add_entity(Entity::new_unknown(
|
b.add_entity(Entity::new_unknown(
|
||||||
"steel-chest",
|
"steel-chest",
|
||||||
Position::new(x, -2),
|
Position::new(1, 1) + 2 * Position::new(x, -2),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
Position::new(1, 1),
|
Position::new(2, 2),
|
||||||
));
|
));
|
||||||
b.add_entity(Entity::new_inserter(
|
b.add_entity(Entity::new_inserter(
|
||||||
InserterType::Bulk,
|
InserterType::Bulk,
|
||||||
None,
|
None,
|
||||||
Position::new(x, -1),
|
Position::new(1, 1) + 2 * Position::new(x, -1),
|
||||||
Direction::Up,
|
Direction::Up,
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
@ -188,7 +201,7 @@ pub fn basic_station(
|
||||||
for l in 1..=(length + locomotives) {
|
for l in 1..=(length + locomotives) {
|
||||||
poles.push(blueprint.add_entity(Entity::new_electric_pole(
|
poles.push(blueprint.add_entity(Entity::new_electric_pole(
|
||||||
ElectricPoleType::Medium,
|
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(
|
unloader.transform(Transformation::new(
|
||||||
Direction::Up,
|
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);
|
blueprint.add_blueprint(unloader);
|
||||||
|
|
@ -225,18 +238,18 @@ pub fn basic_station(
|
||||||
// train stop
|
// train stop
|
||||||
blueprint.add_entity(Entity::new_unknown(
|
blueprint.add_entity(Entity::new_unknown(
|
||||||
"train-stop",
|
"train-stop",
|
||||||
Position::new(0, -2),
|
Position::new(2, -2),
|
||||||
Direction::Left,
|
Direction::Left,
|
||||||
Position::new(2, 2),
|
Position::new(4, 4),
|
||||||
));
|
));
|
||||||
|
|
||||||
// rails
|
// rails
|
||||||
for l in 0..((length * 7 + global_x_offset + 1) / 2) {
|
for l in 0..((length * 7 + global_x_offset + 1) / 2) {
|
||||||
blueprint.add_entity(Entity::new_unknown(
|
blueprint.add_entity(Entity::new_unknown(
|
||||||
"straight-rail",
|
"straight-rail",
|
||||||
Position::new(2 * l as PositionType, 0),
|
Position::new(2 + 4 * l as PositionType, 2),
|
||||||
Direction::Right,
|
Direction::Left,
|
||||||
Position::new(2, 2),
|
Position::new(4, 4),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,20 +259,12 @@ pub fn basic_station(
|
||||||
|
|
||||||
m.transform(Transformation::new(
|
m.transform(Transformation::new(
|
||||||
Direction::Up,
|
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);
|
blueprint.add_blueprint(m);
|
||||||
// e.extend(merger(
|
|
||||||
// load,
|
// blueprint.transform(Transformation::new(Direction::Right, Position::new(0, 0)));
|
||||||
// beltspeed,
|
|
||||||
// global_x_offset as f64 + 3.5,
|
|
||||||
// output_y,
|
|
||||||
// e.len() as u32,
|
|
||||||
// 7,
|
|
||||||
// outputs,
|
|
||||||
// length,
|
|
||||||
// ));
|
|
||||||
|
|
||||||
blueprint
|
blueprint
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ impl ElectricPoleType {
|
||||||
|
|
||||||
fn size(&self) -> Position {
|
fn size(&self) -> Position {
|
||||||
match self {
|
match self {
|
||||||
ElectricPoleType::Small | ElectricPoleType::Medium => Position::new(1, 1),
|
ElectricPoleType::Small | ElectricPoleType::Medium => Position::new(2, 2),
|
||||||
ElectricPoleType::Big | ElectricPoleType::Substation => Position::new(2, 2),
|
ElectricPoleType::Big | ElectricPoleType::Substation => Position::new(4, 4),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -213,14 +213,14 @@ impl Entity {
|
||||||
|
|
||||||
pub fn size(&self) -> Position {
|
pub fn size(&self) -> Position {
|
||||||
match &self.entity {
|
match &self.entity {
|
||||||
EntityType::Splitter(_) => Position::new(2, 1),
|
EntityType::Splitter(_) => Position::new(4, 2),
|
||||||
EntityType::Unknown {
|
EntityType::Unknown {
|
||||||
name: _,
|
name: _,
|
||||||
size,
|
size,
|
||||||
misc: _,
|
misc: _,
|
||||||
} => *size,
|
} => *size,
|
||||||
EntityType::ElectricPole(electric_pole_type) => electric_pole_type.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 {
|
for &p in path {
|
||||||
match p {
|
match p {
|
||||||
PathField::Belt { pos, dir } => {
|
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 } => {
|
PathField::Underground { pos, dir, len } => {
|
||||||
self.add_entity(Entity::new_underground_belt(
|
self.add_entity(Entity::new_underground_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
UndergroundType::Input,
|
UndergroundType::Input,
|
||||||
pos,
|
2 * pos + Position::new(1, 1),
|
||||||
dir,
|
dir,
|
||||||
));
|
));
|
||||||
self.add_entity(Entity::new_underground_belt(
|
self.add_entity(Entity::new_underground_belt(
|
||||||
beltspeed,
|
beltspeed,
|
||||||
UndergroundType::Output,
|
UndergroundType::Output,
|
||||||
pos.in_direction(&dir, len as PositionType),
|
2 * pos.in_direction(&dir, len as PositionType) + Position::new(1, 1),
|
||||||
dir,
|
dir,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -304,15 +308,10 @@ impl Blueprint {
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, (_, e))| {
|
.map(|(i, (_, e))| {
|
||||||
let size = (e.size() - Position::new(1, 1))
|
|
||||||
.transform(Transformation::new(e.direction, Position::new(0, 0)));
|
|
||||||
BlueprintEntity::builder(
|
BlueprintEntity::builder(
|
||||||
e.get_name(),
|
e.get_name(),
|
||||||
i as u32 + 1,
|
i as u32 + 1,
|
||||||
BlueprintPosition::new(
|
BlueprintPosition::new(0.5 * e.position.x as f64, 0.5 * e.position.y as f64),
|
||||||
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,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.direction(match e.direction {
|
.direction(match e.direction {
|
||||||
Direction::Up => 0,
|
Direction::Up => 0,
|
||||||
|
|
|
||||||
|
|
@ -72,3 +72,22 @@ impl From<(i32, i32)> for Position {
|
||||||
Position::new(value.0, value.1)
|
Position::new(value.0, value.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::ops::Mul<i32> for Position {
|
||||||
|
type Output = Position;
|
||||||
|
|
||||||
|
fn mul(mut self, rhs: i32) -> Self::Output {
|
||||||
|
self.x *= rhs;
|
||||||
|
self.y *= rhs;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::ops::Mul<Position> for i32 {
|
||||||
|
type Output = Position;
|
||||||
|
|
||||||
|
fn mul(self, mut rhs: Position) -> Self::Output {
|
||||||
|
rhs.x *= self;
|
||||||
|
rhs.y *= self;
|
||||||
|
rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue