mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add audio and chat message feedback when the player attempts to collect something while thier inventory is full.
This commit is contained in:
parent
ab56829385
commit
bc692c0101
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Game pauses when in singleplayer and pause menu
|
||||
- Added authentication system (to play on the official server register on https://account.veloren.net)
|
||||
- Added gamepad/controller support
|
||||
- Added player feedback when attempting to pickup an item with a full inventory
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -88,6 +88,12 @@
|
||||
"voxygen.audio.sfx.inventory.consumable.food",
|
||||
],
|
||||
threshold: 0.3,
|
||||
),
|
||||
Inventory(CollectFailed): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.inventory.add_failed",
|
||||
],
|
||||
threshold: 0.3,
|
||||
)
|
||||
}
|
||||
)
|
BIN
assets/voxygen/audio/sfx/inventory/add_failed.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/sfx/inventory/add_failed.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/sfx/inventory/add_item.wav
(Stored with Git LFS)
BIN
assets/voxygen/audio/sfx/inventory/add_item.wav
(Stored with Git LFS)
Binary file not shown.
@ -14,7 +14,9 @@ pub use specs::{
|
||||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use common::{
|
||||
comp::{self, ControlEvent, Controller, ControllerInputs, InventoryManip},
|
||||
comp::{
|
||||
self, ControlEvent, Controller, ControllerInputs, InventoryManip, InventoryUpdateEvent,
|
||||
},
|
||||
event::{EventBus, SfxEvent, SfxEventItem},
|
||||
msg::{
|
||||
validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, PlayerListUpdate,
|
||||
@ -689,7 +691,19 @@ impl Client {
|
||||
}
|
||||
},
|
||||
ServerMsg::InventoryUpdate(inventory, event) => {
|
||||
match event {
|
||||
InventoryUpdateEvent::CollectFailed => {
|
||||
frontend_events.push(Event::Chat {
|
||||
message: String::from(
|
||||
"Failed to collect item. Your inventory may be full!",
|
||||
),
|
||||
chat_type: ChatType::Meta,
|
||||
})
|
||||
},
|
||||
_ => {
|
||||
self.state.write_component(self.entity, inventory);
|
||||
},
|
||||
}
|
||||
|
||||
self.state
|
||||
.ecs()
|
||||
|
@ -150,6 +150,7 @@ pub enum InventoryUpdateEvent {
|
||||
Swapped,
|
||||
Dropped,
|
||||
Collected,
|
||||
CollectFailed,
|
||||
Possession,
|
||||
Debug,
|
||||
}
|
||||
|
@ -61,19 +61,26 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
let block = state.terrain().get(pos).ok().copied();
|
||||
|
||||
if let Some(block) = block {
|
||||
if block.is_collectible()
|
||||
&& state
|
||||
let has_inv_space = state
|
||||
.ecs()
|
||||
.read_storage::<comp::Inventory>()
|
||||
.get(entity)
|
||||
.map(|inv| !inv.is_full())
|
||||
.unwrap_or(false)
|
||||
&& state.try_set_block(pos, Block::empty()).is_some()
|
||||
.unwrap_or(false);
|
||||
|
||||
if !has_inv_space {
|
||||
state.write_component(
|
||||
entity,
|
||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::CollectFailed),
|
||||
);
|
||||
} else {
|
||||
if block.is_collectible() && state.try_set_block(pos, Block::empty()).is_some()
|
||||
{
|
||||
comp::Item::try_reclaim_from_block(block)
|
||||
.map(|item| state.give_item(entity, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
comp::InventoryManip::Use(slot) => {
|
||||
|
Loading…
Reference in New Issue
Block a user