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: |
---|
25 | * Damian 'Mozork' Frick |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file |
---|
31 | @brief Implementation of the DroppedPickup class. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "DroppedPickup.h" |
---|
35 | |
---|
36 | #include "core/CoreIncludes.h" |
---|
37 | #include "interfaces/Pickupable.h" |
---|
38 | #include "graphics/Model.h" |
---|
39 | |
---|
40 | namespace orxonox |
---|
41 | { |
---|
42 | |
---|
43 | CreateFactory(DroppedPickup); |
---|
44 | |
---|
45 | /** |
---|
46 | @brief |
---|
47 | Default constructor. Registers object and sets default values. |
---|
48 | */ |
---|
49 | DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator) |
---|
50 | { |
---|
51 | RegisterObject(DroppedPickup); |
---|
52 | |
---|
53 | this->initialize(); |
---|
54 | } |
---|
55 | |
---|
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. |
---|
63 | @param position |
---|
64 | The position at which the DroppedPickup should be created. |
---|
65 | @param triggerDistance |
---|
66 | The distance at which the PickupSpawner triggers. Default is 10. |
---|
67 | */ |
---|
68 | DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1) |
---|
69 | { |
---|
70 | RegisterObject(DroppedPickup); |
---|
71 | |
---|
72 | this->initialize(); |
---|
73 | |
---|
74 | this->setPosition(position); |
---|
75 | this->setActive(false); |
---|
76 | this->startRespawnTimer(); |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | @brief |
---|
81 | Destructor. |
---|
82 | */ |
---|
83 | DroppedPickup::~DroppedPickup() |
---|
84 | { |
---|
85 | if(this->gotPickedUp_ && this->pickup_ != NULL) |
---|
86 | { |
---|
87 | this->pickup_ = NULL; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | @brief |
---|
93 | Initializes the member variables of the object. |
---|
94 | */ |
---|
95 | void DroppedPickup::initialize(void) |
---|
96 | { |
---|
97 | this->gotPickedUp_ = false; |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | @brief |
---|
102 | Creates the Pickupable that is going to get picked up. |
---|
103 | 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. |
---|
104 | */ |
---|
105 | Pickupable* DroppedPickup::getPickup(void) |
---|
106 | { |
---|
107 | return this->pickup_; |
---|
108 | } |
---|
109 | |
---|
110 | } |
---|