[7162] | 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 CollectiblePickup.cc |
---|
| 31 | @brief Implementation of the CollectiblePickup class. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #include "CollectiblePickup.h" |
---|
| 35 | |
---|
| 36 | #include "core/CoreIncludes.h" |
---|
[7494] | 37 | |
---|
[7162] | 38 | #include "PickupCollection.h" |
---|
| 39 | |
---|
| 40 | namespace orxonox { |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | @brief |
---|
| 44 | Constructor. |
---|
| 45 | Registers the object and initializes variables. |
---|
| 46 | */ |
---|
[9348] | 47 | CollectiblePickup::CollectiblePickup() : collection_(NULL) |
---|
[7162] | 48 | { |
---|
| 49 | RegisterObject(CollectiblePickup); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | /** |
---|
| 53 | @brief |
---|
| 54 | Destructor. |
---|
| 55 | */ |
---|
| 56 | CollectiblePickup::~CollectiblePickup() |
---|
| 57 | { |
---|
[9348] | 58 | if (this->isInCollection()) |
---|
| 59 | this->collection_->removePickupable(this); |
---|
[7162] | 60 | } |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | @brief |
---|
| 64 | Is called when the pickup has transited from used to unused or the other way around. |
---|
| 65 | */ |
---|
| 66 | void CollectiblePickup::changedUsed(void) |
---|
| 67 | { |
---|
| 68 | SUPER(CollectiblePickup, changedUsed); |
---|
| 69 | |
---|
| 70 | if(this->isInCollection()) |
---|
| 71 | this->collection_->pickupChangedUsed(this->isUsed()); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | @brief |
---|
| 76 | Is called when the pickup has transited from picked up to dropped or the other way around. |
---|
| 77 | */ |
---|
| 78 | void CollectiblePickup::changedPickedUp(void) |
---|
| 79 | { |
---|
| 80 | SUPER(CollectiblePickup, changedPickedUp); |
---|
| 81 | |
---|
| 82 | if(this->isInCollection()) |
---|
| 83 | this->collection_->pickupChangedPickedUp(this->isPickedUp()); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | @brief |
---|
[9348] | 88 | Notifies this CollectiblePickup that it was added to a PickupCollection. |
---|
[7162] | 89 | @param collection |
---|
| 90 | A pointer to the PickupCollection to which the CollectiblePickup should be added. |
---|
| 91 | */ |
---|
[9348] | 92 | void CollectiblePickup::wasAddedToCollection(PickupCollection* collection) |
---|
[7162] | 93 | { |
---|
| 94 | this->collection_ = collection; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | @brief |
---|
[9348] | 99 | Notifies this CollectiblePickup that it was removed from its PickupCollection. |
---|
[7162] | 100 | */ |
---|
[9348] | 101 | void CollectiblePickup::wasRemovedFromCollection(void) |
---|
[7162] | 102 | { |
---|
| 103 | this->collection_ = NULL; |
---|
| 104 | } |
---|
| 105 | } |
---|