| [6405] | 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 | |
|---|
| [6538] | 29 | /** |
|---|
| 30 | @file PickupCollection.h |
|---|
| 31 | @brief Declaration of PickupCollection. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| [6405] | 34 | #ifndef _PickupCollection_H__ |
|---|
| 35 | #define _PickupCollection_H__ |
|---|
| 36 | |
|---|
| [6466] | 37 | #include "PickupPrereqs.h" |
|---|
| [6405] | 38 | |
|---|
| 39 | #include "core/BaseObject.h" |
|---|
| [7163] | 40 | #include "CollectiblePickup.h" |
|---|
| [6405] | 41 | |
|---|
| 42 | #include <list> |
|---|
| 43 | |
|---|
| 44 | namespace orxonox |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | @brief |
|---|
| [7163] | 49 | The PickupCollection combines different Pickupables to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one Pickupable. |
|---|
| [6405] | 50 | @author |
|---|
| 51 | Damian 'Mozork' Frick |
|---|
| 52 | */ |
|---|
| [7163] | 53 | class _PickupExport PickupCollection : public CollectiblePickup, public BaseObject |
|---|
| [6405] | 54 | { |
|---|
| [7163] | 55 | |
|---|
| [6405] | 56 | public: |
|---|
| [6538] | 57 | PickupCollection(BaseObject* creator); //!< Default Constructor. |
|---|
| 58 | virtual ~PickupCollection(); //!< Destructor. |
|---|
| [7163] | 59 | |
|---|
| [6538] | 60 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates an instance of this Class through XML. |
|---|
| [6405] | 61 | |
|---|
| [6538] | 62 | virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. |
|---|
| 63 | virtual void changedCarrier(void); //!< Is called when the pickup has changed its PickupCarrier. |
|---|
| 64 | virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around. |
|---|
| [7163] | 65 | |
|---|
| [6538] | 66 | virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. |
|---|
| [7163] | 67 | |
|---|
| [6731] | 68 | virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. |
|---|
| [7163] | 69 | |
|---|
| [6538] | 70 | virtual const PickupIdentifier* getPickupIdentifier(void); //!< Get the PickupIdentifier of this PickupCollection. |
|---|
| [7163] | 71 | |
|---|
| 72 | bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection. |
|---|
| [6538] | 73 | const Pickupable* getPickupable(unsigned int index); //!< Get the Pickupable at the given index. |
|---|
| [7163] | 74 | |
|---|
| 75 | void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value. |
|---|
| 76 | void pickupChangedPickedUp(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value. |
|---|
| 77 | void pickupDisabled(void); //!< Informs the PickupCollection, that one of its pickups has been disabled. |
|---|
| 78 | |
|---|
| [6466] | 79 | protected: |
|---|
| [6538] | 80 | void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup. |
|---|
| [7163] | 81 | |
|---|
| [6540] | 82 | virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. |
|---|
| [7163] | 83 | |
|---|
| [6538] | 84 | PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves. |
|---|
| [7163] | 85 | |
|---|
| [6405] | 86 | private: |
|---|
| [7163] | 87 | void changedUsedAction(void); //!< Helper method. |
|---|
| 88 | void changedPickedUpAction(void); //!< Helper method. |
|---|
| [6405] | 89 | |
|---|
| [7163] | 90 | std::vector<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid. |
|---|
| 91 | |
|---|
| 92 | unsigned int usedCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are in use. |
|---|
| 93 | unsigned int pickedUpCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are picked up. |
|---|
| 94 | unsigned int disabledCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are disabled. |
|---|
| 95 | |
|---|
| 96 | bool processingUsed_; //!< Boolean to ensure, that the PickupCollection doesn't update its used status while its internal state is inconsistent. |
|---|
| 97 | bool processingPickedUp_; //!< Boolean to ensure, that the PickupCollection doesn't update its picked upp status while its internal state is inconsistent. |
|---|
| 98 | |
|---|
| [6405] | 99 | }; |
|---|
| [7163] | 100 | |
|---|
| [6405] | 101 | } |
|---|
| 102 | |
|---|
| 103 | #endif /* _PickupCollection_H__ */ |
|---|