[3079] | 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 | * Daniel 'Huty' Haggenmueller |
---|
| 24 | * Co-authors: |
---|
[6475] | 25 | * Damian 'Mozork' Frick |
---|
[3079] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[6475] | 29 | /** |
---|
[6540] | 30 | @file DroppedPickup.cc |
---|
[6475] | 31 | @brief Implementation of the DroppedPickup class. |
---|
| 32 | */ |
---|
[2917] | 33 | |
---|
[6475] | 34 | #include "DroppedPickup.h" |
---|
| 35 | |
---|
[3196] | 36 | #include "core/CoreIncludes.h" |
---|
[6421] | 37 | #include "interfaces/Pickupable.h" |
---|
[6540] | 38 | #include "interfaces/PickupCarrier.h" |
---|
[5737] | 39 | #include "graphics/Model.h" |
---|
[2917] | 40 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
[7163] | 43 | |
---|
[6512] | 44 | CreateFactory(DroppedPickup); |
---|
[7163] | 45 | |
---|
[5947] | 46 | /** |
---|
| 47 | @brief |
---|
[6475] | 48 | Default constructor. Registers object and sets default values. |
---|
[5947] | 49 | */ |
---|
[6475] | 50 | DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator) |
---|
[2917] | 51 | { |
---|
[6475] | 52 | RegisterObject(DroppedPickup); |
---|
[7163] | 53 | |
---|
[5953] | 54 | } |
---|
[2917] | 55 | |
---|
[6475] | 56 | /** |
---|
| 57 | @brief |
---|
| 58 | Constructor. Registers the object and sets values. |
---|
| 59 | @param creator |
---|
| 60 | The creator of the DroppedPickup. |
---|
| 61 | @param pickup |
---|
| 62 | The Pickupable that was dropped. |
---|
[7401] | 63 | @param carrier |
---|
| 64 | The PickupCarrier that carried the input pickup before it was dropped. |
---|
[6475] | 65 | @param triggerDistance |
---|
| 66 | The distance at which the PickupSpawner triggers. Default is 10. |
---|
| 67 | */ |
---|
[6540] | 68 | DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 5, 1) |
---|
[7163] | 69 | { |
---|
[6475] | 70 | RegisterObject(DroppedPickup); |
---|
[6516] | 71 | |
---|
[6540] | 72 | this->setPosition(carrier->getCarrierPosition()); |
---|
[6512] | 73 | this->setActive(false); |
---|
[7163] | 74 | |
---|
[6540] | 75 | //TODO: Do more elegantly. |
---|
[6512] | 76 | this->startRespawnTimer(); |
---|
[6421] | 77 | } |
---|
[5947] | 78 | |
---|
| 79 | /** |
---|
| 80 | @brief |
---|
[6475] | 81 | Destructor. |
---|
[5947] | 82 | */ |
---|
[6475] | 83 | DroppedPickup::~DroppedPickup() |
---|
[2917] | 84 | { |
---|
[6516] | 85 | if(this->pickup_ != NULL && this->pickup_->isPickedUp()) |
---|
[6421] | 86 | { |
---|
| 87 | this->pickup_ = NULL; |
---|
| 88 | } |
---|
[2917] | 89 | } |
---|
[5947] | 90 | |
---|
[6475] | 91 | /** |
---|
| 92 | @brief |
---|
| 93 | Creates the Pickupable that is going to get picked up. |
---|
| 94 | In the case of the DroppedItem it is the one and only Pickupable that was dropped. No additional Pickupables of the same type are created. |
---|
| 95 | */ |
---|
| 96 | Pickupable* DroppedPickup::getPickup(void) |
---|
[2917] | 97 | { |
---|
[6421] | 98 | return this->pickup_; |
---|
[2917] | 99 | } |
---|
[5947] | 100 | |
---|
[2917] | 101 | } |
---|