From 1f95c377b2abfaa454b1f2298af10956d95ad941 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 13 Feb 2008 00:40:59 +0000 Subject: split client from game module --- src/core/entity.h | 91 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 18 deletions(-) (limited to 'src/core/entity.h') 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 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 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__ + -- cgit v1.2.3