Skip to content

Commit

Permalink
refactor(frontend) finish signal conversion, fix passing data to VM
Browse files Browse the repository at this point in the history
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
  • Loading branch information
Ryex committed Aug 20, 2024
1 parent 70833e0 commit b1c9db2
Show file tree
Hide file tree
Showing 45 changed files with 5,256 additions and 2,610 deletions.
16 changes: 13 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 148 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -1 +1,148 @@
{"language":"en","flagWords":[],"version":"0.2","words":["Astroloy","Autolathe","bapal","bapz","bapzal","batchmode","batchmodes","bdns","bdnsal","bdse","bdseal","beqal","beqz","beqzal","bgeal","bgez","bgezal","bgtal","bgtz","bgtzal","bindgen","bleal","blez","blezal","bltal","bltz","bltzal","bnaal","bnan","bnaz","bnazal","bneal","bnez","bnezal","brap","brapz","brdns","brdse","breq","breqz","brge","brgez","brgt","brgtz","brle","brlez","brlt","brltz","brna","brnan","brnaz","brne","brnez","Circuitboard","codegen","conv","cstyle","endpos","getd","Hardsuit","hashables","inext","inextp","infile","itertools","jetpack","kbshortcutmenu","Keybind","lbns","logicable","logictype","logictypes","lzma","Mineables","mscorlib","MSEED","ninf","nomatch","oprs","overcolumn","Overlength","pedia","peekable","prec","preproc","putd","QUICKFIX","reagentmode","reagentmodes","repr","retval","rocketstation","sapz","sattellite","sdns","sdse","searchbox","searchbtn","seqz","serde","settingsmenu","sgez","sgtz","slez","slotlogic","slotlogicable","LogicSlotType","LogicSlotTypes","slottype","sltz","snan","snanz","snaz","snez","splitn","Stationeers","stationpedia","stdweb","thiserror","tokentype","trunc","Tsify","whos","Depressurising","Pressurising","logicslottypes","lparen","rparen","hstack","dylib"]}
{
"language": "en",
"flagWords": [],
"version": "0.2",
"words": [
"arn't",
"Astroloy",
"Atmo",
"Autolathe",
"Autotagged",
"bapal",
"bapz",
"bapzal",
"batchmode",
"batchmodes",
"bdns",
"bdnsal",
"bdse",
"bdseal",
"beqal",
"beqz",
"beqzal",
"bgeal",
"bgez",
"bgezal",
"bgtal",
"bgtz",
"bgtzal",
"bindgen",
"bleal",
"blez",
"blezal",
"bltal",
"bltz",
"bltzal",
"bnaal",
"bnan",
"bnaz",
"bnazal",
"bneal",
"bnez",
"bnezal",
"brap",
"brapz",
"brdns",
"brdse",
"breq",
"breqz",
"brge",
"brgez",
"brgt",
"brgtz",
"brle",
"brlez",
"brlt",
"brltz",
"brna",
"brnan",
"brnaz",
"brne",
"brnez",
"Circuitboard",
"codegen",
"conv",
"cstyle",
"Depressurising",
"dylib",
"endpos",
"getd",
"Hardsuit",
"hashables",
"hstack",
"impls",
"indexmap",
"inext",
"inextp",
"infile",
"Instructable",
"intf",
"itertools",
"jetpack",
"kbshortcutmenu",
"Keybind",
"lbns",
"logicable",
"LogicSlotType",
"logicslottypes",
"LogicSlotTypes",
"logictype",
"logictypes",
"lparen",
"lzma",
"Mineables",
"mscorlib",
"MSEED",
"ninf",
"nomatch",
"nops",
"oprs",
"overcolumn",
"Overlength",
"pedia",
"peekable",
"prec",
"preproc",
"Pressurising",
"putd",
"QUICKFIX",
"reagentmode",
"reagentmodes",
"repr",
"retval",
"rocketstation",
"rparen",
"sapz",
"sattellite",
"sdns",
"sdse",
"searchbox",
"searchbtn",
"seqz",
"serde",
"settingsmenu",
"sgez",
"sgtz",
"slez",
"slotlogic",
"slotlogicable",
"slottype",
"sltz",
"snan",
"snanz",
"snaz",
"snez",
"splitn",
"Stationeers",
"stationpedia",
"stdweb",
"tbody",
"thiserror",
"tokentype",
"toolbelt",
"trunc",
"Tsify",
"uneval",
"whos"
]
}
4 changes: 2 additions & 2 deletions ic10emu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ time = { version = "0.3.36", features = [
"serde",
"local-offset",
] }
tsify = { version = "0.4.5", optional = true, features = ["json"] }
tsify = { version = "0.4.5", optional = true, features = ["js"] }
wasm-bindgen = { version = "0.2.92", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand All @@ -46,7 +46,7 @@ color-eyre = "0.6.3"
serde_json = "1.0.117"

# Self dev dependency to enable prefab_database feature for tests
ic10emu = { path = ".", features = ["prefab_database"] }
# ic10emu = { path = ".", features = ["prefab_database"] }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions ic10emu/src/interpreter/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,7 @@ impl<T: IC10Marker> LrInstruction for T {
.as_reagent_interface()
.ok_or(ICError::NotReagentReadable(*logicable.get_id()))?;
reagent_interface
.get_current_recipie()
.get_current_recipe()
.iter()
.find(|(hash, _)| *hash as f64 == int)
.map(|(_, quantity)| *quantity)
Expand Down Expand Up @@ -2686,7 +2686,7 @@ impl<T: IC10Marker> HcfInstruction for T {
.borrow_mut()
.as_mut_circuit_holder()
.ok_or(ICError::CircuitHolderNotLogicable(*self.get_id()))?
.hault_and_catch_fire();
.halt_and_catch_fire();
}
self.set_state(ICState::HasCaughtFire);
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions ic10emu/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub enum Connection {
PipeLiquid {
role: ConnectionRole,
},
RoboticArmRail {
role: ConnectionRole,
},
#[default]
None,
}
Expand Down Expand Up @@ -83,6 +86,7 @@ impl Connection {
ConnectionType::LandingPad => Self::LandingPad { role },
ConnectionType::LaunchPad => Self::LaunchPad { role },
ConnectionType::PipeLiquid => Self::PipeLiquid { role },
ConnectionType::RoboticArmRail => Self::RoboticArmRail { role },
}
}

