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>2010-10-18 23:41:41 +0000
committerStijn Buys <ingar@osirion.org>2010-10-18 23:41:41 +0000
commit7a373c3f1fb8ea9dbef7690154bbe332fc386eca (patch)
treee56652c9b6197017d7eb8e86e5cd431bf9861d57 /src/core/entity.h
parent4c5b00221c9405c5af06143974fbc6296ebe46b5 (diff)
bullet ActionInterface for controlable entities, KeepAlive flag and g_keepalive
Diffstat (limited to 'src/core/entity.h')
-rw-r--r--src/core/entity.h53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 057ffb2..f6ee1d7 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -41,8 +41,10 @@ class Entity : public Label
friend class Extension;
public:
- /// Entity flags
- enum Flags {Static = 1, Solid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16};
+ /**
+ * @brief entity flags
+ */
+ enum Flags {Static = 1, Solid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32};
/// Entity type constants
enum Type {Default = 0, Dynamic = 1, Controlable = 2, Globe = 3};
@@ -492,7 +494,17 @@ public:
return entity_timer;
}
-/*----- mutators -------------------------------------------------- */
+ /// time when the entity was last alive
+ inline const float keepalive_time() const {
+ return entity_keepalive_time;
+ }
+
+ /// keepalive timeout
+ inline const float keepalive_timeout() const {
+ return entity_keepalive_timeout;
+ }
+
+ /*----- mutators -------------------------------------------------- */
/// mass of the entity
inline void set_mass(const float mass) {
@@ -528,6 +540,12 @@ public:
/// set event state
virtual void set_state(int state);
+
+ /// set the time when the entity was last alive, in game time seconds
+ void set_keepalive_time(float time);
+
+ /// set the timeout after which the entitie is deleted, in seconds
+ void set_keepalive_timeout(float timeout);
/// runs one game frame for the entity
/**
@@ -542,6 +560,8 @@ public:
virtual void reset();
protected:
+ float entity_keepalive_time;
+ float entity_keepalive_timeout;
float entity_timer;
int entity_state;
};
@@ -551,6 +571,20 @@ class EntityControlable : public EntityDynamic
{
friend class Player;
public:
+ /// bullet action interface class
+ class ActionInterface: public btActionInterface {
+ public:
+ ActionInterface(EntityControlable *entity);
+ virtual ~ActionInterface();
+
+ virtual void updateAction( btCollisionWorld* collisionWorld, btScalar deltaTimeStep);
+
+ virtual void debugDraw(btIDebugDraw* debugDrawer);
+
+ private:
+ EntityControlable *actioninterface_entity;
+ };
+
/// server-side constructor, create a controlable entity
EntityControlable();
@@ -581,9 +615,9 @@ public:
return entity_movement;
}
- /// physics vehicle container
- inline btRaycastVehicle *vehicle() {
- return entity_vehicle;
+ /// physics action
+ inline ActionInterface *actioninterface() {
+ return entity_actioninterface;
}
/*----- serializers ----------------------------------------------- */
@@ -655,6 +689,10 @@ public:
float entity_thrust;
protected:
+
+ /// physics action interface callback
+ virtual void action (btScalar seconds);
+
/* target_ variables can be set by the client */
/**
@@ -688,8 +726,7 @@ protected:
float entity_movement;
- btRaycastVehicle::btVehicleTuning entity_vehicletuning;
- btRaycastVehicle *entity_vehicle;
+ ActionInterface *entity_actioninterface;
private:
// owner of the entity