Skip to content

Commit

Permalink
docs + clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyTornetta committed Dec 4, 2024
1 parent 65e6e06 commit f814ec8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
5 changes: 1 addition & 4 deletions cosmos_client/src/crafting/blocks/basic_fabricator/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ fn populate_menu(
flex_direction: FlexDirection::Column,
..Default::default()
},
..Default::default()
},
..Default::default()
},
Expand Down Expand Up @@ -236,9 +235,7 @@ fn populate_menu(
})
.with_children(|p| {
for item in recipe.inputs.iter() {
let item_id = match item.item {
RecipeItem::Item(i) => i,
};
let RecipeItem::Item(item_id) = item.item;

p.spawn((
NodeBundle {
Expand Down
10 changes: 3 additions & 7 deletions cosmos_core/src/crafting/recipes/basic_fabricator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,16 @@ impl BasicFabricatorRecipe {
}

for input in &self.inputs {
let id = match input.item {
RecipeItem::Item(id) => id,
};
let RecipeItem::Item(id) = input.item;
unique_item_counts.entry(id).or_insert(0);
}

unique_item_counts
.into_iter()
.flat_map(|(item_id, quantity)| {
let Some(input) = self.inputs.iter().find(|x| match x.item {
let input = self.inputs.iter().find(|x| match x.item {
RecipeItem::Item(id) => id == item_id,
}) else {
return None;
};
})?;

Some(quantity / input.quantity as u32)
})
Expand Down
4 changes: 1 addition & 3 deletions cosmos_server/src/crafting/blocks/basic_fabricator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ fn monitor_craft_event(
let input_multiplier = qty_crafted / ev.recipe.output.quantity as u32;

for input in ev.recipe.inputs.iter() {
let item = match input.item {
RecipeItem::Item(item_id) => item_id,
};
let RecipeItem::Item(item) = input.item;
let item = items.from_numeric_id(item);
let (leftover, _) = fab_inv.take_and_remove_item(item, input.quantity as usize * input_multiplier as usize, &mut commands);
assert_eq!(leftover, 0, "Invalid crafting occurred! Input Leftover ({leftover}) != 0");
Expand Down
2 changes: 2 additions & 0 deletions cosmos_server/src/crafting/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Server-related crafting logic
use bevy::prelude::App;

mod blocks;
Expand Down
6 changes: 6 additions & 0 deletions cosmos_server/src/netty/sync/registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Server registry syncing
use bevy::{
app::Update,
log::warn,
Expand All @@ -10,6 +12,10 @@ use cosmos_core::{
use renet2::{ClientId, RenetServer};

#[derive(Debug, Event)]
/// This event is sent when the client has received every registry from the server.
///
/// This will be sent in their initial connecting phase, and anything that relies on a registry
/// must be sent after this is received.
pub struct ClientFinishedReceivingRegistriesEvent(pub ClientId);

fn listen_for_done_syncing(
Expand Down

0 comments on commit f814ec8

Please sign in to comment.