Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/interfaces/PickupCarrier.h @ 7505

Last change on this file since 7505 was 7494, checked in by dafrick, 14 years ago

Some documenting and cleaning up/re-organization in pickups module.

  • Property svn:eol-style set to native
File size: 5.4 KB
RevLine 
[6405]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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
[6540]30    @file PickupCarrier.h
[6405]31    @brief Definition of the PickupCarrier class.
[7456]32    @ingroup Pickup
[6405]33*/
34
35#ifndef _PickupCarrier_H__
36#define _PickupCarrier_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include <set>
[7494]41#include <vector>
[6405]42
[6474]43#include "core/OrxonoxClass.h"
44
[7163]45namespace orxonox
46{
[6521]47
[7494]48    // Forward-declarations.
[6711]49    class PickupManager;
[6710]50    class Pickup;
51    class HealthPickup;
52    class InvisiblePickup;
53    class MetaPickup;
[7163]54    class DronePickup;
[6710]55    class SpeedPickup;
56
[6474]57    /**
58    @brief
[7494]59        The PickupCarrier interface provides the means, for any class implementing it, to possess @ref orxonox::Pickupable "Pickupables".
60
61        For a class to use the PickupCarrier interface it must implement the follwing three methods:
62        - <b>getCarrierPosition()</b> The getCarrierPosition() method returns the absolute position (in space) of the PickupCarrier.
63
64        Different PickupCarriers are structured hierarchically, a pickup can be picked up by a PickupCarrier that can't really carry that particular pickup but one of its children (or one of their children) can, and thus it gets "handed down" until it is at the right place.
65        But this structure has to be established first.
66        - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxonx::Engine "Engine".
67        - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or NULL if the PickupCarrier is a root node in this hierarchy.
68
[6474]69    @author
70        Damian 'Mozork' Frick
71    */
[7163]72    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
73    {
[7494]74        // So that the different Pickupables have full access to their PickupCarrier.
[6711]75        friend class Pickupable;
76        friend class PickupManager;
[7494]77        // Friends.
[6512]78        friend class Pickup;
79        friend class HealthPickup;
[6710]80        friend class InvisiblePickup;
81        friend class MetaPickup;
[7163]82        friend class DronePickup;
[6709]83        friend class SpeedPickup;
84
[6405]85        public:
[6474]86            PickupCarrier(); //!< Constructor.
87            virtual ~PickupCarrier(); //!< Destructor.
[7494]88            void preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed.
[6709]89
[7494]90            bool isTarget(const Pickupable* pickup); //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
91            PickupCarrier* getTarget(const Pickupable* pickup); //!< Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
[6709]92
[6475]93            /**
[6540]94            @brief Get the (absolute) position of the PickupCarrier.
95                   This method needs to be implemented by any direct derivative class of PickupCarrier.
96            @return Returns the position as a Vector3.
97            */
98            virtual const Vector3& getCarrierPosition(void) = 0;
[7163]99
100        protected:
[6475]101            /**
102            @brief Get all direct children of this PickupSpawner.
103                   This method needs to be implemented by any direct derivative class of PickupCarrier.
[6540]104                   The returned list will be deleted by the methods calling this function.
[6709]105            @return Returns a pointer to a list of all direct children.
[6475]106            */
[6711]107            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) = 0;
[6475]108            /**
[7494]109            @brief Get the parent of this PickupSpawner.
[6475]110                   This method needs to be implemented by any direct derivative class of PickupCarrier.
111            @return Returns a pointer to the parent.
112            */
113            virtual PickupCarrier* getCarrierParent(void) = 0;
[6709]114
[6521]115            /**
116            @brief Get all Pickupables this PickupCarrier has.
117            @return  Returns the set of all Pickupables this PickupCarrier has.
118            */
[6512]119            std::set<Pickupable*>& getPickups(void)
120                { return this->pickups_; }
[7163]121
[6405]122        private:
[6475]123            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
[7163]124
[7494]125            bool addPickup(Pickupable* pickup); //!< Adds a Pickupable to the list of pickups that are carried by this PickupCarrier.
126            bool removePickup(Pickupable* pickup); //!< Removes a Pickupable from the list of pickups that are carried by this PickupCarrier.
[7163]127
128    };
129}
130
[6405]131#endif /* _PickupCarrier_H__ */
Note: See TracBrowser for help on using the repository browser.