From afec8e7c3aec1a186512b997ed3b717efef8fc43 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 11 Feb 2008 00:19:11 +0000 Subject: renamed Entity.base_* to Entity.core_* fixed camera::mode::Overview --- src/core/entity.cc | 25 +++++++++++++------------ src/core/entity.h | 45 +++++++++++++++++++++++++++------------------ src/core/gameinterface.h | 7 ++++++- 3 files changed, 46 insertions(+), 31 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.cc b/src/core/entity.cc index 3854fd0..b0808fb 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -13,16 +13,16 @@ namespace core // --- Entity ----------------------------------------------------- -Entity::Entity(unsigned int entity_flags, unsigned int entity_type) +Entity::Entity(unsigned int entity_flags) { flags = entity_flags; - type = entity_type; - - base_shape = entity::Diamond; - base_color = math::Color(1.0f, 1.0f, 1.0f); - base_radius = 1.0f; + + core_shape = entity::Diamond; + core_color = math::Color(1.0f, 1.0f, 1.0f); + core_radius = 1.0f; core::entity::add(this); + type = 0; } @@ -31,8 +31,8 @@ Entity::~Entity() // --- EntityDynamic ------------------------------------------ -EntityDynamic::EntityDynamic(unsigned int entity_flags, unsigned int entity_type) : - Entity(entity_type, entity_flags), +EntityDynamic::EntityDynamic(unsigned int entity_flags) : + Entity(entity_flags), speed(0,0,0) { @@ -40,8 +40,8 @@ EntityDynamic::EntityDynamic(unsigned int entity_flags, unsigned int entity_type // --- EntityControlable ------------------------------------------ -EntityControlable::EntityControlable(unsigned int entity_flags, unsigned int entity_type) : - EntityDynamic(entity_type, entity_flags) +EntityControlable::EntityControlable(unsigned int entity_flags) : + EntityDynamic(entity_flags) { owner = 0; } @@ -90,8 +90,9 @@ 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(3) << (*it)->type + con_print << " id " << std::setw(4) << (*it)->id + << " type " << std::setw(4) << (*it)->core_type() + << ":" << std::setw(4) << (*it)->type << " " << (*it)->label << std::endl; } con_print << registry.size() << " registered entities" << std::endl; diff --git a/src/core/entity.h b/src/core/entity.h index 518166b..62b8a39 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -34,41 +34,47 @@ class Entity { public: /// create a new entity and add it to the registry - Entity(unsigned int entity_flags = 0, unsigned int entity_type = entity::Default); + Entity(unsigned int entity_flags = 0); virtual ~Entity(); - /// id of the entity - unsigned int id; + /// core type of this entity + virtual inline unsigned int core_type() { return entity::Default; } - /// flags - unsigned int flags; - - /// type - unsigned int type; - - /// base shape - entity::Shape base_shape; + /// core shape + entity::Shape core_shape; - /// base color - math::Color base_color; + /// core color + math::Color core_color; - /// base radius - float base_radius; + /// 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 +/// an entity that can move around in the game world class EntityDynamic : public Entity { public: - EntityDynamic(unsigned int entity_flags = 0, unsigned int entity_type=entity::Dynamic); + EntityDynamic(unsigned int entity_flags = 0); + + /// core type of this entity + virtual inline unsigned int core_type() { return entity::Dynamic; } /* updateable */ @@ -80,7 +86,10 @@ public: class EntityControlable : public EntityDynamic { public: - EntityControlable(unsigned int entity_flags = 0, unsigned int entity_type=entity::Controlable); + 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; diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index 2e61ffb..b7df479 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -7,6 +7,8 @@ #ifndef __INCLUDED_CORE_GAMEINTERFACE_H__ #define __INCLUDED_CORE_GAMEINTERFACE_H__ +#include "core/player.h" + namespace core { @@ -26,12 +28,15 @@ public: /// shutdown the game virtual void shutdown() = 0; - + /// run one frame of the game /** @param sec time since the previous frame, in seconds */ virtual void frame(float seconds) = 0; + /// a player joins the game + virtual void event_join(Player *player) = 0; + /// a pointer to the current game instance static GameInterface * instance(); -- cgit v1.2.3