From 6b737ea7f6e5a31d3c6024105ee11890f1a5451f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 14 Nov 2012 12:53:53 +0000 Subject: Added initial core::Slot attributes. --- src/core/slot.cc | 20 ++++++++++---- src/core/slot.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 87 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/slot.cc b/src/core/slot.cc index 1b3e648..89f885c 100644 --- a/src/core/slot.cc +++ b/src/core/slot.cc @@ -13,21 +13,31 @@ namespace core Slot::Slot() { slot_item = 0; + slot_active = true; + slot_timestamp = 0; } -Slot::Slot(const math::Vector3f &location) +Slot::Slot(const math::Vector3f & location) : + slot_location(location) { slot_item = 0; - slot_location.assign(location); + slot_active = true; + slot_timestamp = 0; + } - Slot::~Slot() { slot_item = 0; + slot_active = false; + slot_timestamp = 0; +} + +void Slot::set_item(Item *item) +{ + slot_item = item; + set_timestamp(game() ? game()->timestamp() : 1); } } // namespace core - - diff --git a/src/core/slot.h b/src/core/slot.h index e99f33c..d0f2fdc 100644 --- a/src/core/slot.h +++ b/src/core/slot.h @@ -12,37 +12,102 @@ #include "core/item.h" +#include + namespace core { /** - * @brief A single equipment or weapon slots + * @brief A mount point for a weapon or a piece of equipment * */ class Slot { public: + /** + * @brief default constructor + * Creates an empty slot + * */ Slot(); - Slot(const math::Vector3f &location); + /** + * @brief creates and empty slot at a given location + * */ + Slot(const math::Vector3f & location); + + /** + * @brief default destructor + * */ ~Slot(); - inline const math::Vector3f &location() { + /** + * @brief location of the slot within the parent model + * */ + inline const math::Vector3f & location() const + { return slot_location; } - - inline void set_item(Item *item) + /** + * @brief axis indication the slot's orientation + * */ + inline const math::Axis & axis() const { - slot_item = item; + return slot_axis; } + /** + * @brief the name of the particlesystem used to render + * projectiles generated by this slot + * */ + + + /* --- mutators -------------------------------------------- */ + + /** + * @brief set the slot's location + * */ inline void set_location(const math::Vector3f &location) { slot_location.assign(location); } + /** + * @brief set the slot's orientation + */ + inline void set_axis(const math::Axis & axis) + { + slot_axis.assign(axis); + } + + /** + * @brief set the slot's timestamp + * The timestamp indicates when the slot's configuration was last changed. + * */ + inline void set_timestamp(unsigned long timestamp) + { + slot_timestamp = timestamp; + } + + /** + * @brief set the item this slot is holding + * */ + inline void set_item(Item *item); + private: math::Vector3f slot_location; - Item *slot_item; + math::Axis slot_axis; + + unsigned long slot_timestamp; + // FIXME consolidate into slot_flags + bool slot_active; + + std::string slot_particlesystem_name; + + // fire rate, in projectiles per second + float slot_fire_rate; + // fire range, in game units + float slot_fire_range; + + Item *slot_item; }; } // namespace core -- cgit v1.2.3