diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:28:15 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:28:15 +0000 |
commit | d4ee190ca1d37174da5692a3f391e12d46fe6ea5 (patch) | |
tree | c45c9002968f17fffe5bbc29a5e84dcca83bc234 /src/core | |
parent | 0d9a69607e7538dc46e685ef8e18b5fa343b6241 (diff) |
Cleaned up slots API.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/slot.cc | 35 | ||||
-rw-r--r-- | src/core/slot.h | 101 | ||||
-rw-r--r-- | src/core/slots.cc | 13 | ||||
-rw-r--r-- | src/core/slots.h | 6 |
4 files changed, 20 insertions, 135 deletions
diff --git a/src/core/slot.cc b/src/core/slot.cc index e1ccd05..e842f78 100644 --- a/src/core/slot.cc +++ b/src/core/slot.cc @@ -17,11 +17,6 @@ Slot::Slot() slot_flags = 0; slot_timestamp = 0; slot_last_fired = 0; - - slot_projectile_interval = 0;; - slot_projectile_lifespan = 0; - slot_projectile_speed = 0.0f; - slot_projectile_damage = 0.0f; } Slot::~Slot() @@ -40,36 +35,6 @@ void Slot::unset_flag(const Flags flag) set_timestamp(game() ? game()->timestamp() : 1); } -void Slot::set_projectile_speed(const float projectile_speed) -{ - slot_projectile_speed = projectile_speed; - set_timestamp(game() ? game()->timestamp() : 1); -} - -void Slot::set_projectile_interval(unsigned long projectile_interval) -{ - slot_projectile_interval = projectile_interval; - set_timestamp(game() ? game()->timestamp() : 1); -} - -void Slot::set_projectile_lifespan(unsigned long projectile_lifespan) -{ - slot_projectile_lifespan = projectile_lifespan; - set_timestamp(game() ? game()->timestamp() : 1); -} - -void Slot::set_projectile_damage(const float projectile_damage) -{ - slot_projectile_damage = projectile_damage; - set_timestamp(game() ? game()->timestamp() : 1); -} - -void Slot::set_projectile_modelname(const std::string & projectile_modelname) -{ - slot_projectile_modelname.assign(projectile_modelname); - set_timestamp(game() ? game()->timestamp() : 1); -} - void Slot::set_item(Item *item) { slot_item = item; diff --git a/src/core/slot.h b/src/core/slot.h index 5cfeb3e..56ee224 100644 --- a/src/core/slot.h +++ b/src/core/slot.h @@ -83,55 +83,6 @@ public: { return slot_last_fired; } - - /** - * @brief timestamp indicating when the slot was last fire, client-side - * This is a client-side property - * */ - inline unsigned long last_ejected() const - { - return slot_last_ejected; - } - - /** - * @brief interval between two consequtive shots by this slot, in milliseconds - * */ - inline unsigned long projectile_interval() const - { - return slot_projectile_interval; - } - - /** - * @brief lifespan of a projectile generated by this slot, in milliseconds - * */ - inline unsigned long projectile_lifespan() const - { - return slot_projectile_lifespan; - } - - /** - * @brief speed of a projectile generated by this slot, in game units per second - * */ - inline float projectile_speed() const - { - return slot_projectile_speed; - } - - /** - * @brief damage done by a projectile generated by this slot - * */ - inline float projectile_damage() const - { - return slot_projectile_damage; - } - - /** - * @brief model name used to draw projectiles generated by this slot - * */ - inline const std::string & projectile_modelname() const - { - return slot_projectile_modelname; - } /* --- mutators -------------------------------------------- */ @@ -178,40 +129,7 @@ public: { slot_last_fired = last_fired; } - - /** - * @brief set the timestamp when the slat last ejected a projectile, client-side - * This is a client-side property, to be set by the client - * */ - inline void set_last_ejected(unsigned long last_ejected) - { - slot_last_ejected = last_ejected; - } - - /** - * @brief set the interval between two shots, in milliseconds - * */ - void set_projectile_interval(unsigned long projectile_interval); - - /** - * @brief set the lifespan of ejected projectiles, in milliseconds - * */ - void set_projectile_lifespan(unsigned long projectile_lifespan); - - /** - * @brief set the speed of ejected projectiles, in game units per second - * */ - void set_projectile_speed(float projectile_speed); - - /** - * @brief set the amount of damage done by a projectile generated by this slot - * */ - void set_projectile_damage(float projectile_damage); - /** - * @brief set the name of model used to draw projectiles generated by this slot - * */ - void set_projectile_modelname(const std::string & projectile_modelname); - + /** * @brief set the item this slot is holding * */ @@ -231,23 +149,6 @@ private: // timestamp indicating when the slot last generated a projectile, server-side unsigned long slot_last_fired; - // timestamp indicating when the slot last generated a projectile, client-side - unsigned long slot_last_ejected; - - // interval between two shots, in milliseconds - unsigned long slot_projectile_interval; - - // projectile lifespan - unsigned long slot_projectile_lifespan; - - // projectile speed, in game units per second - float slot_projectile_speed; - - // projectile damage - float slot_projectile_damage; - - // name of the model used to draw projectiles generated by this slot - std::string slot_projectile_modelname; // item mounted in this slot Item *slot_item; diff --git a/src/core/slots.cc b/src/core/slots.cc index 9bf557f..12f6208 100644 --- a/src/core/slots.cc +++ b/src/core/slots.cc @@ -41,6 +41,19 @@ void Slots::clear() slots_container.clear(); } +Slot *Slots::find(Item *item) +{ + for (iterator it = slots_container.begin(); it != slots_container.end(); ++it) + { + if ((*it)->item() == item) { + return (*it); + } + } + + return 0; + +} + } // namespace core diff --git a/src/core/slots.h b/src/core/slots.h index 6bb09f1..aefffb7 100644 --- a/src/core/slots.h +++ b/src/core/slots.h @@ -37,6 +37,12 @@ public: * */ void clear(); + /** + * @brief found a mounted item + * */ + Slot *find(Item *item); + + inline iterator begin() { return slots_container.begin(); } |