#pragma once

#include "ehs/EHS.h"
#include "ehs/Array.h"
#include "ehs/io/File.h"
#include "Mesh.h"
#include "Bone.h"
#include "Animation.h"

namespace ehs
{
	enum class ModelEncoding : UInt_8
	{
		EHM
	};

	class Model : public BaseObj
	{
	protected:
		UInt_64 hashId;
		Str_8 id;
		Array<Mesh> meshes;
		Bone skeleton;
		Array<Animation> animations;

	public:
		Model();

		Model(const Str_8& filePath);

		Model(Str_8 id, Array<Mesh> meshes, Bone skeleton, Array<Animation> animations);

		Model(Str_8 id, Array<Mesh> meshes, Bone skeleton);

		Model(Str_8 id, Array<Mesh> meshes);

		Model(Model&& model) noexcept;

		Model(const Model& model) = default;

		Model& operator=(Model&& model) noexcept;

		Model& operator=(const Model& model) = default;

		void Release();

		UInt_64 GetHashId() const;

		void SetId(Str_8 newId);

		Str_8 GetId() const;

		const Array<Mesh>& GetMeshes() const;

		Array<Mesh>& GetMeshes();

		Mesh* GetMesh(UInt_64 inHashId);

		Mesh* GetMesh(const Str_8& inId);

		const Bone& GetSkeleton() const;

		Bone& GetSkeleton();

		Animation* GetAnimation(UInt_64 inHashId);

		const Array<Animation>& GetAnimations() const;

		Array<Animation>& GetAnimations();

		void Calculate();

		void Export(const Str_8& filePath, ModelEncoding encoding);

	private:
		void ToEHM(File& file);

		void FromEHM(File& file);
	};
}