Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ScriptableController_HS17/src/orxonox/interfaces/PickupCarrier.h @ 11663

Last change on this file since 11663 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
Line 
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/**
30    @file PickupCarrier.h
31    @brief Definition of the PickupCarrier class.
32    @ingroup Pickup
33*/
34
35#ifndef _PickupCarrier_H__
36#define _PickupCarrier_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include <set>
41#include <vector>
42
43#include "core/class/OrxonoxInterface.h"
44
45namespace orxonox
46{
47
48    // Forward-declarations.
49    class MetaPickup;
50
51    /**
52    @brief
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.
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".
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.
62
63    @author
64        Damian 'Mozork' Frick
65
66    @ingroup Pickup
67    */
68    class _OrxonoxExport PickupCarrier : virtual public OrxonoxInterface
69    {
70        // So that the different Pickupables have full access to their PickupCarrier.
71        friend class Pickupable;
72        friend class PickupManager;
73        // Friends.
74        friend class MetaPickup;
75
76        public:
77            PickupCarrier(); //!< Constructor.
78            virtual ~PickupCarrier(); //!< Destructor.
79            virtual void preDestroy(void) override; //!< Is called before the PickupCarrier is effectively destroyed.
80
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.
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.
83
84            /**
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            */
89            virtual const Vector3& getCarrierPosition(void) const = 0;
90
91        protected:
92            /**
93            @brief Get all direct children of this PickupSpawner.
94                   This method needs to be implemented by any direct derivative class of PickupCarrier.
95                   The returned list will be deleted by the methods calling this function.
96            @return Returns a pointer to a list of all direct children.
97            */
98            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const = 0;
99            /**
100            @brief Get the parent of this PickupSpawner.
101                   This method needs to be implemented by any direct derivative class of PickupCarrier.
102            @return Returns a pointer to the parent.
103            */
104            virtual PickupCarrier* getCarrierParent(void) const = 0;
105
106            /**
107            @brief Get all Pickupables this PickupCarrier has.
108            @return  Returns the set of all Pickupables this PickupCarrier has.
109            */
110            std::set<Pickupable*>& getPickups(void)
111                { return this->pickups_; }
112
113        private:
114            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
115
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.
118
119    };
120}
121
122#endif /* _PickupCarrier_H__ */
Note: See TracBrowser for help on using the repository browser.