[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"). |
---|
[6475] | 59 | @author |
---|
| 60 | Damian 'Mozork' Frick |
---|
| 61 | */ |
---|
[6474] | 62 | class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass |
---|
| 63 | { |
---|
[7163] | 64 | |
---|
[6474] | 65 | public: |
---|
[6480] | 66 | PickupIdentifier(Pickupable* pickup); //!< Constructor. |
---|
[6475] | 67 | ~PickupIdentifier(); //!< Destructor. |
---|
[7163] | 68 | |
---|
[6475] | 69 | 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] | 70 | |
---|
[6475] | 71 | bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier. |
---|
[7163] | 72 | |
---|
[6474] | 73 | private: |
---|
[6480] | 74 | Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for. |
---|
[6475] | 75 | std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class. |
---|
[7163] | 76 | |
---|
[6474] | 77 | }; |
---|
[7163] | 78 | |
---|
[6475] | 79 | /** |
---|
| 80 | @brief |
---|
[7494] | 81 | Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers. |
---|
[6475] | 82 | */ |
---|
[6474] | 83 | struct PickupIdentifierCompare |
---|
| 84 | { |
---|
| 85 | bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const |
---|
[6475] | 86 | { return lhs->compare(rhs) < 0; } |
---|
[6474] | 87 | }; |
---|
[7163] | 88 | |
---|
[6474] | 89 | } |
---|
| 90 | |
---|
| 91 | #endif // _PickupIdentifier_H__ |
---|