Hazel icon indicating copy to clipboard operation
Hazel copied to clipboard

AllComponents should maybe be a template.

Open Sebanisu opened this issue 4 years ago • 0 comments

https://github.com/TheCherno/Hazel/blob/d87b9b460d4c1508d7bf6510825357c9d9f2d31d/Hazel/src/Hazel/Scene/Components.h#L138-L147

I was just thinking if we made AllComponents into a template.

	template<typename... Component>
	using AllComponents = ComponentGroup
	<
		TransformComponent,
		SpriteRendererComponent,
		CircleRendererComponent,
		CameraComponent,
		NativeScriptComponent,
		Rigidbody2DComponent,
		BoxCollider2DComponent,
		Component...
	>;

We could add Components like TagComponent or IDComponent where needed.

// This requires empty set of <> when not setting anything extra.
		CopyComponent(AllComponents<>{}, dstSceneRegistry, srcSceneRegistry, enttMap);
// But you could do this when you wanted to.
		CopyComponent(AllComponents<TagComponent>{}, dstSceneRegistry, srcSceneRegistry, enttMap);

Or we could create another using declaration that contains IDComponent and TagComponent.

	template<typename... Component>
	using TrueAllComponents = AllComponents
	<
		IDComponent,
		TagComponent,
		Component...
	>;

Or we could use something like: CommonComponents That we could extend on a as needed basis and AllComponents could remain the the way it is.

	template<typename... Component>
	using CommonComponents = ComponentGroup
	<
		TransformComponent,
		SpriteRendererComponent,
		CircleRendererComponent,
		CameraComponent,
		NativeScriptComponent,
		Rigidbody2DComponent,
		BoxCollider2DComponent,
		Component...
	>;
	using AllComponents = CommonComponents<>;

Sebanisu avatar Sep 30 '21 18:09 Sebanisu