[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: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[2917] | 29 | #include "DroppedItem.h" |
---|
| 30 | |
---|
[3196] | 31 | #include "core/CoreIncludes.h" |
---|
[6421] | 32 | #include "interfaces/Pickupable.h" |
---|
[5737] | 33 | #include "graphics/Model.h" |
---|
[2917] | 34 | |
---|
| 35 | namespace orxonox |
---|
| 36 | { |
---|
[5947] | 37 | /** |
---|
| 38 | @brief |
---|
| 39 | Constructor. Registers object and sets default values. |
---|
| 40 | */ |
---|
[5953] | 41 | DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator) |
---|
[2917] | 42 | { |
---|
[6421] | 43 | this->initialize(); |
---|
[5953] | 44 | } |
---|
[2917] | 45 | |
---|
[6421] | 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) |
---|
[5953] | 54 | { |
---|
| 55 | RegisterObject(DroppedItem); |
---|
[6421] | 56 | |
---|
| 57 | this->gotPickedUp_ = false; |
---|
[2917] | 58 | } |
---|
[5947] | 59 | |
---|
| 60 | /** |
---|
| 61 | @brief |
---|
| 62 | Default destructor. |
---|
| 63 | */ |
---|
[2917] | 64 | DroppedItem::~DroppedItem() |
---|
| 65 | { |
---|
[6421] | 66 | if(this->gotPickedUp_ && this->pickup_ != NULL) |
---|
| 67 | { |
---|
| 68 | this->pickup_ = NULL; |
---|
| 69 | } |
---|
[2917] | 70 | } |
---|
[5947] | 71 | |
---|
[6421] | 72 | Pickupable* DroppedItem::getPickup(void) |
---|
[2917] | 73 | { |
---|
[6421] | 74 | return this->pickup_; |
---|
[2917] | 75 | } |
---|
[6421] | 76 | |
---|
| 77 | void DroppedItem::createDrop(const Vector3& position) |
---|
[2917] | 78 | { |
---|
[6421] | 79 | this->setPosition(position); |
---|
[5953] | 80 | |
---|
[6421] | 81 | //TODO: Make this work. |
---|
| 82 | //const Model& model = PickupManager::getModel(item->getPickupIdentifier()); |
---|
| 83 | //this->attach(model); |
---|
[2917] | 84 | } |
---|
[5947] | 85 | |
---|
[6421] | 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 | // } |
---|
[5947] | 114 | |
---|
| 115 | //TODO: See one function above. |
---|
[6421] | 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 | // } |
---|
[2917] | 121 | } |
---|