<commit_before>#pragma once


namespace framework {


//=================================
// ECS Controller inline functions
//=================================


namespace detail {

	//-------------------------------
	// EcsController::GenCompPtrList
	//
	// variadic template recursively adds components to a raw component pointer list
	//
	template<typename TComponentType>
	void GenCompPtrList(std::vector<RawComponentPtr>& list, TComponentType& component) 
	{
		list.emplace_back(MakeRawComponent(component));
	}

	template<typename TComponentType, typename... Args>
	void GenCompPtrList(std::vector<RawComponentPtr>& list, TComponentType& component1, Args... args) 
	{
		list.emplace_back(MakeRawComponent(component1));
		GenCompPtrList(list, args...);
	}

} // namespace detail


//--------------------------
// EcsController::AddEntity
//
template<typename TComponentType, typename... Args>
T_EntityId EcsController::AddEntity(TComponentType& component1, Args... args)
{
	return AddEntityChild(INVALID_ENTITY_ID, component1, args...);
}

//-------------------------------
// EcsController::AddEntityChild
//
template<typename TComponentType, typename... Args>
T_EntityId EcsController::AddEntityChild(T_EntityId const parent, TComponentType& component1, Args... args)
{
	std::vector<RawComponentPtr> components;
	detail::GenCompPtrList(components, component1, args...);

	return AddEntityBatched(parent, components);
}

//------------------------------
// EcsController::AddComponents
//
template<typename TComponentType, typename... Args>
void EcsController::AddComponents(T_EntityId const entity, TComponentType& component1, Args... args)
{
	std::vector<RawComponentPtr> components;<commit_msg>ecs controller works as expected now when bulk creating entities with templates.<commit_after>#pragma once


namespace framework {


//=================================
// ECS Controller inline functions
//=================================


namespace detail {

	//-------------------------------
	// EcsController::GenCompPtrList
	//
	// variadic template recursively adds components to a raw component pointer list
	//
	template<typename TComponentType>
	void GenCompPtrList(std::vector<RawComponentPtr>& list, TComponentType& component) 
	{
		list.emplace_back(MakeRawComponent(component));
	}

	template<typename TComponentType, typename... Args>
	void GenCompPtrList(std::vector<RawComponentPtr>& list, TComponentType& component1, Args... args) 
	{
		list.emplace_back(MakeRawComponent(component1));
		GenCompPtrList(list, args...);
	}

	//-------------------------------
	// EcsController::AddToEcs
	//
	// variadic template recursively adds components to a raw component pointer list and finally create an entity from that component list
	// adding the entity in the last recursion call prevents components from going out of scope for some reason
	//
	template<typename TComponentType>
	T_EntityId AddToEcs(EcsController& ecs, T_EntityId const parent, std::vector<RawComponentPtr>& list, TComponentType& component)
	{
		list.emplace_back(MakeRawComponent(component));
		return ecs.AddEntityBatched(parent, list);
	}

	template<typename TComponentType, typename... Args>
	T_EntityId AddToEcs(EcsController& ecs, T_EntityId const parent, std::vector<RawComponentPtr>& list, TComponentType& component1, Args... args)
	{
		list.emplace_back(MakeRawComponent(component1));
		return AddToEcs(ecs, parent, list, args...);
	}

} // namespace detail


//--------------------------
// EcsController::AddEntity
//
template<typename TComponentType, typename... Args>
T_EntityId EcsController::AddEntity(TComponentType& component1, Args... args)
{
	return AddEntityChild(INVALID_ENTITY_ID, component1, args...);
}

//-------------------------------
// EcsController::AddEntityChild
//
template<typename TComponentType, typename... Args>
T_EntityId EcsController::AddEntityChild(T_EntityId const parent, TComponentType& component1, Args... args)
{
	std::vector<RawComponentPtr> components;
	return detail::AddToEcs(*this, parent, components, component1, args...);
}

//------------------------------
// EcsController::AddComponents
//
template<typename TComponentType, typename... Args>
void EcsController::AddComponents(T_EntityId const entity, TComponentType& component1, Args... args)
{
	std::vector<RawComponentPtr> components;
{'fraction_non_alphanumeric': 0.19755083179297597, 'fraction_numerical': 0.0036968576709796672, 'mean_word_length': 3.8915254237288135, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5135902', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1176, 'n_words': 279}