Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/entity.cc16
-rw-r--r--src/core/entity.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 8ea0db5..63fa4e8 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -62,12 +62,24 @@ void Entity::add(Entity *ent, unsigned int id)
Entity *Entity::find(unsigned int id)
{
Registry::iterator it = entity_registry.find(id);
- if (it == entity_registry.end())
+ if (it == entity_registry.end()) {
return 0;
- else
+ } else {
return (*it).second;
+ }
+}
+
+Entity *Entity::find(Entity * entity)
+{
+ for (Registry::iterator it = entity_registry.begin(); it != entity_registry.end(); ++it) {
+ if ((*it).second == entity) {
+ return entity;
+ }
+ }
+ return 0;
}
+
void Entity::erase(unsigned int id)
{
Registry::iterator it = entity_registry.find(id);
diff --git a/src/core/entity.h b/src/core/entity.h
index 90f350e..140f6ca 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -471,6 +471,9 @@ public:
/// find an entity in the registry
static Entity *find(unsigned int id);
+
+ /// find an entity in the registry
+ static Entity *find(Entity * entity);
/// add an entity to the registry
static void add(Entity *ent, unsigned int it);