Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/modules/pickup/DroppedPickup.cc @ 6518

Last change on this file since 6518 was 6516, checked in by dafrick, 15 years ago

Resolved DroppedPickup bug, where the pickup picked up from a DroppedPickup was destroyed almost immediately after beign picked up, because the DroppedPickup was destroyed, and destroyed the pickup in its constructor.

  • Property svn:eol-style set to native
File size: 2.7 KB
RevLine 
[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/**
30    @file
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"
[5737]38#include "graphics/Model.h"
[2917]39
40namespace orxonox
41{
[6512]42   
43    CreateFactory(DroppedPickup);
44   
[5947]45    /**
46    @brief
[6475]47        Default constructor. Registers object and sets default values.
[5947]48    */
[6475]49    DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator)
[2917]50    {
[6475]51        RegisterObject(DroppedPickup);
52       
[5953]53    }
[2917]54
[6475]55    /**
56    @brief
57        Constructor. Registers the object and sets values.
58    @param creator
59        The creator of the DroppedPickup.
60    @param pickup
61        The Pickupable that was dropped.
62    @param position
63        The position at which the DroppedPickup should be created.
64    @param triggerDistance
65        The distance at which the PickupSpawner triggers. Default is 10.
66    */
[6512]67    DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1)
[6421]68    {   
[6475]69        RegisterObject(DroppedPickup);
[6516]70
[6475]71        this->setPosition(position);
[6512]72        this->setActive(false);
73        this->startRespawnTimer();
[6421]74    }
[5947]75
76    /**
77    @brief
[6475]78        Destructor.
[5947]79    */
[6475]80    DroppedPickup::~DroppedPickup()
[2917]81    {
[6516]82        if(this->pickup_ != NULL && this->pickup_->isPickedUp())
[6421]83        {
84            this->pickup_ = NULL;
85        }
[2917]86    }
[5947]87
[6475]88    /**
89    @brief
90        Creates the Pickupable that is going to get picked up.
91        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.
92    */
93    Pickupable* DroppedPickup::getPickup(void)
[2917]94    {
[6421]95        return this->pickup_;
[2917]96    }
[5947]97
[2917]98}
Note: See TracBrowser for help on using the repository browser.