Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2010, 10:44:10 PM (14 years ago)
Author:
dafrick
Message:

Loads of changes.
1) PickupInventory should now be working even for extreme cases.
2) Added support for inactive Spawnpoints in Gametype.
3) Made Pickupable rewardble. meaning from now on any Pickupable can be given as a reward for completing Quests.
4) Added some keybinds to KeybindMenu, such as PickupInventory, QuestGUI and Chat.

Location:
code/branches/presentation3/src/modules/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/pickup/PickupManager.cc

    r6965 r6996  
    3939#include "core/ScopedSingletonManager.h"
    4040#include "core/Identifier.h"
     41#include "util/Convert.h"
    4142#include "interfaces/PickupCarrier.h"
    4243#include "infos/PlayerInfo.h"
     
    6465       
    6566        this->defaultRepresentation_ = new PickupRepresentation();
    66         this->pickupsIndex_ = 0;
    6767       
    6868        COUT(3) << "PickupManager created." << std::endl;
     
    154154    {
    155155        this->pickupsList_.clear();
    156         this->pickupsIndex_ = 0;
    157156       
    158157        PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s);
     
    169168            for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++)
    170169            {
    171                 this->pickupsList_.insert(*pickup);
     170                this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup)));
    172171            }
    173172        }
     
    199198    void PickupManager::dropPickup(orxonox::Pickupable* pickup)
    200199    {
     200        std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup);
     201        if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL)
     202            return;
     203
    201204        if(!pickup->isPickedUp())
    202205            return;
    203        
     206
    204207        PickupCarrier* carrier = pickup->getCarrier();
    205208        if(pickup != NULL && carrier != NULL)
     209        {
    206210            carrier->drop(pickup);
     211        }
    207212    }
    208213
    209214    void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use)
    210215    {
     216        std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup);
     217        if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL)
     218            return;
     219       
    211220        if(!pickup->isPickedUp())
    212221            return;
  • code/branches/presentation3/src/modules/pickup/PickupManager.h

    r6965 r6996  
    3939#include <map>
    4040#include "util/Singleton.h"
     41#include "core/WeakPtr.h"
    4142#include "pickup/PickupIdentifier.h"
    4243#include "PickupRepresentation.h"
     
    7273            // tolua_begin
    7374            int getNumPickups(void);
    74             orxonox::Pickupable* popPickup(void) { this->pickupsIndex_++; return *(this->pickupsIterator_++); }
    75             int getPickupIndex(void) { return this->pickupsIndex_-1; }
     75            orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; }
    7676            orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; }
    7777
    7878            void dropPickup(orxonox::Pickupable* pickup);
    7979            void usePickup(orxonox::Pickupable* pickup, bool use);
     80            bool isValidPickup(orxonox::Pickupable* pickup) { std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); if(it == this->pickupsList_.end()) return false; return it->second.get() != NULL; }
    8081            // tolua_end
    8182           
     
    8788            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
    8889
    89             std::set<Pickupable*> pickupsList_;
    90             std::set<Pickupable*>::iterator pickupsIterator_;
    91             int pickupsIndex_;
     90            std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_;
     91            std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_;
    9292
    9393            std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier);
Note: See TracChangeset for help on using the changeset viewer.