diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-11 20:56:30 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-11 20:56:30 +0000 |
commit | 7bec374404aa1a0b30c220aee49b4a9890437f75 (patch) | |
tree | 8800c5623039b59bd781d4310e0c9c966e3b2b8e /src/core | |
parent | 89d8f7f384dcd6c201288bf6fe86ab19e59e1a5c (diff) |
Cleaned up core::EntyControlable client-side and server-side proprties API.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/entity.cc | 40 | ||||
-rw-r--r-- | src/core/entity.h | 87 |
2 files changed, 70 insertions, 57 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 78878f9..feff172 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -1000,7 +1000,7 @@ void EntityControlable::ActionInterface::debugDraw(btIDebugDraw* debugDrawer) EntityControlable::EntityControlable() : EntityDynamic() { entity_thrust = 0; - entity_control_flags = 0; + entity_controlflags = 0; target_direction = 0.0f; target_thrust = 0.0f; @@ -1008,6 +1008,7 @@ EntityControlable::EntityControlable() : EntityDynamic() target_roll = 0.0f; target_strafe = 0.0f; target_afterburner = 0.0f; + target_controlflags = 0; entity_owner = 0; @@ -1018,7 +1019,7 @@ EntityControlable::EntityControlable(std::istream & is) : EntityDynamic(is) { entity_thrust = 0; - entity_control_flags = 0; + entity_controlflags = 0; target_direction = 0.0f; target_thrust = 0.0f; @@ -1026,6 +1027,7 @@ EntityControlable::EntityControlable(std::istream & is) : target_roll = 0.0f; target_strafe = 0.0f; target_afterburner = 0.0f; + target_controlflags = 0; entity_owner = 0; @@ -1056,6 +1058,14 @@ void EntityControlable::set_owner(Player *owner) } +void EntityControlable::set_thrust(float thrust) +{ + if (entity_thrust != thrust) { + entity_thrust = thrust; + set_dirty(); + } +} + void EntityControlable::serialize_server_create(std::ostream & os) const { EntityDynamic::serialize_server_create(os); @@ -1098,7 +1108,7 @@ void EntityControlable::serialize_client_update(std::ostream & os) const os << target_strafe << " "; os << target_vstrafe << " "; os << target_afterburner << " "; - os << entity_control_flags << " "; + os << target_controlflags << " "; } void EntityControlable::receive_client_update(std::istream &is) @@ -1111,7 +1121,7 @@ void EntityControlable::receive_client_update(std::istream &is) is >> target_strafe; is >> target_vstrafe; is >> target_afterburner; - is >> entity_control_flags; + is >> target_controlflags; } void EntityControlable::serialize_server_update(std::ostream & os) const @@ -1127,7 +1137,7 @@ void EntityControlable::receive_server_update(std::istream &is) entity_thrust /= 100.0f; } -void EntityControlable::set_thrust(float thrust) +void EntityControlable::set_target_thrust(float thrust) { if (thrust != target_thrust) { target_thrust = thrust; @@ -1135,7 +1145,7 @@ void EntityControlable::set_thrust(float thrust) } } -void EntityControlable::set_direction(float direction) +void EntityControlable::set_target_direction(float direction) { if (target_direction != direction) { target_direction = direction; @@ -1143,7 +1153,7 @@ void EntityControlable::set_direction(float direction) } } -void EntityControlable::set_pitch(float pitch) +void EntityControlable::set_target_pitch(float pitch) { if (target_pitch != pitch) { target_pitch = pitch; @@ -1151,7 +1161,7 @@ void EntityControlable::set_pitch(float pitch) } } -void EntityControlable::set_roll(float roll) +void EntityControlable::set_target_roll(float roll) { if (target_roll != roll) { target_roll = roll; @@ -1159,7 +1169,7 @@ void EntityControlable::set_roll(float roll) } } -void EntityControlable::set_strafe(float strafe) +void EntityControlable::set_target_strafe(float strafe) { if (target_strafe != strafe) { target_strafe = strafe; @@ -1167,7 +1177,7 @@ void EntityControlable::set_strafe(float strafe) } } -void EntityControlable::set_vstrafe(float vstrafe) +void EntityControlable::set_target_vstrafe(float vstrafe) { if (target_vstrafe != vstrafe) { target_vstrafe = vstrafe; @@ -1183,7 +1193,7 @@ void EntityControlable::set_target_aim(const math::Vector3f &aim) } } -void EntityControlable::set_afterburner(float afterburner) +void EntityControlable::set_target_afterburner(float afterburner) { if (target_afterburner != afterburner) { target_afterburner = afterburner; @@ -1191,6 +1201,14 @@ void EntityControlable::set_afterburner(float afterburner) } } +void EntityControlable::set_target_controlflags(int controlflags) +{ + if (target_controlflags != controlflags) { + target_controlflags = controlflags; + set_dirty(); + } +} + void EntityControlable::set_zone(Zone *zone) { if (entity_zone == zone) diff --git a/src/core/entity.h b/src/core/entity.h index 092f4a7..72553fa 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -698,13 +698,13 @@ public: } /// control flags - inline int control_flags() const { - return entity_control_flags; + inline int controlflags() const { + return entity_controlflags; } /// returns true if the specified control flag is set - inline bool control_has_flag(ControlFlags flag) const { - return ((flag && entity_control_flags) == flag); + inline bool has_controlflag(ControlFlags flag) const { + return ((flag && entity_controlflags) == flag); } /// physics action @@ -724,27 +724,39 @@ public: virtual void serialize_server_update(std::ostream & os) const; /*----- mutators -------------------------------------------------- */ + + /// set the target thrust + void set_target_thrust(float thrust); + + /// set the target direction + void set_target_direction(float direction); + + /// set the target pitch + void set_target_pitch(float pitch); + + /// set target roll + void set_target_roll(float roll); + + /// set target strafe + void set_target_strafe(float strafe); - /// set all control flags - inline void set_control_flags(int control_flags) { - entity_control_flags = control_flags; - } - - /// set a single control flag - inline void set_control_flag(ControlFlags control_flag) { - entity_control_flags |= control_flag; - } + /// set target vertical strafe + void set_target_vstrafe(float vstrafe); - /// unset a single control flag - inline void unset_control_flag(ControlFlags control_flag) { - entity_control_flags &= ~control_flag; - } + /// set target afterburner/reverse + void set_target_afterburner(float afterburner); + + /// set target aim + void set_target_aim(const math::Vector3f &aim); + + /// set target controlflags + void set_target_controlflags(int controlflags); /** * @brief 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); /** @@ -763,30 +775,9 @@ public: /// set the player who owns this entity void set_owner(Player *owner); - - /// set the target thrust - void set_thrust(float thrust); - - /// set the target direction - void set_direction(float direction); - - /// set the target pitch - void set_pitch(float pitch); - - /// set target roll - void set_roll(float roll); - - /// set target strafe - void set_strafe(float strafe); - - /// set target vertical strafe - void set_vstrafe(float vstrafe); - - /// set afterburner/reverse - void set_afterburner(float afterburner); - /// set aim - void set_target_aim(const math::Vector3f &aim); + /// set thrust + void set_thrust(float thrust); /** * @brief runs one game frame for the entity @@ -796,14 +787,17 @@ public: */ virtual void frame(const unsigned long elapsed); - /// current thrust - float entity_thrust; - protected: /// physics action interface callback virtual void action (btScalar seconds); + /// current control flags + int entity_controlflags; + + /// current thrust + float entity_thrust; + /* target_ variables can be set by the client */ /** @@ -837,13 +831,14 @@ protected: math::Vector3f target_aim; - int entity_control_flags; + int target_controlflags; ActionInterface *entity_actioninterface; private: - // owner of the entity + /// owner of the entity Player *entity_owner; + }; /// a Globe entity |