<commit_before>#include "entity_id.h"

#include "world.h"
#include "halley/maths/uuid.h"
#include "halley/entity/entity_factory.h"

using namespace Halley;

String EntityId::toUUID(const EntityId& id, const ConfigNodeSerializationContext& context)
{
	auto& world = context.entityContext->getWorld();
	return world.getEntity(id).getInstanceUUID().toString();
}

EntityId EntityId::fromUUID(const String& uuidStr, const ConfigNodeSerializationContext& context)
{
	return context.entityContext->getEntityIdFromUUID(UUID(uuidStr));
}
<commit_msg>Some fallback to allow deserialization of components outside of a factory context<commit_after>#include "entity_id.h"

#include "world.h"
#include "halley/maths/uuid.h"
#include "halley/entity/entity_factory.h"

using namespace Halley;

String EntityId::toUUID(const EntityId& id, const ConfigNodeSerializationContext& context)
{
	if (!context.entityContext) {
		return "";
	}
	auto& world = context.entityContext->getWorld();
	return world.getEntity(id).getInstanceUUID().toString();
}

EntityId EntityId::fromUUID(const String& uuidStr, const ConfigNodeSerializationContext& context)
{
	if (!context.entityContext) {
		return EntityId();
	}
	return context.entityContext->getEntityIdFromUUID(UUID(uuidStr));
}

{'fraction_non_alphanumeric': 0.12280701754385964, 'fraction_numerical': 0.0, 'mean_word_length': 7.256578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7641622', 'n_tokens_mistral': 385, 'n_tokens_neox': 398, 'n_words': 82}