mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Owned mine loot
This commit is contained in:
parent
179bf7216e
commit
e03b733ad7
@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Bamboo collectibles now spawn near rivers
|
- Bamboo collectibles now spawn near rivers
|
||||||
- Chest sprites can longer be exploded
|
- Chest sprites can longer be exploded
|
||||||
- Smoke varies by temperature, humidity, time of day and house
|
- Smoke varies by temperature, humidity, time of day and house
|
||||||
|
- Added loot ownership for drops from mining
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ use common::{
|
|||||||
agent::{AgentEvent, Sound, SoundKind},
|
agent::{AgentEvent, Sound, SoundKind},
|
||||||
dialogue::Subject,
|
dialogue::Subject,
|
||||||
inventory::slot::EquipSlot,
|
inventory::slot::EquipSlot,
|
||||||
|
loot_owner::LootOwnerKind,
|
||||||
tool::ToolKind,
|
tool::ToolKind,
|
||||||
Inventory, Pos, SkillGroupKind,
|
Inventory, LootOwner, Pos, SkillGroupKind,
|
||||||
},
|
},
|
||||||
consts::{MAX_MOUNT_RANGE, SOUND_TRAVEL_DIST_PER_VOLUME},
|
consts::{MAX_MOUNT_RANGE, SOUND_TRAVEL_DIST_PER_VOLUME},
|
||||||
event::EventBus,
|
event::EventBus,
|
||||||
@ -169,6 +170,8 @@ pub fn handle_mine_block(
|
|||||||
if let Some(block) = block.filter(|b| b.mine_tool().map_or(false, |t| Some(t) == tool)) {
|
if let Some(block) = block.filter(|b| b.mine_tool().map_or(false, |t| Some(t) == tool)) {
|
||||||
// Drop item if one is recoverable from the block
|
// Drop item if one is recoverable from the block
|
||||||
if let Some(mut item) = comp::Item::try_reclaim_from_block(block) {
|
if let Some(mut item) = comp::Item::try_reclaim_from_block(block) {
|
||||||
|
let maybe_uid = state.ecs().uid_from_entity(entity);
|
||||||
|
|
||||||
if let Some(mut skillset) = state
|
if let Some(mut skillset) = state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<comp::SkillSet>()
|
.write_storage::<comp::SkillSet>()
|
||||||
@ -176,7 +179,7 @@ pub fn handle_mine_block(
|
|||||||
{
|
{
|
||||||
if let (Some(tool), Some(uid), Some(exp_reward)) = (
|
if let (Some(tool), Some(uid), Some(exp_reward)) = (
|
||||||
tool,
|
tool,
|
||||||
state.ecs().uid_from_entity(entity),
|
maybe_uid,
|
||||||
item.item_definition_id()
|
item.item_definition_id()
|
||||||
.itemdef_id()
|
.itemdef_id()
|
||||||
.and_then(|id| RESOURCE_EXPERIENCE_MANIFEST.read().0.get(id).copied()),
|
.and_then(|id| RESOURCE_EXPERIENCE_MANIFEST.read().0.get(id).copied()),
|
||||||
@ -232,10 +235,15 @@ pub fn handle_mine_block(
|
|||||||
let _ = item.increase_amount(1);
|
let _ = item.increase_amount(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state
|
let item_drop = state
|
||||||
.create_item_drop(Default::default(), item)
|
.create_item_drop(Default::default(), item)
|
||||||
.with(comp::Pos(pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0)))
|
.with(comp::Pos(pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0)));
|
||||||
.build();
|
if let Some(uid) = maybe_uid {
|
||||||
|
item_drop.with(LootOwner::new(LootOwnerKind::Player(uid)))
|
||||||
|
} else {
|
||||||
|
item_drop
|
||||||
|
}
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
state.set_block(pos, block.into_vacant());
|
state.set_block(pos, block.into_vacant());
|
||||||
|
Loading…
Reference in New Issue
Block a user