mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Convert into Possessor for /into_npc
This commit is contained in:
parent
7e2f219de1
commit
0caa54bf5b
@ -676,6 +676,39 @@ fn handle_into_npc(
|
||||
args: Vec<String>,
|
||||
action: &ServerChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
// Black magic
|
||||
use crate::IdMaps;
|
||||
use comp::{Presence, PresenceKind};
|
||||
|
||||
let id_to_drop = {
|
||||
let ecs = server.state.ecs();
|
||||
let presences = ecs.read_storage::<Presence>();
|
||||
let presence = presences.get(target);
|
||||
if let Some(PresenceKind::Character(character_id)) = presence.map(|p| p.kind) {
|
||||
Some(character_id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
if let Some(id) = id_to_drop {
|
||||
server
|
||||
.state
|
||||
.mut_resource::<IdMaps>()
|
||||
.remove_entity(Some(target), None, Some(id), None);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let ecs_mut = server.state.ecs_mut();
|
||||
let mut presences = ecs_mut.write_storage::<Presence>();
|
||||
if let Some(presence) = presences.get_mut(target) {
|
||||
presence.kind = PresenceKind::Possessor;
|
||||
}
|
||||
}
|
||||
// End of black magic
|
||||
|
||||
if client != target {
|
||||
server.notify_client(
|
||||
client,
|
||||
|
Loading…
Reference in New Issue
Block a user