<commit_before>use std::default::Default;
use rand::Rng;
use util::Dijkstra;
use util::Rgb;
use world;
use location::{Location};
use dir6::Dir6;
use flags;
use stats::{Intrinsic};
use components::{BrainState, Alignment};
use geom::HexGeom;
use spatial::Place;
use action;
use fov::Fov;
use rng;
use msg;
use item::{ItemType, Slot};
use stats::Stats;
use ecs::{ComponentAccess};

/// Game object handle.
#[derive(Copy, PartialEq, Eq, Clone, Hash, PartialOrd, Ord, Debug, RustcDecodable, RustcEncodable)]
pub struct Entity(pub usize);

impl Entity {
    /// Place the entity in a location in the game world.
    pub fn place(self, loc: Location) {
        assert!(!self.is_prototype(), "Tried to field a prototype");
        world::with_mut(|w| w.spatial.insert_at(self, loc));
        self.on_move_to(loc);
    }

    /// Remove the entity from all the game world systems. THE ENTITY VALUE
    /// WILL BE INVALID FROM HERE ON AND USING IT WILL LEAD TO BUGS. THE
    /// CALLER IS RESPONSIBLE FOR ENSUING THAT AN ENTITY WILL NOT BE
    /// USED FROM ANYWHERE AFTER THE DELETE OPERATION.
    pub fn delete(self) {
        world::with_mut(|w| w.comps.remove(self));
        world::with_mut(|w| w.spatial.remove(self));
        world::with_mut(|w| w.ecs.delete(self));
    }

    pub fn blocks_walk(self) -> bool { self.is_mob() }

    pub fn name(self) -> String {
        world::with(|w|
            match w.descs().get(self) {
                Some(desc) => desc.name.clone(),
                None => "".to_string()
            }
        )
    }

    pub fn get_icon(self) -> Option<(usize, Rgb)> {
        world::with(|w|
            if let Some(desc) = w.descs().get(self) {
                Some((desc.icon, desc.color))
            } else {
                None
            }
        )
    }
<commit_msg>Update cache when deleting player<commit_after>use std::default::Default;
use rand::Rng;
use util::Dijkstra;
use util::Rgb;
use world;
use location::{Location};
use dir6::Dir6;
use flags;
use stats::{Intrinsic};
use components::{BrainState, Alignment};
use geom::HexGeom;
use spatial::Place;
use action;
use fov::Fov;
use rng;
use msg;
use item::{ItemType, Slot};
use stats::Stats;
use ecs::{ComponentAccess};

/// Game object handle.
#[derive(Copy, PartialEq, Eq, Clone, Hash, PartialOrd, Ord, Debug, RustcDecodable, RustcEncodable)]
pub struct Entity(pub usize);

impl Entity {
    /// Place the entity in a location in the game world.
    pub fn place(self, loc: Location) {
        assert!(!self.is_prototype(), "Tried to field a prototype");
        world::with_mut(|w| w.spatial.insert_at(self, loc));
        self.on_move_to(loc);
    }

    /// Remove the entity from all the game world systems. THE ENTITY VALUE
    /// WILL BE INVALID FROM HERE ON AND USING IT WILL LEAD TO BUGS. THE
    /// CALLER IS RESPONSIBLE FOR ENSUING THAT AN ENTITY WILL NOT BE
    /// USED FROM ANYWHERE AFTER THE DELETE OPERATION.
    pub fn delete(self) {
        world::with_mut(|w|
            if w.flags.player == Some(self) { w.flags.player = None; });
        world::with_mut(|w| w.comps.remove(self));
        world::with_mut(|w| w.spatial.remove(self));
        world::with_mut(|w| w.ecs.delete(self));
    }

    pub fn blocks_walk(self) -> bool { self.is_mob() }

    pub fn name(self) -> String {
        world::with(|w|
            match w.descs().get(self) {
                Some(desc) => desc.name.clone(),
                None => "".to_string()
            }
        )
    }

    pub fn get_icon(self) -> Option<(usize, Rgb)> {
        world::with(|w|
            if let Some(desc) = w.descs().get(self) {
                Some((desc.icon, desc.color))
            } else {
                None
            }
        )
    }

{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0010720986330742428, 'mean_word_length': 2.5240793201133145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4291379', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1225, 'n_words': 344}