[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 | |
---|
[6540] | 29 | /** |
---|
| 30 | @file PickupIdentifier.h |
---|
| 31 | @brief Definition of the PickupIdentifier class. |
---|
[7456] | 32 | @ingroup Pickup |
---|
[6540] | 33 | */ |
---|
| 34 | |
---|
[6474] | 35 | #ifndef _PickupIdentifier_H__ |
---|
| 36 | #define _PickupIdentifier_H__ |
---|
| 37 | |
---|
| 38 | #include "OrxonoxPrereqs.h" |
---|
| 39 | |
---|
| 40 | #include <map> |
---|
| 41 | #include <string> |
---|
| 42 | |
---|
[7163] | 43 | #include "core/OrxonoxClass.h" |
---|
[6475] | 44 | |
---|
[6474] | 45 | namespace orxonox |
---|
| 46 | { |
---|
[7163] | 47 | |
---|
[6475] | 48 | /** |
---|
| 49 | @brief |
---|
[7494] | 50 | The purpose of the PickupIdentifier class is to identify (or differentiate between) different types of pickups although they are of the same class. |
---|
| 51 | |
---|
| 52 | This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. |
---|
| 53 | |
---|
| 54 | An example is the @ref orxonox::HealthPickup "HealthPickup" class that encompasses a wide variety of different types of health pickups, e.g a @ref orxonox::HealthPickup "HealthPickup" that adds 10 health every second for 10 seconds or a @ref orxonox::HealthPickup "HealthPickup" that adds 100 health as soon as it is picked up, a.s.o. |
---|
| 55 | |
---|
| 56 | To that purpose this class provides functionality to compare two @ref orxonox::PickupIdentifier "PickupIdentifiers" (and since all @ref orxonox::Pickupable "Pickupables" have an identifier, we can use it to compare pickups). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class. |
---|
| 57 | |
---|
| 58 | Lastly a struct (@ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare") is provided that can be used in stl containers to establish a strictly lesser ordering between @ref orxonox::PickupIdentifier "PickupIdentifiers" (and thus @ref orxonox::Pickupable "Pickupables"). |
---|
[7547] | 59 | |
---|
[6475] | 60 | @author |
---|
| 61 | Damian 'Mozork' Frick |
---|
[7547] | 62 | |
---|
| 63 | @ingroup Pickup |
---|
[6475] | 64 | */ |
---|
[6474] | 65 | class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass |
---|
| 66 | { |
---|
[7163] | 67 | |
---|
[6474] | 68 | public: |
---|
[6480] | 69 | PickupIdentifier(Pickupable* pickup); //!< Constructor. |
---|
[6475] | 70 | ~PickupIdentifier(); //!< Destructor. |
---|
[7163] | 71 | |
---|
[6475] | 72 | virtual int compare(const PickupIdentifier* identifier) const; //!< Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b). |
---|
[7163] | 73 | |
---|
[6475] | 74 | bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier. |
---|
[7163] | 75 | |
---|
[6474] | 76 | private: |
---|
[6480] | 77 | Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for. |
---|
[6475] | 78 | std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class. |
---|
[7163] | 79 | |
---|
[6474] | 80 | }; |
---|
[7163] | 81 | |
---|
[6475] | 82 | /** |
---|
| 83 | @brief |
---|
[7494] | 84 | Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers. |
---|
[7551] | 85 | |
---|
| 86 | @ingroup Pickup |
---|
[6475] | 87 | */ |
---|
[6474] | 88 | struct PickupIdentifierCompare |
---|
| 89 | { |
---|
| 90 | bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const |
---|
[6475] | 91 | { return lhs->compare(rhs) < 0; } |
---|
[6474] | 92 | }; |
---|
[7163] | 93 | |
---|
[6474] | 94 | } |
---|
| 95 | |
---|
| 96 | #endif // _PickupIdentifier_H__ |
---|