mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Allow non player entites to be removed again
This commit is contained in:
parent
b5f649eb15
commit
e674424974
@ -243,6 +243,8 @@ impl Server {
|
||||
let state = &mut self.state;
|
||||
let clients = &mut self.clients;
|
||||
|
||||
let mut todo_remove = None;
|
||||
|
||||
match event {
|
||||
ServerEvent::Explosion { pos, radius } => {
|
||||
const RAYS: usize = 500;
|
||||
@ -306,23 +308,21 @@ impl Server {
|
||||
clients.notify_registered(ServerMsg::kill(msg));
|
||||
}
|
||||
|
||||
{
|
||||
// Give EXP to the client
|
||||
let mut stats = ecs.write_storage::<comp::Stats>();
|
||||
// Give EXP to the client
|
||||
let mut stats = ecs.write_storage::<comp::Stats>();
|
||||
|
||||
if let Some(entity_stats) = stats.get(entity).cloned() {
|
||||
if let comp::HealthSource::Attack { by } = cause {
|
||||
ecs.entity_from_uid(by.into()).map(|attacker| {
|
||||
if let Some(attacker_stats) = stats.get_mut(attacker) {
|
||||
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
||||
attacker_stats.exp.change_by(
|
||||
(entity_stats.health.maximum() as f64 / 10.0
|
||||
+ entity_stats.level.level() as f64 * 10.0)
|
||||
as i64,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(entity_stats) = stats.get(entity).cloned() {
|
||||
if let comp::HealthSource::Attack { by } = cause {
|
||||
ecs.entity_from_uid(by.into()).map(|attacker| {
|
||||
if let Some(attacker_stats) = stats.get_mut(attacker) {
|
||||
// TODO: Discuss whether we should give EXP by Player Killing or not.
|
||||
attacker_stats.exp.change_by(
|
||||
(entity_stats.health.maximum() as f64 / 10.0
|
||||
+ entity_stats.level.level() as f64 * 10.0)
|
||||
as i64,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ impl Server {
|
||||
let _ = ecs.write_storage().insert(entity, comp::ForceUpdate);
|
||||
client.force_state(ClientState::Dead);
|
||||
} else {
|
||||
let _ = state.ecs_mut().delete_entity_synced(entity);
|
||||
todo_remove = Some(entity.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,6 +356,10 @@ impl Server {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(entity) = todo_remove {
|
||||
let _ = state.ecs_mut().delete_entity_synced(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user