diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index e4be8d78..79f90f33 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -2,6 +2,7 @@ #define EntityWrapper_h__ #include +#include #include "ComponentWrapper.h" class World; @@ -26,9 +27,23 @@ struct EntityWrapper bool Valid(); ComponentWrapper operator[](const char* componentName); - bool operator==(const EntityWrapper& e); + bool operator==(const EntityWrapper& e) const; explicit operator EntityID() const; operator bool(); }; +namespace std +{ + template<> struct hash + { + std::size_t operator()(const EntityWrapper& e) const + { + std::size_t seed = 0; + boost::hash_combine(seed, e.World); + boost::hash_combine(seed, e.ID); + return seed; + } + }; +} + #endif diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index c3c5cf27..8c1ab10d 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -3,7 +3,7 @@ const EntityWrapper EntityWrapper::Invalid = EntityWrapper(nullptr, EntityID_Invalid); -bool EntityWrapper::operator==(const EntityWrapper& e) +bool EntityWrapper::operator==(const EntityWrapper& e) const { return (this->World == e.World) && (this->ID == e.ID); }