#include <Entity/Entity.hpp>
#include <World/LocalWorld/LocalWorld.hpp>
#include <Log/Log.hpp>

void Entity::sendMessage(const void *msg, size_t size)
{
    world->sendMessageToEntity(id, msg, size);
}

void Entity::despawn()
{
    LocalWorld *localWorld = dynamic_cast<LocalWorld*>(world);
    if (localWorld == nullptr)
    {
        crash("despawn() called on the client!");
    }

    localWorld->despawnEntity(id);
    localWorld->sendDeleteEntityMessageToClients(id);
}

Entity::Entity(World &world, std::string typeId, uint64_t id) : world(&world), typeId(typeId), id(id) {}

bool Entity::wouldCollideWith(Block &block, glm::ivec3 pos)
{
    return false;
}