/* core/slot.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2. */ #ifndef __INCLUDED_CORE_SLOT_H__ #define __INCLUDED_CORE_SLOT_H__ #include "math/vector3f.h" #include "math/axis.h" #include "core/item.h" #include "model/tags.h" #include namespace core { /** * @brief A mount point for a weapon or a piece of equipment * */ class Slot { public: enum Flags {None = 0, Mounted = 1, Active = 2}; /** * @brief default constructor * Creates an empty slot * */ Slot(); /** * @brief default destructor * */ ~Slot(); /** * @brief load slot configuration from a model slot * */ void load(const model::Slot *slot_tag, const float modelscale); /** * @brief clear slot values * */ void clear(); /** * @brief location of the slot within the parent model * */ inline const math::Vector3f & location() const { return slot_location; } /** * @brief axis indication the slot's orientation * */ inline const math::Axis & axis() const { return slot_axis; } /** * @brief slot flags * */ inline const unsigned int flags() const { return slot_flags; } /** * @brief return true if a specified flag is set * */ inline const bool has_flag(const Flags flag) { return ( (slot_flags & flag) == (unsigned int) flag ); } /** * @brief the item this slot is holding * */ inline core::Item *item() { return slot_item; } /** * @brief timestamp indicating when the slot was last fired,server-side * This is a server-side property * */ inline unsigned long last_fired() const { return slot_last_fired; } /** * @brief slot radius * */ inline const float radius() const { return slot_radius; } /** * @brief slot fire cone, in degrees * */ inline const float cone() const { return slot_cone; } /** * @brief weapon slot type * */ inline const model::Slot::Type type() const { return slot_type; } /* --- 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 a specified flags * */ void set_flag(const Flags flag); /** * @brief unset a specified flags * */ void unset_flag(const Flags flag); /** * @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 timestamp when the slot last ejected a projectile, server-side * This is a server-side property, to be set by the game module * */ inline void set_last_fired(unsigned long last_fired) { slot_last_fired = last_fired; } /** * @brief set the item this slot is holding * */ void set_item(Item *item); /** * @brief set slot fire cone, in radians * */ inline void set_cone(const float cone) { slot_cone = cone; } /** * @brief set slot slot_radius * */ void set_radius(const float radius) { slot_radius = radius; } /** * @brief set slot type * */ void set_type(const model::Slot::Type type) { slot_type = type; } /** * @brief load slot parameters from a model weapon tag * */ void load(const model::Slot *slot_tag); private: model::Slot::Type slot_type; math::Vector3f slot_location; math::Axis slot_axis; float slot_radius; float slot_cone; // slot flags unsigned int slot_flags; // timestamp indicating when the slot configuration was last changed unsigned long slot_timestamp; // timestamp indicating when the slot last generated a projectile, server-side unsigned long slot_last_fired; // item mounted in this slot Item *slot_item; }; } // namespace core #endif // __INCLUDED_CORE_SLOTS_H__