From 7a373c3f1fb8ea9dbef7690154bbe332fc386eca Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 18 Oct 2010 23:41:41 +0000 Subject: bullet ActionInterface for controlable entities, KeepAlive flag and g_keepalive --- src/core/entity.h | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'src/core/entity.h') 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 -- cgit v1.2.3