[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. |
---|
[7456] | 32 | @ingroup Pickup |
---|
[6538] | 33 | */ |
---|
| 34 | |
---|
[6405] | 35 | #ifndef _PickupCollection_H__ |
---|
| 36 | #define _PickupCollection_H__ |
---|
| 37 | |
---|
[6466] | 38 | #include "PickupPrereqs.h" |
---|
[6405] | 39 | |
---|
[7547] | 40 | #include <list> |
---|
| 41 | |
---|
| 42 | #include "CollectiblePickup.h" |
---|
[6405] | 43 | #include "core/BaseObject.h" |
---|
| 44 | |
---|
| 45 | namespace orxonox |
---|
| 46 | { |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | @brief |
---|
[7494] | 50 | The PickupCollection combines different @ref orxonox::Pickupable "Pickupables" (more precisely @ref orxonox::CollectiblePickup "CollectiblePickups") to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one @ref orxonox::Pickupable "Pickupable". |
---|
| 51 | |
---|
| 52 | A PickupCollection can be created in XML as follows: |
---|
| 53 | @code |
---|
| 54 | <PickupCollection> |
---|
| 55 | <pickupables> |
---|
| 56 | <CollectiblePickup ... /> |
---|
| 57 | ... |
---|
| 58 | <CollectiblePickup ... /> |
---|
| 59 | </pickupables> |
---|
| 60 | </PickupCollection> |
---|
| 61 | @endcode |
---|
| 62 | |
---|
[6405] | 63 | @author |
---|
| 64 | Damian 'Mozork' Frick |
---|
[7533] | 65 | |
---|
| 66 | @ingroup Pickup |
---|
[6405] | 67 | */ |
---|
[7163] | 68 | class _PickupExport PickupCollection : public CollectiblePickup, public BaseObject |
---|
[6405] | 69 | { |
---|
[7163] | 70 | |
---|
[6405] | 71 | public: |
---|
[9667] | 72 | PickupCollection(Context* context); //!< Default Constructor. |
---|
[6538] | 73 | virtual ~PickupCollection(); //!< Destructor. |
---|
[7163] | 74 | |
---|
[6538] | 75 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates an instance of this Class through XML. |
---|
[6405] | 76 | |
---|
[6538] | 77 | virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. |
---|
| 78 | virtual void changedCarrier(void); //!< Is called when the pickup has changed its PickupCarrier. |
---|
| 79 | virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around. |
---|
[7163] | 80 | |
---|
[7547] | 81 | virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. |
---|
[7163] | 82 | |
---|
[9348] | 83 | inline void setRepresentationName(const std::string& name) |
---|
| 84 | { this->representationName_ = name; } |
---|
| 85 | virtual const std::string& getRepresentationName() const |
---|
| 86 | { return this->representationName_; } |
---|
[7163] | 87 | |
---|
| 88 | bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection. |
---|
[7547] | 89 | const Pickupable* getPickupable(unsigned int index) const; //!< Get the Pickupable at the given index. |
---|
[9348] | 90 | bool removePickupable(CollectiblePickup* pickup); //!< Removes the input Pickupable from the list of Pickupables in this PickupCollection. |
---|
[7163] | 91 | |
---|
[9348] | 92 | inline const std::list<CollectiblePickup*>& getPickups() const |
---|
| 93 | { return this->pickups_; } |
---|
| 94 | |
---|
[7163] | 95 | void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value. |
---|
| 96 | void pickupChangedPickedUp(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value. |
---|
| 97 | void pickupDisabled(void); //!< Informs the PickupCollection, that one of its pickups has been disabled. |
---|
| 98 | |
---|
[6466] | 99 | protected: |
---|
[6540] | 100 | virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. |
---|
[7163] | 101 | |
---|
[6405] | 102 | private: |
---|
[7163] | 103 | void changedUsedAction(void); //!< Helper method. |
---|
| 104 | void changedPickedUpAction(void); //!< Helper method. |
---|
[9348] | 105 | void pickupsChanged(void); //!< Helper method. |
---|
[7494] | 106 | |
---|
[9348] | 107 | std::string representationName_; //!< The name of the associated PickupRepresentation. |
---|
| 108 | std::list<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. |
---|
[7163] | 109 | |
---|
| 110 | bool processingUsed_; //!< Boolean to ensure, that the PickupCollection doesn't update its used status while its internal state is inconsistent. |
---|
| 111 | bool processingPickedUp_; //!< Boolean to ensure, that the PickupCollection doesn't update its picked upp status while its internal state is inconsistent. |
---|
| 112 | |
---|
[6405] | 113 | }; |
---|
[7163] | 114 | |
---|
[6405] | 115 | } |
---|
| 116 | |
---|
[8351] | 117 | #endif /* _PickupCollection_H__ */ |
---|