Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/PickupManager.h @ 7221

Last change on this file since 7221 was 7206, checked in by dafrick, 14 years ago

Cleaning up and documenting PickupManager.
Also discovered and fixed a small bug.

  • Property svn:eol-style set to native
File size: 4.7 KB
RevLine 
[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.
32*/
33
34#ifndef _PickupManager_H__
35#define _PickupManager_H__
36
37#include "PickupPrereqs.h"
38
39#include <map>
40#include "util/Singleton.h"
[7163]41#include "core/WeakPtr.h"
[6474]42#include "pickup/PickupIdentifier.h"
43#include "PickupRepresentation.h"
44
45#include "core/OrxonoxClass.h"
46
[6711]47namespace orxonox // tolua_export
48{ // tolua_export
[6474]49
50    /**
51    @brief
52        Manages Pickupables.
[6711]53        In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory.
[6474]54    @author
55        Damian 'Mozork' Frick
56    */
[6711]57    class _PickupExport PickupManager // tolua_export
58        : public Singleton<PickupManager>, public OrxonoxClass
59    { // tolua_export
[6474]60        friend class Singleton<PickupManager>;
[7163]61
[6474]62        public:
63            PickupManager();
64            virtual ~PickupManager();
[7163]65
[6711]66            static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
[7163]67
[6475]68            bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
[6725]69            bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
[6474]70            PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
[7163]71
[6711]72            // tolua_begin
[7206]73            orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup); //!< Get the PickupRepresentation of an input Pickupable.
74
75            int getNumPickups(void); //!< Update the list of picked up Pickupables and get the number of Pickupables in the list.
76            /**
77            @brief Get the next Pickupable in the list.
78                   Use this, after having called getNumPickups() to access all the Pickupables individually and in succession.
79            @return Returns the next Pickupable in the list.
80            */
[7163]81            orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; }
82
[7206]83            void dropPickup(orxonox::Pickupable* pickup); //!< Drop the input Pickupable.
84            void usePickup(orxonox::Pickupable* pickup, bool use); //!< Use (or unuse) the input Pickupable.
85            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]86            // tolua_end
[7163]87
[6474]88        private:
89            static PickupManager* singletonPtr_s;
[7206]90            static const std::string guiName_s; //!< The name of the PickupInventory
[7163]91
[6474]92            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
[6475]93            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
[7163]94
[7206]95            std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_; //!< A list of all the picked up Pickupables.
96            std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_.
[7163]97
[7206]98            std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier, std::vector<PickupCarrier*>* carriers = NULL); //!< Helper method. Get all the PickupCarriers that carry Pickupables, recursively.
[7163]99
[6711]100    }; // tolua_export
[7163]101
[6711]102} // tolua_export
[6474]103
104#endif // _PickupManager_H__
Note: See TracBrowser for help on using the repository browser.