Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7479 was 7456, checked in by dafrick, 14 years ago

Reviewing documentation fo Questsystem, moving documentation fully into doxygen.
Added some files to modules they belong to.

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
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/**
30    @file PickupManager.h
31    @brief Definition of the PickupManager class.
32    @ingroup Pickup
33*/
34
35#ifndef _PickupManager_H__
36#define _PickupManager_H__
37
38#include "PickupPrereqs.h"
39
40#include <map>
41#include "util/Singleton.h"
42#include "core/WeakPtr.h"
43#include "pickup/PickupIdentifier.h"
44#include "PickupRepresentation.h"
45
46#include "core/OrxonoxClass.h"
47
48namespace orxonox // tolua_export
49{ // tolua_export
50
51    /**
52    @brief
53        Manages Pickupables.
54        In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory.
55    @author
56        Damian 'Mozork' Frick
57    */
58    class _PickupExport PickupManager // tolua_export
59        : public Singleton<PickupManager>, public OrxonoxClass
60    { // tolua_export
61        friend class Singleton<PickupManager>;
62
63        public:
64            PickupManager();
65            virtual ~PickupManager();
66
67            static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
68
69            bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
70            bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
71            PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
72
73            // tolua_begin
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            */
82            orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; }
83
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.
87            // tolua_end
88
89        private:
90            static PickupManager* singletonPtr_s;
91            static const std::string guiName_s; //!< The name of the PickupInventory
92
93            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
94            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
95
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_.
98
99            std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier, std::vector<PickupCarrier*>* carriers = NULL); //!< Helper method. Get all the PickupCarriers that carry Pickupables, recursively.
100
101    }; // tolua_export
102
103} // tolua_export
104
105#endif // _PickupManager_H__
Note: See TracBrowser for help on using the repository browser.