Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h @ 3063

Last change on this file since 3063 was 3001, checked in by danielh, 16 years ago
  • Added helper method to HumanController to get it's ControllableEntity as a Pawn
  • Removed tooltip, added default (empty) values for text and image from BaseItem
  • Fixed tolua in BaseItem.h
  • Added object to PickupCollection for the current UsableItem
  • Moved most inventory logic from Lua to PickupInventory (still slow)

TODO

  • Re-use of CEGUI item windows, destroying and creating them on each update is slow, very slow
  • Property svn:eol-style set to native
File size: 5.0 KB
RevLine 
[2917]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:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Definition of PickupCollection.
32*/
33
34#ifndef _PickupCollection_H__
35#define _PickupCollection_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include <map>
[2972]40#include <deque>
[2917]41#include <string>
42
43#include "util/Math.h" 
44
45#include "ModifierType.h"
46
47namespace orxonox
48{
49    class BaseItem;
[2972]50    class EquipmentItem;
51    class PassiveItem;
[2917]52    class UsableItem;
53    class Pawn;
54
55    /**
56        @brief PickupCollection for organising items.
57        @author Daniel 'Huty' Haggenmueller
58    */
59    class _OrxonoxExport PickupCollection
60    {
61    public:
62        PickupCollection();
63
64        bool add(BaseItem* item);       //!< Add an item to the collection.
65
66        bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.
67
68        void clear();                   //!< Empty the collection
69        bool contains(BaseItem* item, bool anyOfType = false);                      //!< Check if the collection contains an item.
70
71        void remove(BaseItem* item, bool removeAllOfType = false);                  //!< Remove an item from the collection.
72
73        void useItem();                                                             //!< Use the first usable item.
74        void useItem(UsableItem* item);                                             //!< Use a usable item.
75
76        void addAdditiveModifier(ModifierType::Enum type, float value);             //!< Add an additive modifier.
77        void addMultiplicativeModifier(ModifierType::Enum type, float value);       //!< Add a multiplicative modifier.
78
79        float getAdditiveModifier(ModifierType::Enum type);                         //!< Get total additive modifier.
80        float getMultiplicativeModifier(ModifierType::Enum type);                   //!< Get total multiplicative modifier.
81
82        void removeAdditiveModifier(ModifierType::Enum type, float value);          //!< Remove an additive modifier.
83        void removeMultiplicativeModifier(ModifierType::Enum type, float value);    //!< Remove a multiplicative modifier.
84
85        float processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication = false);        //!< Apply the modifiers to a float.
86        Vector3 processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication = false);    //!< Apply the modifiers to a Vector3.
87
88        /**
89            @brief Get the map of contained items.
90            @return The map of items.
91        */
92        std::multimap<std::string, BaseItem*> getItems() const
93            { return this->items_; }
94
95        /**
96            @brief Get the owner of the PickupCollection.
97            @return Returns the pawn which owns the PickupCollection.
98        */
99        inline Pawn* getOwner() const 
100            { return this->owner_; }
101        /**
102            @brief Set the owner of the PickupCollection.
103            @param owner The new Pawn which owns the PickupCollection.
104        */
105        inline void setOwner(Pawn* owner)
106            { this->owner_ = owner; }
107
[3001]108        inline UsableItem* getCurrentUsable()
109            { return this->currentUsable_; };
110        inline void setCurrentUsable(UsableItem* usable)
111            { this->currentUsable_ = usable; }
112
[2972]113        std::deque<EquipmentItem*> getEquipmentItems();   //!< Get a list of equipment-type items.
114        std::deque<PassiveItem*> getPassiveItems();     //!< Get a list of passive items.
115        std::deque<UsableItem*> getUsableItems();      //!< Get a list of usable items.
[2917]116    private:
117        Pawn* owner_;           //!< The owner of the PickupCollection.
[3001]118        UsableItem* currentUsable_;
[2917]119
120        bool bBlockRemovals_;   //!< Whether to block direct removals through remove().
121
122        std::multimap<ModifierType::Enum, float> additiveModifiers_;        //!< Contains additive modifiers (indexed by ModifierType).
123        std::multimap<ModifierType::Enum, float> multiplicativeModifiers_;  //!< Contains multiplicative modifiers (indexed by ModifierType).
124
125        std::multimap<std::string, BaseItem*> items_;                       //!< Map of items in the collection (indexed by pickupIdentifier of the items).
126    };
127}
128
129#endif /* _PickupCollection_H__ */
Note: See TracBrowser for help on using the repository browser.