Expand Down Expand Up @@ -140,6 +144,10 @@ impl Connection {
typ: ConnectionType::LaunchPad,
role: *role,
},
Self::RoboticArmRail { role } => ConnectionInfo {
typ: ConnectionType::RoboticArmRail,
role: *role
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion ic10emu/src/vm/object/generic/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ where
fn get_ic(&self) -> Option<VMObject> {
self.get_ic_gw()
}
fn hault_and_catch_fire(&mut self) {
fn halt_and_catch_fire(&mut self) {
self.hault_and_catch_fire_gw()
}
}
Expand Down
2 changes: 1 addition & 1 deletion ic10emu/src/vm/object/humans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl Human for HumanPlayer {
fn set_hygiene(&mut self, hygiene: f32) {
self.hygiene = hygiene.clamp(0.0, MAX_HYGIENE);
}
fn hygine_state(&self) -> StatState {
fn hygiene_state(&self) -> StatState {
if self.hygiene < CRITICAL_HYGIENE {
return StatState::Critical;
}
Expand Down
10 changes: 5 additions & 5 deletions ic10emu/src/vm/object/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ macro_rules! object_trait {

paste::paste! {
$(
#[doc = "Return a `& dyn " $trt "` if implimented by the object"]
#[doc = "Return a `& dyn " $trt "` if implemented by the object"]
#[inline(always)]
fn [<as_ $trt:snake>](&self) -> Option<[<$trt Ref>]> {
None
}

#[doc = "Return a `&mut dyn " $trt "` if implimented by the object"]
#[doc = "Return a `&mut dyn " $trt "` if implemented by the object"]
#[inline(always)]
fn [<as_mut_ $trt:snake>](&mut self) -> Option<[<$trt RefMut>]> {
None
Expand Down Expand Up @@ -74,7 +74,7 @@ macro_rules! object_trait {

}
}
/// call func on the dyn refrence or a borrow of the vm object
/// call func on the dyn reference or a borrow of the vm object
pub fn map<F, R>(&self, mut func: F ) -> R
where
F: std::ops::FnMut(& dyn $trait_name) -> R
Expand Down Expand Up @@ -103,12 +103,12 @@ macro_rules! object_trait {
}
pub fn get_id(&self) -> u32 {
match self {
Self::DynRef(refrence) => *refrence.get_id(),
Self::DynRef(reference) => *reference.get_id(),
Self::VMObject(obj) => *obj.borrow().get_id(),

}
}
/// call func on the dyn refrence or a borrow of the vm object
/// call func on the dyn reference or a borrow of the vm object
pub fn map<F, R>(&mut self, mut func: F ) -> R
where
F: std::ops::FnMut(&mut dyn $trait_name) -> R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl CircuitHolder for StructureCircuitHousing {
.and_then(|info| self.vm.get_object(info.id))
}

fn hault_and_catch_fire(&mut self) {
fn halt_and_catch_fire(&mut self) {
// TODO: do something here??
}
}
14 changes: 14 additions & 0 deletions ic10emu/src/vm/object/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct ObjectInfo {
pub prefab: Option<String>,
pub prefab_hash: Option<i32>,
pub slots: Option<BTreeMap<u32, SlotOccupantInfo>>,
pub parent_slot: Option<(ObjectID, u32)>,
pub root_parent_human: Option<ObjectID>,
pub damage: Option<f32>,
pub device_pins: Option<BTreeMap<u32, ObjectID>>,
pub connections: Option<BTreeMap<u32, ObjectID>>,
Expand All @@ -96,6 +98,8 @@ impl From<&VMObject> for ObjectInfo {
prefab: Some(obj_ref.get_prefab().value.clone()),
prefab_hash: Some(obj_ref.get_prefab().hash),
slots: None,
parent_slot: None,
root_parent_human: None,
damage: None,
device_pins: None,
connections: None,
Expand Down Expand Up @@ -136,6 +140,8 @@ impl ObjectInfo {
prefab: Some(prefab_name),
prefab_hash: Some(prefab_hash),
slots: None,
parent_slot: None,
root_parent_human: None,
damage: None,
device_pins: None,
connections: None,
Expand Down Expand Up @@ -215,6 +221,14 @@ impl ObjectInfo {
} else {
self.damage.replace(damage);
}
let parent_slot = item.get_parent_slot();
if let Some(parent_slot) = parent_slot {
self.parent_slot = Some((parent_slot.parent, parent_slot.slot as u32));
}
let root_parent_human = item.root_parent_human();
if let Some(root_parent_human) = root_parent_human {
self.root_parent_human = Some(root_parent_human.get_id());
}
self
}

Expand Down
Loading

0 comments on commit b1c9db2

Please sign in to comment.