#include <utility>
#include <vector>
#include <type_traits>
+ #include <functional>
#include "entityx/help/Pool.h"
#include "entityx/config.h"
template <typename C, typename EM = EntityManager>
class ComponentHandle;
+
+
/** A convenience handle around an Entity::Id.
*
* If an entity is destroyed, any copies will be invalidated. Use valid() to
} // namespace entityx
+
+
+namespace std {
+template <> struct hash<entityx::Entity> {
+ std::size_t operator () (const entityx::Entity &entity) const {
+ return static_cast<std::size_t>(entity.id().index() ^ entity.id().version());
+ }
+};
+}
+
template <typename E, typename Receiver>
void unsubscribe(Receiver &receiver) {
BaseReceiver &base = receiver;
- //Assert that it has been subscribed before
+ // Assert that it has been subscribed before
assert(base.connections_.find(Event<E>::family()) != base.connections_.end());
auto pair = base.connections_[Event<E>::family()];
auto connection = pair.second;
// Functor used as an event signal callback that casts to E.
template <typename E>
struct EventCallbackWrapper {
- EventCallbackWrapper(std::function<void(const E &)> callback) : callback(callback) {}
+ explicit EventCallbackWrapper(std::function<void(const E &)> callback) : callback(callback) {}
void operator()(const void *event) { callback(*(static_cast<const E*>(event))); }
std::function<void(const E &)> callback;
};