mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Prevent crafting without station
This commit is contained in:
parent
a1fe7c12c3
commit
1a0f6f03ef
@ -584,10 +584,33 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
let craft_result = recipe_book
|
||||
.get(&recipe)
|
||||
.filter(|r| {
|
||||
let sprite = craft_sprite
|
||||
.and_then(|pos| state.terrain().get(pos).ok().copied())
|
||||
.and_then(|block| block.get_sprite());
|
||||
r.craft_sprite.map_or(true, |cs| Some(cs) == sprite)
|
||||
if let Some(needed_sprite) = r.craft_sprite {
|
||||
let sprite = craft_sprite
|
||||
.filter(|pos| {
|
||||
let entity_cylinder = get_cylinder(state, entity);
|
||||
if !within_pickup_range(entity_cylinder, || {
|
||||
Some(find_dist::Cube {
|
||||
min: pos.as_(),
|
||||
side_length: 1.0,
|
||||
})
|
||||
}) {
|
||||
debug!(
|
||||
?entity_cylinder,
|
||||
"Failed to pick up block as not within range, block pos: \
|
||||
{}",
|
||||
pos
|
||||
);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
.and_then(|pos| state.terrain().get(pos).ok().copied())
|
||||
.and_then(|block| block.get_sprite());
|
||||
Some(needed_sprite) == sprite
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
.and_then(|r| {
|
||||
r.perform(
|
||||
|
@ -699,6 +699,7 @@ impl<'a> Widget for Crafting<'a> {
|
||||
.resize(recipe.inputs().len(), &mut ui.widget_id_generator())
|
||||
});
|
||||
};
|
||||
|
||||
// Widget generation for every ingredient
|
||||
for (i, (recipe_input, amount)) in recipe.inputs.iter().enumerate() {
|
||||
let item_def = match recipe_input {
|
||||
|
@ -74,6 +74,7 @@ use common::{
|
||||
skills::{Skill, SkillGroupKind},
|
||||
BuffKind, Item,
|
||||
},
|
||||
consts::MAX_PICKUP_RANGE,
|
||||
outcome::Outcome,
|
||||
terrain::{SpriteKind, TerrainChunk},
|
||||
trade::{ReducedInventory, TradeAction},
|
||||
@ -3361,6 +3362,16 @@ impl Hud {
|
||||
.handle_event(conrod_core::event::Input::Text("\t".to_string()));
|
||||
}
|
||||
|
||||
// Stop selecting a sprite to perform crafting with when out of range
|
||||
self.show.craft_sprite = self.show.craft_sprite.filter(|(pos, _)| {
|
||||
self.show.crafting
|
||||
&& if let Some(player_pos) = client.position() {
|
||||
pos.map(|e| e as f32 + 0.5).distance(player_pos) < MAX_PICKUP_RANGE
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
// Optimization: skip maintaining UI when it's off.
|
||||
if !self.show.ui {
|
||||
return std::mem::take(&mut self.events);
|
||||
|
@ -530,13 +530,13 @@ impl Archetype for House {
|
||||
center_offset.x,
|
||||
center_offset.y,
|
||||
z + 100,
|
||||
)) % 8
|
||||
)) % 7
|
||||
{
|
||||
0..=1 => SpriteKind::Crate,
|
||||
2 => SpriteKind::Bench,
|
||||
3 => SpriteKind::Anvil,
|
||||
4 => SpriteKind::Cauldron,
|
||||
5 => SpriteKind::CraftingBench,
|
||||
4 => SpriteKind::Cauldron,
|
||||
5 => SpriteKind::CraftingBench,
|
||||
6 => SpriteKind::FireBowlGround,
|
||||
//8 => SpriteKind::Forge,
|
||||
_ => unreachable!(),
|
||||
@ -621,7 +621,7 @@ impl Archetype for House {
|
||||
0 => SpriteKind::HangingSign,
|
||||
1 | 2 | 3 => SpriteKind::HangingBasket,
|
||||
4 => SpriteKind::WallSconce,
|
||||
5 => SpriteKind::WallLampSmall,
|
||||
5 => SpriteKind::WallLampSmall,
|
||||
_ => SpriteKind::DungeonWallDecor,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user