Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: c8736da085620bf877ced9366870066d1653fc15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
}
}

}