This commit is contained in:
juliancoffee
2021-09-27 23:21:57 +03:00
parent 7291d32209
commit 68aba856ec
2 changed files with 4 additions and 11 deletions

View File

@ -862,13 +862,6 @@ impl Component for Item {
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>; type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>;
} }
// #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
// pub struct ItemDrop<T: AsRef<str>>(pub LootSpec<T>);
// impl<T: 'static + Send + Sync + AsRef<str>> Component for ItemDrop<T> {
// type Storage = IdvStorage<Self>;
// }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ItemDrop(pub Item); pub struct ItemDrop(pub Item);

View File

@ -346,18 +346,18 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
Some(comp::Alignment::Owned(_)) Some(comp::Alignment::Owned(_))
) )
{ {
// Only drop loot if entity has agency (not a player), and if it is not owned by // Only drop loot if entity has agency (not a player),
// another entity (not a pet) // and if it is not owned by another entity (not a pet)
// Decide for a loot drop before turning into a lootbag // Decide for a loot drop before turning into a lootbag
let old_body = state.ecs().write_storage::<Body>().remove(entity); let old_body = state.ecs().write_storage::<Body>().remove(entity);
let loot_spec = { let item = {
let mut item_drop = state.ecs().write_storage::<comp::ItemDrop>(); let mut item_drop = state.ecs().write_storage::<comp::ItemDrop>();
item_drop.remove(entity).map(|comp::ItemDrop(item)| item) item_drop.remove(entity).map(|comp::ItemDrop(item)| item)
}; };
if let Some(item) = loot_spec { if let Some(item) = item {
let pos = state.ecs().read_storage::<comp::Pos>().get(entity).cloned(); let pos = state.ecs().read_storage::<comp::Pos>().get(entity).cloned();
let vel = state.ecs().read_storage::<comp::Vel>().get(entity).cloned(); let vel = state.ecs().read_storage::<comp::Vel>().get(entity).cloned();
if let Some(pos) = pos { if let Some(pos) = pos {