Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/lastmanstanding3/src/modules/pickup/PickupCollection.h @ 8368

Last change on this file since 8368 was 7547, checked in by dafrick, 14 years ago

Documenting and cleanup.

  • Property svn:eol-style set to native
File size: 5.7 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 PickupCollection.h
31    @brief Declaration of PickupCollection.
32    @ingroup Pickup
33*/
34
35#ifndef _PickupCollection_H__
36#define _PickupCollection_H__
37
38#include "PickupPrereqs.h"
39
40#include <list>
41
42#include "CollectiblePickup.h"
43#include "core/BaseObject.h"
44
45namespace orxonox
46{
47
48    /**
49    @brief
50        The PickupCollection combines different @ref orxonox::Pickupable "Pickupables" (more precisely @ref orxonox::CollectiblePickup "CollectiblePickups") to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one @ref orxonox::Pickupable "Pickupable".
51
52        To differentiate between different types of @ref orxonox::PickupCollection "PickupCollections" (just as we differentiate between different types of @ref orxonox::Pickupable "Pickupables") we define a new identifyer called the @ref orxonox::PickupCollectionIdentifier "PickupCollectionIdentifier" which has pretty much the same properties as the @ref orxonox::PickupIdentifier "PickupIdentifier" but extende to @ref orxonox::PickupCollection "PickupCollections".
53
54        A PickupCollection can be created in XML as follows:
55        @code
56        <PickupCollection>
57            <pickupables>
58                <CollectiblePickup ... />
59                ...
60                <CollectiblePickup ... />
61            </pickupables>
62        </PickupCollection>
63        @endcode
64
65    @author
66        Damian 'Mozork' Frick
67
68    @ingroup Pickup
69    */
70    class _PickupExport PickupCollection : public CollectiblePickup, public BaseObject
71    {
72
73        public:
74            PickupCollection(BaseObject* creator); //!< Default Constructor.
75            virtual ~PickupCollection(); //!< Destructor.
76
77            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates an instance of this Class through XML.
78
79            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
80            virtual void changedCarrier(void); //!< Is called when the pickup has changed its PickupCarrier.
81            virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around.
82
83            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input pickup.
84
85            virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
86
87            virtual const PickupIdentifier* getPickupIdentifier(void) const; //!< Get the PickupIdentifier of this PickupCollection.
88
89            bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
90            const Pickupable* getPickupable(unsigned int index) const; //!< Get the Pickupable at the given index.
91
92            void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value.
93            void pickupChangedPickedUp(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value.
94            void pickupDisabled(void); //!< Informs the PickupCollection, that one of its pickups has been disabled.
95
96        protected:
97            void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup.
98
99            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
100
101            PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.
102
103        private:
104            void changedUsedAction(void); //!< Helper method.
105            void changedPickedUpAction(void); //!< Helper method.
106
107            std::vector<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid.
108
109            unsigned int usedCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are in use.
110            unsigned int pickedUpCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are picked up.
111            unsigned int disabledCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are disabled.
112
113            bool processingUsed_; //!< Boolean to ensure, that the PickupCollection doesn't update its used status while its internal state is inconsistent.
114            bool processingPickedUp_; //!< Boolean to ensure, that the PickupCollection doesn't update its picked upp status while its internal state is inconsistent.
115
116    };
117
118}
119
120#endif /* _PickupCollection_H__ */
Note: See TracBrowser for help on using the repository browser.