Core/ApplicationBase: Fix GetComponent
This commit is contained in:
parent
e5da020b55
commit
03ff328b5b
|
|
@ -61,7 +61,7 @@ namespace Nz
|
||||||
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
||||||
|
|
||||||
auto it = m_components.find(typeHash);
|
auto it = m_components.find(typeHash);
|
||||||
if (it != m_components.end())
|
if (it == m_components.end())
|
||||||
throw std::runtime_error("component not found");
|
throw std::runtime_error("component not found");
|
||||||
|
|
||||||
return static_cast<T&>(*it->second);
|
return static_cast<T&>(*it->second);
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Nz
|
||||||
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
||||||
|
|
||||||
auto it = m_components.find(typeHash);
|
auto it = m_components.find(typeHash);
|
||||||
if (it != m_components.end())
|
if (it == m_components.end())
|
||||||
throw std::runtime_error("component not found");
|
throw std::runtime_error("component not found");
|
||||||
|
|
||||||
return static_cast<const T&>(*it->second);
|
return static_cast<const T&>(*it->second);
|
||||||
|
|
@ -83,12 +83,7 @@ namespace Nz
|
||||||
bool ApplicationBase::HasComponent() const
|
bool ApplicationBase::HasComponent() const
|
||||||
{
|
{
|
||||||
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
constexpr UInt64 typeHash = FNV1a64(TypeName<T>());
|
||||||
|
return m_components.contains(typeHash);
|
||||||
auto it = m_components.find(typeHash);
|
|
||||||
if (it != m_components.end())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return it->second != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ApplicationBase::Quit()
|
inline void ApplicationBase::Quit()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue