Add constructors for inputs and outputs

master
D4VID 1 month ago
parent 2617424501
commit d19d7cd94c

@ -1,11 +1,22 @@
use std::{
fs::{self, File}, i32, io::{self, Write}, path::Path
fs::{self, File},
io::{self, Write},
path::Path,
};
use crate::lw::{BinarySerializable, ComponentIdMap, ModVersion, Version};
pub mod lw;
// Convert component text id into numeric id
pub fn component_id(text_id: &str) -> i16 {
match text_id {
"MHG.CircuitBoard" => 1,
"MHG.AndGate" => 2,
_ => -1,
}
}
enum SaveType {
_World = 1,
Subassembly = 2,
@ -56,10 +67,16 @@ fn write_subassembly_file(
}];
mods.write_to(file)?;
let component_id_map = vec![ComponentIdMap {
numeric_id: 15,
let component_id_map = vec![
ComponentIdMap {
numeric_id: 1,
text_id: "MHG.CircuitBoard".to_owned(),
}];
},
ComponentIdMap {
numeric_id: 2,
text_id: "MHG.AndGate".to_owned(),
},
];
component_id_map.write_to(file)?;
for component in components {

@ -47,10 +47,20 @@ pub struct ModVersion {
pub struct Input {
circuit_state_id: Int,
}
impl Input {
pub fn new(circuit_state_id: Int) -> Self {
Self { circuit_state_id }
}
}
#[derive(BinarySerializable)]
pub struct Output {
circuit_state_id: Int,
}
impl Output {
pub fn new(circuit_state_id: Int) -> Self {
Self { circuit_state_id }
}
}
#[derive(BinarySerializable)]
pub struct ComponentIdMap {

Loading…
Cancel
Save