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 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #include "DroppedItem.h" |
---|
30 | |
---|
31 | #include "core/CoreIncludes.h" |
---|
32 | #include "interfaces/Pickupable.h" |
---|
33 | #include "graphics/Model.h" |
---|
34 | |
---|
35 | namespace orxonox |
---|
36 | { |
---|
37 | /** |
---|
38 | @brief |
---|
39 | Constructor. Registers object and sets default values. |
---|
40 | */ |
---|
41 | DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator) |
---|
42 | { |
---|
43 | this->initialize(); |
---|
44 | } |
---|
45 | |
---|
46 | DroppedItem::DroppedItem(BaseObject* creator, Pickupable* item, const Vector3& position, float triggerDistance) : PickupSpawner(creator, item, triggerDistance, 0, 1) |
---|
47 | { |
---|
48 | this->initialize(); |
---|
49 | |
---|
50 | this->createDrop(position); |
---|
51 | } |
---|
52 | |
---|
53 | void DroppedItem::initialize(void) |
---|
54 | { |
---|
55 | RegisterObject(DroppedItem); |
---|
56 | |
---|
57 | this->gotPickedUp_ = false; |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | @brief |
---|
62 | Default destructor. |
---|
63 | */ |
---|
64 | DroppedItem::~DroppedItem() |
---|
65 | { |
---|
66 | if(this->gotPickedUp_ && this->pickup_ != NULL) |
---|
67 | { |
---|
68 | this->pickup_ = NULL; |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | Pickupable* DroppedItem::getPickup(void) |
---|
73 | { |
---|
74 | return this->pickup_; |
---|
75 | } |
---|
76 | |
---|
77 | void DroppedItem::createDrop(const Vector3& position) |
---|
78 | { |
---|
79 | this->setPosition(position); |
---|
80 | |
---|
81 | //TODO: Make this work. |
---|
82 | //const Model& model = PickupManager::getModel(item->getPickupIdentifier()); |
---|
83 | //this->attach(model); |
---|
84 | } |
---|
85 | |
---|
86 | //TODO: Remove. |
---|
87 | //TODO: Comment. |
---|
88 | //Each pickup should have a XML template where the Model and Billboard, and so on, is specified. |
---|
89 | // /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive) |
---|
90 | // { |
---|
91 | // //TODO: triggerDistance? |
---|
92 | // float triggerDistance = 20.0; |
---|
93 | // DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1); |
---|
94 | // |
---|
95 | // //TODO: Do this somehwere else? |
---|
96 | // Model* model = new Model(item); |
---|
97 | // Billboard* billboard = new Billboard(item); |
---|
98 | // |
---|
99 | // model->setMeshSource("sphere.mesh"); |
---|
100 | // model->setScale(3.0f); |
---|
101 | // |
---|
102 | // billboard->setMaterial("Examples/Flare"); |
---|
103 | // billboard->setColour(flareColour); |
---|
104 | // billboard->setScale(0.5f); |
---|
105 | // |
---|
106 | // droppedItem->setPosition(position); |
---|
107 | // droppedItem->attach(model); |
---|
108 | // droppedItem->attach(billboard); |
---|
109 | // |
---|
110 | // COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl; |
---|
111 | // |
---|
112 | // return droppedItem; |
---|
113 | // } |
---|
114 | |
---|
115 | //TODO: See one function above. |
---|
116 | // DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive) |
---|
117 | // { |
---|
118 | // Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f); |
---|
119 | // return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive); |
---|
120 | // } |
---|
121 | } |
---|