<commit_before>#include "World.h"
#include "WorldState.h"
#include "Engine.h"

namespace ECSE
{

World::World(WorldState* worldState)
    : worldState(worldState)
{
}

World::~World()
{
}

void World::update(sf::Time deltaTime)
{
    // Notify systems they've been added on first update
    if (!systemsAdded)
    {
        for (auto& system : orderedSystems)
        {
            system->added();
        }

        systemsAdded = true;
    }

    for (auto& system : orderedSystems)
    {
        system->update(deltaTime);
    }
}

void World::advance()
{
    for (auto& system : orderedSystems)
    {
        system->advance();
    }
}

void World::render(float alpha, sf::RenderTarget& renderTarget)
{
    for (auto& system : orderedSystems)
    {
        system->render(alpha, renderTarget);
    }
}

void World::registerEntity(Entity::ID id)
{
    Entity* entity = getEntity(id);

    if (!entity)
    {
        throw std::runtime_error("Tried to register an Entity with an invalid ID!");
    }

    for (auto& pair : systems)
    {
        pair.second->inspectEntity(*entity);
    }
<commit_msg>Improved error handling for attaching components/entity registration<commit_after>#include "World.h"
#include "WorldState.h"
#include "Engine.h"

namespace ECSE
{

World::World(WorldState* worldState)
    : worldState(worldState)
{
}

World::~World()
{
}

void World::update(sf::Time deltaTime)
{
    // Notify systems they've been added on first update
    if (!systemsAdded)
    {
        for (auto& system : orderedSystems)
        {
            system->added();
        }

        systemsAdded = true;
    }

    for (auto& system : orderedSystems)
    {
        system->update(deltaTime);
    }
}

void World::advance()
{
    for (auto& system : orderedSystems)
    {
        system->advance();
    }
}

void World::render(float alpha, sf::RenderTarget& renderTarget)
{
    for (auto& system : orderedSystems)
    {
        system->render(alpha, renderTarget);
    }
}

void World::registerEntity(Entity::ID id)
{
    Entity* entity = getEntity(id);

    if (entity->registered)
    {
        std::stringstream ss;
        ss << "Entity already registered (id " << id << ")";
        throw std::runtime_error(ss.str());
    }

    if (!entity)
    {
        std::stringstream ss;
        ss << "Tried to register an Entity with an invalid ID (" << id << ")";
        throw std::runtime_error(ss.str());
    }

    for (auto& pair : systems)
    {
        pair.second->inspectEntity(*entity);
    }

{'fraction_non_alphanumeric': 0.13841244515357, 'fraction_numerical': 0.0, 'mean_word_length': 2.587982832618026, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, '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': '175450', 'n_tokens_mistral': 799, 'n_tokens_neox': 784, 'n_words': 179}