Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/entity.h')
-rw-r--r--src/core/entity.h78
1 files changed, 65 insertions, 13 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 3ba2b0c..2719040 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -28,6 +28,7 @@ class EntityControlable;
#include "core/descriptions.h"
#include "core/inventory.h"
#include "core/label.h"
+#include "core/physics.h"
#include "core/player.h"
#include "core/zone.h"
@@ -146,11 +147,30 @@ public:
return entity_radius;
}
- /// current speed of the entity in game units per second
+ /**
+ * @brief current speed of the entity in game units per second
+ * For a normal entity, speed is always 0. Use the EntityDynamic
+ * and EntityControlable classes to create moving entities
+ */
inline const float speed() const {
return entity_speed;
}
+ /// mass of the entity
+ inline const float mass() const {
+ return entity_mass;
+ }
+
+ /// physics body
+ inline btRigidBody *body() {
+ return entity_body;
+ }
+
+ /// collision shape
+ inline btCollisionShape *collision_shape() {
+ return entity_collision_shape;
+ }
+
/// indicates a server-side entity
inline const bool serverside() const {
return entity_serverside;
@@ -234,11 +254,6 @@ public:
*/
virtual void set_zone(Zone *zone);
- /// current speed of the entity in game units per second
- inline void set_speed(const float speed) {
- entity_speed = speed;
- }
-
/// set visibility
inline void set_visible(const bool visible = true) {
entity_visible = visible;
@@ -259,10 +274,11 @@ public:
inline void set_radius(const float radius) {
entity_radius = radius;
}
-
-/* ---- actors ---------------------------------------------------- */
+
+ /* ---- actors ---------------------------------------------------- */
/// called when the entity received a docking request
+ // FIXME move docking functions to game
virtual void dock(Entity *entity);
/// set flags
@@ -275,6 +291,11 @@ public:
entity_flags &= ~flag;
}
+ /**
+ * @brief reset the physics state
+ */
+ virtual void reset();
+
/// add an entity menu
void add_menu(MenuDescription *menu);
@@ -318,7 +339,6 @@ public:
/**
* @brief mutable reference to the secondary color
*/
-
inline math::Color& get_color_second() {
return entity_color_second;
}
@@ -387,7 +407,7 @@ public:
/* entity_ variables can be set by the module */
- /// speed of the entity
+ float entity_mass;
float entity_speed;
Shape entity_shape;
unsigned int entity_moduletypeid;
@@ -398,8 +418,11 @@ public:
/// timestamp when entity data was received from the server
float entity_servertimestamp;
-private:
+protected:
+ btRigidBody *entity_body;
+ btCollisionShape *entity_collision_shape;
+private:
unsigned int entity_id;
unsigned int entity_flags;
@@ -430,7 +453,7 @@ private:
Info* entity_info;
Extension* entity_extension[4];
-
+
static Registry entity_registry;
static size_t entity_nextid;
@@ -466,6 +489,27 @@ public:
return entity_timer;
}
+ inline btMotionState *motionstate() {
+ return entity_motionstate;
+ }
+
+ /*----- mutators -------------------------------------------------- */
+
+ /// mass of the entity
+ inline void set_mass(const float mass) {
+ entity_mass = mass;
+ }
+
+ /// current speed of the entity in game units per second
+ inline void set_speed(const float speed) {
+ entity_speed = speed;
+ }
+
+ /**
+ * @brief reset the physics state
+ */
+ virtual void reset();
+
/*----- serializers ----------------------------------------------- */
/// serialize the entity to a stream
@@ -501,6 +545,9 @@ public:
protected:
float entity_timer;
int entity_state;
+
+ btMotionState *entity_motionstate;
+
};
@@ -577,7 +624,10 @@ public:
void set_roll(float roll);
/// set target strafe
- void set_strafe(float strage);
+ void set_strafe(float strafe);
+
+ /// set target vertical strafe
+ void set_vstrafe(float vstrafe);
/// set afterburner/reverse
void set_afterburner(float afterburner);
@@ -621,6 +671,8 @@ protected:
float target_afterburner;
float target_strafe;
+
+ float target_vstrafe;
float entity_movement;