Add constructors for inputs and outputs

master
D4VID 1 month ago
parent 2617424501
commit d19d7cd94c

@ -1,11 +1,22 @@
use std::{ 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}; use crate::lw::{BinarySerializable, ComponentIdMap, ModVersion, Version};
pub mod lw; 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 { enum SaveType {
_World = 1, _World = 1,
Subassembly = 2, Subassembly = 2,
@ -56,10 +67,16 @@ fn write_subassembly_file(
}]; }];
mods.write_to(file)?; mods.write_to(file)?;
let component_id_map = vec![ComponentIdMap { let component_id_map = vec![
numeric_id: 15, ComponentIdMap {
numeric_id: 1,
text_id: "MHG.CircuitBoard".to_owned(), text_id: "MHG.CircuitBoard".to_owned(),
}]; },
ComponentIdMap {
numeric_id: 2,
text_id: "MHG.AndGate".to_owned(),
},
];
component_id_map.write_to(file)?; component_id_map.write_to(file)?;
for component in components { for component in components {

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

Loading…
Cancel
Save