Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
committerStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
commit48aa068b036f565d6b94d4207242066ba655afe4 (patch)
tree4b68cf169c7fcd4bc6f2eecc7c072830d91830f8 /src/core/entity.cc
parent23aee34002facf39b56d209320817375db3b6189 (diff)
entities, step 1
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
new file mode 100644
index 0000000..c8736da
--- /dev/null
+++ b/src/core/entity.cc
@@ -0,0 +1,56 @@
+/*
+ core/entity.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2.
+*/
+
+#include "sys/sys.h"
+#include "core/entity.h"
+#include <iomanip>
+
+namespace core
+{
+
+Entity::Entity(unsigned int entity_type, unsigned int entity_flags)
+{
+ flags = entity_flags;
+ type = entity_type;
+ core::entity::add(this);
+}
+
+Entity::~Entity()
+{
+}
+
+namespace entity
+{
+
+std::vector<Entity*> registry;
+
+void add(Entity *ent)
+{
+ ent->id = (unsigned int) registry.size();
+ registry.push_back(ent);
+}
+
+void clear()
+{
+ std::vector<Entity *>::iterator it;
+ for (it=registry.begin(); it != registry.end(); it++) {
+ delete (*it);
+ (*it) = 0;
+ }
+ registry.clear();
+}
+
+void list()
+{
+ std::vector<Entity *>::iterator it;
+ for (it=registry.begin(); it != registry.end(); it++) {
+ con_print << " id " << std::setw(3) << (*it)->id << " type " << std::setw(2) << (*it)->type << std::endl;
+ }
+ con_print << registry.size() << " registered entities" << std::endl;
+}
+}
+
+}