Add hard coded loot

This commit is contained in:
timokoesters 2020-03-18 20:37:11 +01:00
parent 1cb2022d35
commit 87c276b292
2 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,7 @@
use crate::{client::Client, Server, SpawnPoint, StateExt};
use common::{
comp::{self, HealthChange, HealthSource, Player, Stats},
assets,
comp::{self, object, Body, HealthChange, HealthSource, Item, Player, Stats},
msg::ServerMsg,
state::BlockChange,
sync::{Uid, WorldSyncExt},
@ -90,10 +91,36 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
.write_storage::<comp::CharacterState>()
.insert(entity, comp::CharacterState::default());
} else {
// Replace npc with loot
let _ = state
.ecs()
.write_storage()
.insert(entity, Body::Object(object::Body::Pouch));
let _ = state.ecs().write_storage().insert(
entity,
assets::load_expect_cloned::<Item>("common.items.cheese"),
);
state.ecs().write_storage::<comp::Agent>().remove(entity);
state
.ecs()
.write_storage::<comp::LightEmitter>()
.remove(entity);
state
.ecs()
.write_storage::<comp::CharacterState>()
.remove(entity);
state
.ecs()
.write_storage::<comp::Controller>()
.remove(entity);
// TODO: Add Delete(time_left: Duration) component
/*
// If not a player delete the entity
if let Err(err) = state.delete_entity_recorded(entity) {
error!("Failed to delete destroyed entity: {:?}", err);
}
*/
}
}

View File

@ -1364,8 +1364,8 @@ impl FigureMgr {
ecs.read_storage::<Scale>().maybe(),
)
.join()
// Don't render dead entities
.filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead))
// Don't render dead entities // Disabled to render corpses
//.filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead))
{
let is_player = entity == player_entity;
let player_camera_mode = if is_player {