mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added comments in areas that were lacking.
This commit is contained in:
parent
794b072d3e
commit
356057afc4
@ -804,14 +804,14 @@ impl Item {
|
||||
.any(|tag| matches!(tag, ItemTag::SalvageInto(_)))
|
||||
}
|
||||
|
||||
// Attempts to salvage an item, returning the salvaged items if salvageable,
|
||||
// else the original item is not Theoretically supports returning multiple
|
||||
// items, only returns one per tag in the item for now
|
||||
// Attempts to salvage an item by consuming it, returns the salvaged items if
|
||||
// salvageable, else the original item
|
||||
pub fn try_salvage(self) -> Result<Vec<Item>, Item> {
|
||||
if !self.is_salvageable() {
|
||||
return Err(self);
|
||||
}
|
||||
|
||||
// Creates one item for every salvage tag in the target item
|
||||
let salvaged_items: Vec<_> = self
|
||||
.item_def
|
||||
.tags
|
||||
|
@ -37,6 +37,11 @@ impl Recipe {
|
||||
let mut recipe_inputs = Vec::new();
|
||||
let mut unsatisfied_requirements = Vec::new();
|
||||
|
||||
// Checks each input against a slot in the inventory. If the slot contains an
|
||||
// item that fulfills the need of the input, takes from the inventory up to the
|
||||
// quantity needed for the crafting input. If the item either cannot be used, or
|
||||
// there is insufficient quantity, adds input and number of materials needed to
|
||||
// unsatisfied requirements.
|
||||
self.inputs
|
||||
.iter()
|
||||
.enumerate()
|
||||
@ -65,10 +70,12 @@ impl Recipe {
|
||||
}
|
||||
});
|
||||
|
||||
// If there are no unsatisfied requirements, create the items produced by the
|
||||
// recipe in the necessary quantity, else insert the ingredients back into the
|
||||
// inventory
|
||||
if unsatisfied_requirements.is_empty() {
|
||||
let (item_def, quantity) = &self.output;
|
||||
let crafted_item =
|
||||
Item::new_from_item_def(Arc::clone(item_def), &[], ability_map, msm);
|
||||
let crafted_item = Item::new_from_item_def(Arc::clone(item_def), &[], ability_map, msm);
|
||||
let mut crafted_items = Vec::with_capacity(*quantity as usize);
|
||||
for _ in 0..*quantity {
|
||||
crafted_items.push(crafted_item.duplicate(ability_map, msm));
|
||||
|
@ -647,24 +647,6 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Craft),
|
||||
);
|
||||
}
|
||||
|
||||
// Drop the item if there wasn't enough space
|
||||
// if let Some(Some((item, amount))) = craft_result {
|
||||
// let ability_map = &state.ecs().read_resource::<AbilityMap>();
|
||||
// let msm =
|
||||
// state.ecs().read_resource::<MaterialStatManifest>();
|
||||
// for _ in 0..amount {
|
||||
// dropped_items.push((
|
||||
// state
|
||||
// .read_component_copied::<comp::Pos>(entity)
|
||||
// .unwrap_or_default(),
|
||||
// state
|
||||
// .read_component_copied::<comp::Ori>(entity)
|
||||
// .unwrap_or_default(),
|
||||
// item.duplicate(ability_map, &msm),
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
},
|
||||
comp::InventoryManip::Sort => {
|
||||
inventory.sort();
|
||||
|
Loading…
Reference in New Issue
Block a user