Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12126 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 5.1 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
[9667]43#include "core/class/OrxonoxInterface.h"
[6474]44
[7163]45namespace orxonox
46{
[6521]47
[7494]48    // Forward-declarations.
[6710]49    class MetaPickup;
50
[6474]51    /**
52    @brief
[7494]53        The PickupCarrier interface provides the means, for any class implementing it, to possess @ref orxonox::Pickupable "Pickupables".
54
55        For a class to use the PickupCarrier interface it must implement the follwing three methods:
56        - <b>getCarrierPosition()</b> The getCarrierPosition() method returns the absolute position (in space) of the PickupCarrier.
57
58        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.
59        But this structure has to be established first.
[7547]60        - <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 orxonox::Engine "Engine".
[11071]61        - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or nullptr if the PickupCarrier is a root node in this hierarchy.
[7494]62
[6474]63    @author
64        Damian 'Mozork' Frick
[7547]65
66    @ingroup Pickup
[6474]67    */
[9667]68    class _OrxonoxExport PickupCarrier : virtual public OrxonoxInterface
[7163]69    {
[7494]70        // So that the different Pickupables have full access to their PickupCarrier.
[6711]71        friend class Pickupable;
72        friend class PickupManager;
[7494]73        // Friends.
[6710]74        friend class MetaPickup;
[6709]75
[6405]76        public:
[6474]77            PickupCarrier(); //!< Constructor.
78            virtual ~PickupCarrier(); //!< Destructor.
[11071]79            virtual void preDestroy(void) override; //!< Is called before the PickupCarrier is effectively destroyed.
[6709]80
[7547]81            bool isTarget(const Pickupable* pickup) const; //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
[7494]82            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]83
[6475]84            /**
[6540]85            @brief Get the (absolute) position of the PickupCarrier.
86                   This method needs to be implemented by any direct derivative class of PickupCarrier.
87            @return Returns the position as a Vector3.
88            */
[7547]89            virtual const Vector3& getCarrierPosition(void) const = 0;
[7163]90
91        protected:
[6475]92            /**
93            @brief Get all direct children of this PickupSpawner.
94                   This method needs to be implemented by any direct derivative class of PickupCarrier.
[6540]95                   The returned list will be deleted by the methods calling this function.
[6709]96            @return Returns a pointer to a list of all direct children.
[6475]97            */
[7547]98            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const = 0;
[6475]99            /**
[7494]100            @brief Get the parent of this PickupSpawner.
[6475]101                   This method needs to be implemented by any direct derivative class of PickupCarrier.
102            @return Returns a pointer to the parent.
103            */
[7547]104            virtual PickupCarrier* getCarrierParent(void) const = 0;
[6709]105
[6521]106            /**
107            @brief Get all Pickupables this PickupCarrier has.
108            @return  Returns the set of all Pickupables this PickupCarrier has.
109            */
[6512]110            std::set<Pickupable*>& getPickups(void)
111                { return this->pickups_; }
[7163]112
[6405]113        private:
[6475]114            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
[7163]115
[7494]116            bool addPickup(Pickupable* pickup); //!< Adds a Pickupable to the list of pickups that are carried by this PickupCarrier.
117            bool removePickup(Pickupable* pickup); //!< Removes a Pickupable from the list of pickups that are carried by this PickupCarrier.
[7163]118
119    };
120}
121
[6405]122#endif /* _PickupCarrier_H__ */
Note: See TracBrowser for help on using the repository browser.