Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 62b8a392a5ee755ea3638d3afcf7f77fa9020607 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
   core/entity.h
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2.
*/

#ifndef __INCLUDED_CORE_ENTITY_H__
#define __INCLUDED_CORE_ENTITY_H__

#include "core/core.h"
#include "core/player.h"
#include "math/mathlib.h"
#include <vector>

namespace core
{

namespace entity
{

/// Entity flags
enum Flags {Static=1, Solid=2};

/// Entity type constants
enum Type {Default = 0, Dynamic = 1, Controlable = 2};

/// Entity shaoe constants
enum Shape {Diamond=0, Sphere=1, Cube=2};

}

/// The base world entity. All gameworld entities must derive from this class.
class Entity
{
public:
	/// create a new entity and add it to the registry
	Entity(unsigned int entity_flags = 0);
	virtual ~Entity();
	
	/// core type of this entity
	virtual inline unsigned int core_type() { return entity::Default; }

	/// core shape
	entity::Shape core_shape;

	/// core color
	math::Color core_color;

	/// core radius
	float core_radius;
	
	/// label
	std::string label;

	/// custom game type of this entity
	unsigned int type;

	/// id of the entity
	unsigned int id;

	/// flags
	unsigned int flags;

	/* updateable */

	/// location of the entity
	math::Vector3f location;
};

/// an entity that can move around in the game world
class EntityDynamic : public Entity
{
public:
	EntityDynamic(unsigned int entity_flags = 0);

	/// core type of this entity
	virtual inline unsigned int core_type() { return entity::Dynamic; }

	/* updateable */

	/// speed vector, in game units / second
	math::Vector3f speed;
};

/// an entity that can be controlled by a player
class EntityControlable : public EntityDynamic
{
public:
	EntityControlable(unsigned int entity_flags = 0);

	/// core type of this entity
	virtual inline unsigned int core_type() { return entity::Controlable; }

	/// owner of this controllable entity
	Player *owner;
};


namespace entity
{

/// the entity registry
extern std::vector<Entity*> registry;

/// add an entity to the registry
void add(Entity *ent);

/// clear the entity registry
void clear();

/// list the entity registry
void list();
}

}

#endif // __INCLUDED_CORE_ENTITY_H__