<commit_before>package net.sww.ecs;

public abstract class Component {

    public Entity entity;

    void installed(Entity entity) {
        this.entity = entity;
        init();
    }
    void uninstalled(Entity entity) {
        this.entity = null;
    }
    public void update(float dt) {}
    public void onEvent(Event msg) {}
    public void init() {}

    public final <T extends Component> T get(Class<T> type) {
        return entity.get(type);
    }

    public final <T extends Component> boolean has(Class<T> type) {
        return entity.has(type);
    }

    public final World getWorld() {
        return entity.world;
    }

    public void sendEvent(Event event) {
        entity.sendEvent(event);
    }

    public void broadcastEvent(Event event) {
        entity.broadcastEvent(event);
    }
}<commit_msg>Adds a public accessor for a Component's entity.<commit_after>package net.sww.ecs;

public abstract class Component {

    // TODO(sww): make this private
    public Entity entity;

    void installed(Entity entity) {
        this.entity = entity;
        init();
    }
    void uninstalled(Entity entity) {
        this.entity = null;
    }
    public void update(float dt) {}
    public void onEvent(Event msg) {}
    public void init() {}

    public final <T extends Component> T get(Class<T> type) {
        return entity.get(type);
    }

    public final <T extends Component> boolean has(Class<T> type) {
        return entity.has(type);
    }

    public final World getWorld() {
        return entity.world;
    }

    public final Entity getEntity() {
        return entity;
    }

    public void sendEvent(Event event) {
        entity.sendEvent(event);
    }

    public void broadcastEvent(Event event) {
        entity.broadcastEvent(event);
    }
}
{'fraction_non_alphanumeric': 0.10050251256281408, 'fraction_numerical': 0.0, 'mean_word_length': 2.4133333333333336, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6936377', 'n_tokens_mistral': 523, 'n_tokens_neox': 503, 'n_words': 151}