[6474] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
[6540] | 30 | @file PickupManager.h |
---|
[6474] | 31 | @brief Definition of the PickupManager class. |
---|
[7456] | 32 | @ingroup Pickup |
---|
[6474] | 33 | */ |
---|
| 34 | |
---|
| 35 | #ifndef _PickupManager_H__ |
---|
| 36 | #define _PickupManager_H__ |
---|
| 37 | |
---|
| 38 | #include "PickupPrereqs.h" |
---|
| 39 | |
---|
| 40 | #include <map> |
---|
| 41 | #include "util/Singleton.h" |
---|
[7163] | 42 | #include "core/WeakPtr.h" |
---|
[6474] | 43 | #include "pickup/PickupIdentifier.h" |
---|
| 44 | #include "PickupRepresentation.h" |
---|
| 45 | |
---|
| 46 | #include "core/OrxonoxClass.h" |
---|
| 47 | |
---|
[6711] | 48 | namespace orxonox // tolua_export |
---|
| 49 | { // tolua_export |
---|
[6474] | 50 | |
---|
| 51 | /** |
---|
| 52 | @brief |
---|
| 53 | Manages Pickupables. |
---|
[6711] | 54 | In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory. |
---|
[6474] | 55 | @author |
---|
| 56 | Damian 'Mozork' Frick |
---|
| 57 | */ |
---|
[6711] | 58 | class _PickupExport PickupManager // tolua_export |
---|
| 59 | : public Singleton<PickupManager>, public OrxonoxClass |
---|
| 60 | { // tolua_export |
---|
[6474] | 61 | friend class Singleton<PickupManager>; |
---|
[7163] | 62 | |
---|
[6474] | 63 | public: |
---|
| 64 | PickupManager(); |
---|
| 65 | virtual ~PickupManager(); |
---|
[7163] | 66 | |
---|
[6711] | 67 | static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export |
---|
[7163] | 68 | |
---|
[6475] | 69 | bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. |
---|
[6725] | 70 | bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. |
---|
[6474] | 71 | PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. |
---|
[7163] | 72 | |
---|
[6711] | 73 | // tolua_begin |
---|
[7206] | 74 | orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup); //!< Get the PickupRepresentation of an input Pickupable. |
---|
| 75 | |
---|
| 76 | int getNumPickups(void); //!< Update the list of picked up Pickupables and get the number of Pickupables in the list. |
---|
| 77 | /** |
---|
| 78 | @brief Get the next Pickupable in the list. |
---|
| 79 | Use this, after having called getNumPickups() to access all the Pickupables individually and in succession. |
---|
| 80 | @return Returns the next Pickupable in the list. |
---|
| 81 | */ |
---|
[7163] | 82 | orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; } |
---|
| 83 | |
---|
[7206] | 84 | void dropPickup(orxonox::Pickupable* pickup); //!< Drop the input Pickupable. |
---|
| 85 | void usePickup(orxonox::Pickupable* pickup, bool use); //!< Use (or unuse) the input Pickupable. |
---|
| 86 | bool isValidPickup(orxonox::Pickupable* pickup); //!< Check whether the input Pickupable is valid, meaning that it is in the PickupManager's list and still exists. |
---|
[6711] | 87 | // tolua_end |
---|
[7163] | 88 | |
---|
[6474] | 89 | private: |
---|
| 90 | static PickupManager* singletonPtr_s; |
---|
[7206] | 91 | static const std::string guiName_s; //!< The name of the PickupInventory |
---|
[7163] | 92 | |
---|
[6474] | 93 | PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. |
---|
[6475] | 94 | std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. |
---|
[7163] | 95 | |
---|
[7206] | 96 | std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_; //!< A list of all the picked up Pickupables. |
---|
| 97 | std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_. |
---|
[7163] | 98 | |
---|
[7206] | 99 | std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier, std::vector<PickupCarrier*>* carriers = NULL); //!< Helper method. Get all the PickupCarriers that carry Pickupables, recursively. |
---|
[7163] | 100 | |
---|
[6711] | 101 | }; // tolua_export |
---|
[7163] | 102 | |
---|
[6711] | 103 | } // tolua_export |
---|
[6474] | 104 | |
---|
| 105 | #endif // _PickupManager_H__ |
---|