summaryrefslogtreecommitdiff
path: root/src/game-server/entity.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/entity.h')
-rw-r--r--src/game-server/entity.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/game-server/entity.h b/src/game-server/entity.h
index bb76e440..b67b8063 100644
--- a/src/game-server/entity.h
+++ b/src/game-server/entity.h
@@ -25,6 +25,7 @@
#include "common/manaserv_protocol.h"
#include "game-server/component.h"
+#include "game-server/idmanager.h"
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
@@ -48,6 +49,7 @@ class Entity : public sigc::trackable
virtual ~Entity();
+ unsigned getId() const;
EntityType getType() const;
template <class T> void addComponent(T *component);
@@ -71,13 +73,31 @@ class Entity : public sigc::trackable
private:
Component *getComponent(ComponentType type) const;
+ unsigned mId;
MapComposite *mMap; /**< Map the entity is on */
EntityType mType; /**< Type of this entity. */
Component *mComponents[ComponentTypeCount];
+
+ static IdManager<Entity> mIdManager;
+
+ friend Entity *findEntity(unsigned id);
};
/**
+ * Looks up an entity by its ID, returns null if there is no such entity.
+ */
+inline Entity *findEntity(unsigned id)
+{
+ return Entity::mIdManager.find(id);
+}
+
+inline unsigned Entity::getId() const
+{
+ return mId;
+}
+
+/**
* Gets type of this entity.
*
* @return the type of this entity.