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-07-28 19:37:31 +0000
committerStijn Buys <ingar@osirion.org>2008-07-28 19:37:31 +0000
commitd389a31f9816b55d8c7685ec24b9ab814252d693 (patch)
tree9b2577692e543fa6c59fcda508f92c3eb839ac7a /src/core/entity.h
parent17408276791033e8122819185abf3bcb01740105 (diff)
zone support
Diffstat (limited to 'src/core/entity.h')
-rw-r--r--src/core/entity.h65
1 files changed, 44 insertions, 21 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index d6000b9..ca2d029 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -25,6 +25,7 @@ class EntityControlable;
#include "core/clientstate.h"
#include "core/player.h"
+#include "core/zone.h"
namespace core
{
@@ -48,7 +49,7 @@ public:
/// create a new entity and add it to the registry
Entity(unsigned int flags = 0);
- /// create an entity froms stream data
+ /// create an entity from stream data
Entity(std::istream & is);
/// destroy an entity
@@ -83,6 +84,9 @@ public:
/// pointer to the model, is used client-side
inline model::Model * model() { return entity_model; }
+ /// pointer to the zone the entity belongs to
+ inline Zone *zone() const { return entity_zone; }
+
/// dirty flag
inline bool dirty() const { return entity_dirty; }
@@ -117,13 +121,13 @@ public:
/*----- mutators -------------------------------------------------- */
/// receive a client-to-server update from a stream
- virtual void recieve_client_update(std::istream &is);
+ virtual void receive_client_update(std::istream &is);
/// receive a server-to-client update from a stream
- virtual void recieve_server_update(std::istream &is);
+ virtual void receive_server_update(std::istream &is);
/// mark the entity as destroyed
- inline void die() { entity_destroyed = true; }
+ void die();
/// runs one game frame for the entity
/**
@@ -131,23 +135,30 @@ public:
*/
virtual void frame(float seconds);
+ /// set the zone the entity is currently in
+ /**
+ * this fuction removes the entity from its previous zone
+ * and removes it to the new one, if it is not 0
+ */
+ virtual void set_zone(Zone *zone);
+
/*----- static ---------------------------------------------------- */
/// type definition for the entity registry
typedef std::map<unsigned int, Entity*> Registry;
- /// the entity registry
- static Registry registry;
-
/// find an entity in the registry
static Entity *find(unsigned int id);
- /// remove one entity from the registry and deletes it
- static void remove(unsigned int entity_id);
+ /// erase an entity from the registry and delete it
+ static void erase(unsigned int entity_id);
/// list the entity registry
static void list();
+ /// the entity registry
+ static inline Registry & registry() { return entity_registry; }
+
/* entity_ variables can be set by the module */
math::Vector3f entity_location;
math::Axis entity_axis;
@@ -172,15 +183,23 @@ public:
ClientState *entity_clientstate;
+protected:
+ // the zone the entity belongs to
+ Zone *entity_zone;
+
private:
- /// add an entity to the registry
+ // add an entity to the registry
static void add(Entity *ent);
- /// add an entity with id to the registry
- void add(Entity *ent, unsigned int id);
+ // add an entity to the registry
+ static void add(Entity *ent, unsigned int it);
- /// the id is set by add()
+ // the id is set by add()
unsigned int entity_id;
+
+
+ // the entity registry
+ static Registry entity_registry;
};
@@ -216,10 +235,10 @@ public:
/*----- mutators -------------------------------------------------- */
/// receive a client-to-server update from a stream
- virtual void recieve_client_update(std::istream &is);
+ virtual void receive_client_update(std::istream &is);
/// receive a server-to-client update from a stream
- virtual void recieve_server_update(std::istream &is);
+ virtual void receive_server_update(std::istream &is);
/// runs one game frame for the entity
/**
@@ -235,9 +254,11 @@ public:
/// an entity that can be controlled by a player
class EntityControlable : public EntityDynamic
{
+ friend class Player;
+
public:
/// create a controlable entity
- EntityControlable(Player *player, unsigned int flags = 0);
+ EntityControlable(Player *owner, unsigned int flags = 0);
/// create a controlable entity from stream data
EntityControlable(std::istream & is);
@@ -269,10 +290,10 @@ public:
/*----- mutators -------------------------------------------------- */
/// receive a client-to-server update from a stream
- virtual void recieve_client_update(std::istream &is);
+ virtual void receive_client_update(std::istream &is);
/// receive a server-to-client update from a stream
- virtual void recieve_server_update(std::istream &is);
+ virtual void receive_server_update(std::istream &is);
/// set the target thrust
void set_thrust(float thrust);
@@ -293,9 +314,6 @@ public:
*/
virtual void frame(float seconds);
- /* entity_ variables can be set by the module */
- /// owner of the entity
- Player *entity_owner;
/// current thrust
float entity_thrust;
@@ -314,6 +332,11 @@ public:
/** target_roll must be in the [-1, 1] range
*/
float target_roll;
+
+private:
+ // owner of the entity
+ Player *entity_owner;
+
};
/// a Globe entity