<commit_before>/**
	* Interface for all systems. Systems act on a particular set of components.
    *
	* Author: <NAME>
	* Date: 6/8/2013
	* File: ISystem.h
**/

#pragma once

#include <list>
#include "EntityAccessor.h"

class ISystem : public EntityAccessor
{
protected:
	bool _Active;
    const char* _Type;
	std::list<unsigned int> _EntitiesToUpdate;
public:
	ISystem() : _Active(true) {};
    virtual ~ISystem() {}
	void Activate() { _Active = true; }
	void Deactivate() { _Active = false; }
	bool isActive() const { return _Active; }
    const char* GetType() const { return _Type; }
    virtual void Update(unsigned long dt) = 0;
    virtual void ValidateEntity(unsigned int ID) = 0;
};<commit_msg>Now systems will use ValidateEntity to automatically update their lists<commit_after>/**
	* Interface for all systems. Systems act on a particular set of components.
    *
	* Author: <NAME>
	* Date: 6/8/2013
	* File: ISystem.h
**/

#pragma once

#include <list>
#include "EntityAccessor.h"
#include "Listener.h"

class ISystem : public EntityAccessor, public Listener<EntityMessage>
{
protected:
	bool _Active;
    const char* _Type;
	std::list<unsigned int> _EntitiesToUpdate;
public:
    ISystem() : _Active(true) { };
    virtual ~ISystem() {}
	void Activate() { _Active = true; }
	void Deactivate() { _Active = false; }
	bool isActive() const { return _Active; }
    const char* GetType() const { return _Type; }
    virtual void Update(unsigned long dt) = 0;
    virtual bool ValidateEntity(unsigned int ID) = 0;

    void OnMessage(EntityMessage &msg) override;
};

/**
 * @brief ISystem::OnMessage When a new entity is added or destroyed, this will determine whether to add/remove entity from list
 * @param msg the message data
 */
void ISystem::OnMessage(EntityMessage &msg)
{
    if(msg.Destroyed)
    {
        _EntitiesToUpdate.remove(msg.ID);
    }

    else if(ValidateEntity(msg.ID))
    {
        _EntitiesToUpdate.push_back(msg.ID);
    }
}
{'fraction_non_alphanumeric': 0.11881693013768485, 'fraction_numerical': 0.00815910249872514, 'mean_word_length': 3.8088235294117645, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '7258411', 'n_tokens_mistral': 631, 'n_tokens_neox': 624, 'n_words': 197}