Get serialization parity for direct abstract blueprint serialization

This commit is contained in:
hal8174 2025-04-05 23:44:44 +02:00
parent a5d3819114
commit 48a648716d
3 changed files with 108 additions and 7 deletions

View file

@ -8,7 +8,10 @@ use factorio_core::{
quaterdirection::QuaterDirection,
visualize::{Color, Visualization},
};
use std::{collections::HashMap, sync::atomic::AtomicUsize};
use std::{
collections::{HashMap, HashSet},
sync::atomic::AtomicUsize,
};
mod power_connection;
mod roboports;
@ -563,11 +566,10 @@ pub struct EntityKey(usize);
static ENTITY_COUNTER: AtomicUsize = AtomicUsize::new(0);
#[derive(Clone)]
pub struct Blueprint {
entities: Vec<(EntityKey, Entity)>,
keys: HashMap<EntityKey, usize>,
wires: Vec<(EntityKey, u8, EntityKey, u8)>,
wires: HashSet<(EntityKey, u8, EntityKey, u8)>,
}
impl Blueprint {
@ -575,7 +577,7 @@ impl Blueprint {
Self {
entities: Vec::new(),
keys: HashMap::new(),
wires: Vec::new(),
wires: HashSet::new(),
}
}
@ -622,7 +624,7 @@ impl Blueprint {
}
pub fn add_wire(&mut self, a: EntityKey, endpoint_a: u8, b: EntityKey, endpoint_b: u8) {
self.wires.push((a, endpoint_a, b, endpoint_b));
self.wires.insert((a, endpoint_a, b, endpoint_b));
}
pub fn add_blueprint(&mut self, other: Self) {