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-13 00:40:59 +0000
committerStijn Buys <ingar@osirion.org>2008-02-13 00:40:59 +0000
commit1f95c377b2abfaa454b1f2298af10956d95ad941 (patch)
tree2715cf49a8de16921775eff0dc1ac0ceace145b2 /src/core/entity.h
parent468ab7f566ee493b8c7ff6a95763d99ed2ccc200 (diff)
split client from game module
Diffstat (limited to 'src/core/entity.h')
-rw-r--r--src/core/entity.h91
1 files changed, 73 insertions, 18 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 62b8a39..6ff3be1 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -7,9 +7,15 @@
#ifndef __INCLUDED_CORE_ENTITY_H__
#define __INCLUDED_CORE_ENTITY_H__
+namespace core
+{
+class EntityControlable;
+}
+
#include "core/core.h"
#include "core/player.h"
#include "math/mathlib.h"
+
#include <vector>
namespace core
@@ -24,7 +30,7 @@ enum Flags {Static=1, Solid=2};
/// Entity type constants
enum Type {Default = 0, Dynamic = 1, Controlable = 2};
-/// Entity shaoe constants
+/// Entity shape constants
enum Shape {Diamond=0, Sphere=1, Cube=2};
}
@@ -37,62 +43,103 @@ public:
Entity(unsigned int entity_flags = 0);
virtual ~Entity();
- /// core type of this entity
+ /**
+ * @brief core type id
+ */
virtual inline unsigned int core_type() { return entity::Default; }
- /// core shape
+ /// unique instance identifier, automaticly set
+ unsigned int id;
+
+ /// core shape id
entity::Shape core_shape;
- /// core color
+ /// core color id
math::Color core_color;
- /// core radius
+ /// core radius, in game units
float core_radius;
/// label
std::string label;
- /// custom game type of this entity
+ /// custom game type id of this entity
unsigned int type;
- /// id of the entity
- unsigned int id;
-
/// flags
unsigned int flags;
- /* updateable */
+ /* updateable by game */
/// location of the entity
math::Vector3f location;
+
+ /**
+ * @brief direction the entity is facing, in degrees
+ * A direction of 0 degrees means the entity is 'looking'
+ * along the positive X-axis.
+ */
+ float direction;
};
-/// an entity that can move around in the game world
+/**
+ * @brief an entity that can move around in the game world
+ */
class EntityDynamic : public Entity
{
public:
EntityDynamic(unsigned int entity_flags = 0);
+ virtual ~EntityDynamic();
- /// core type of this entity
+ /**
+ * @brief core type id
+ */
virtual inline unsigned int core_type() { return entity::Dynamic; }
- /* updateable */
+ /* updateable by game */
- /// speed vector, in game units / second
- math::Vector3f speed;
+ /**
+ * @brief current speed of the entity in game units per second
+ */
+ float speed;
};
-/// an entity that can be controlled by a player
+/**
+ * @brief an entity that can be controlled by a player
+ */
class EntityControlable : public EntityDynamic
{
public:
EntityControlable(unsigned int entity_flags = 0);
+ virtual ~EntityControlable();
- /// core type of this entity
+ /**
+ * @brief core type id
+ */
virtual inline unsigned int core_type() { return entity::Controlable; }
- /// owner of this controllable entity
+ /**
+ * @brief owner of this controllable entity
+ */
Player *owner;
+
+ /* updatable by client */
+
+ /**
+ * @brief the direction the client wants to travel the entity to
+ * @see direction
+ */
+ float target_direction;
+
+ /**
+ * @brief engine thrust as set by the client, 0.0f - 1.0f
+ */
+ float target_thrust;
+
+ /**
+ * @brief runs one game frame for the entity, to be implemented by game
+ */
+ virtual void frame(float seconds) = 0;
};
@@ -105,13 +152,21 @@ extern std::vector<Entity*> registry;
/// add an entity to the registry
void add(Entity *ent);
+/// remove one entity from the registry
+void remove(unsigned int entity_id);
+
/// clear the entity registry
void clear();
/// list the entity registry
void list();
+
+/// run a game frame on each entity in the registry
+void frame(float seconds);
+
}
}
#endif // __INCLUDED_CORE_ENTITY_H__
+