#pragma once
namespace engineapi{
	template<typename Res>
	inline Guid Resource<Res>::GetGuid() const
	{
		return GetHandle().guid;
	}
	struct GenericResourceHandle
		: variant_wrap_t<tuple_to_variant_t<Resources>, RscHandle>
	{
	private:
		using Base = variant_wrap_t<tuple_to_variant_t<Resources>, RscHandle>;
	public:
		using Base::Base;
		using Base::operator=;
		template<typename T>
		GenericResourceHandle(RscHandle<T> handle) : Base(RscHandle<typename T::BaseResource>{handle}) {}
		GenericResourceHandle(string_view type_name, Guid guid);
		template<typename T> RscHandle<T> AsHandle() const {
			return std::get<ResourceID<T>>(*this);
		}
		Guid   guid() const;
		size_t resource_id() const;
	};
}
// hashtable support
namespace std
{
	template<typename Res>
	struct hash <engineapi::RscHandle<Res>>
	{
		size_t operator()(const engineapi::RscHandle<Res>& res) const noexcept
		{
			return std::hash<engineapi::Guid>()(res.guid);
		}
	};
}
namespace refl {
	template<typename T>
	struct real_type<engineapi::RscHandle<T>> {
		using type = engineapi::RscHandleBase;
	};
}