From 48aa068b036f565d6b94d4207242066ba655afe4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Feb 2008 17:48:16 +0000 Subject: entities, step 1 --- src/core/entity.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/core/entity.cc (limited to 'src/core/entity.cc') 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 + +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 registry; + +void add(Entity *ent) +{ + ent->id = (unsigned int) registry.size(); + registry.push_back(ent); +} + +void clear() +{ + std::vector::iterator it; + for (it=registry.begin(); it != registry.end(); it++) { + delete (*it); + (*it) = 0; + } + registry.clear(); +} + +void list() +{ + std::vector::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; +} +} + +} -- cgit v1.2.3