Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/PickupManager.cc @ 7869

Last change on this file since 7869 was 7801, checked in by dafrick, 14 years ago

Merging presentation2 branch back to trunk.

  • Property svn:eol-style set to native
File size: 24.9 KB
RevLine 
[6474]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:
[7494]23 *      Damian 'Mozork' Frick
[6474]24 *   Co-authors:
25 *      ...
26 *
27*/
28
29/**
[6540]30    @file PickupManager.cc
[6474]31    @brief Implementation of the PickupManager class.
32*/
33
34#include "PickupManager.h"
35
36#include "core/CoreIncludes.h"
[6711]37#include "core/LuaState.h"
38#include "core/GUIManager.h"
[6474]39#include "core/Identifier.h"
[7504]40#include "network/Host.h"
41#include "network/NetworkFunction.h"
[7539]42#include "util/ScopedSingletonManager.h"
[7533]43
[7539]44#include "infos/PlayerInfo.h"
[6474]45#include "interfaces/PickupCarrier.h"
46#include "worldentities/pawns/Pawn.h"
[7533]47
[7163]48#include "CollectiblePickup.h"
[6474]49#include "PickupRepresentation.h"
50
[6711]51#include "ToluaBindPickup.h"
52
[6474]53namespace orxonox
54{
[6711]55    // Register tolua_open function when loading the library
56    DeclareToluaInterface(Pickup);
[7163]57
[7504]58    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
[7163]59
[7533]60    // Initialization of the name of the PickupInventory GUI.
[6711]61    /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
[7163]62
[7801]63    // Register static network functions that are used to communicate changes to pickups over the network, such that the PickupInventory can display the information about the pickups properly.
[7504]64    registerStaticNetworkFunction(PickupManager::pickupChangedUsedNetwork);
65    registerStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork);
66    registerStaticNetworkFunction(PickupManager::dropPickupNetworked);
67    registerStaticNetworkFunction(PickupManager::usePickupNetworked);
68
[6474]69    /**
70    @brief
71        Constructor. Registers the PickupManager and creates the default PickupRepresentation.
72    */
[7533]73    PickupManager::PickupManager() : guiLoaded_(false), pickupHighestIndex_(0), defaultRepresentation_(NULL)
[6474]74    {
[7504]75        RegisterObject(PickupManager);
[7163]76
[6474]77        this->defaultRepresentation_ = new PickupRepresentation();
[7163]78
[6725]79        COUT(3) << "PickupManager created." << std::endl;
[6474]80    }
[7163]81
[6474]82    /**
83    @brief
84        Destructor.
[7533]85        Destroys the default PickupRepresentation and does some cleanup.
[6474]86    */
87    PickupManager::~PickupManager()
88    {
[7533]89        // Destroying the default representation.
[6474]90        if(this->defaultRepresentation_ != NULL)
91            this->defaultRepresentation_->destroy();
[7163]92
[6725]93        this->representations_.clear();
[7533]94        this->representationsNetworked_.clear();
[7163]95
[7533]96        // Destroying all the PickupInventoryContainers that are still there.
97        for(std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.begin(); it != this->pickupInventoryContainers_.end(); it++)
98            delete it->second;
99        this->pickupInventoryContainers_.clear();
[7504]100
[7533]101        // Destroying all the WeakPointers that are still there.
102        for(std::map<uint32_t, WeakPtr<Pickupable>*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
103            delete it->second;
104        this->pickups_.clear();
105
106        this->indexes_.clear();
107
[6725]108        COUT(3) << "PickupManager destroyed." << std::endl;
[6474]109    }
[7163]110
[6474]111    /**
112    @brief
[7533]113        Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode).
114        For every type of Pickupable (uniquely identified by a PickupIdentifier) there can be one (and just one) PickupRepresentation registered.
[6474]115    @param identifier
116        The PickupIdentifier identifying the Pickupable.
117    @param representation
118        A pointer to the PickupRepresentation.
119    @return
120        Returns true if successful and false if not.
121    */
[6475]122    bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
[7163]123    {
[7494]124        assert(identifier);
125        assert(representation);
126
[7533]127        // If the list is not empty and Pickupable already has a Representation registered.
128        if(!this->representations_.empty() && this->representations_.find(identifier) != this->representations_.end())
[6474]129            return false;
[7163]130
[6474]131        this->representations_[identifier] = representation;
[7163]132
[7494]133        COUT(4) << "PickupRepresentation &" << representation << " registered with the PickupManager." << std::endl;
[6474]134        return true;
135    }
[7163]136
[6474]137    /**
138    @brief
[7533]139        Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode).
[6725]140    @param identifier
141        The PickupIdentifier identifying the Pickupable.
142    @param representation
143        A pointer to the PickupRepresentation.
144    @return
145        Returns true if successful and false if not.
146    */
147    bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
[7163]148    {
[7494]149        assert(identifier);
150        assert(representation);
[7163]151
[6725]152        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
[7533]153        if(it == this->representations_.end()) // If the Pickupable is not registered in the first place.
[6725]154            return false;
[7163]155
[6725]156        this->representations_.erase(it);
[7163]157
[7494]158        COUT(4) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << std::endl;
[6725]159        return true;
160    }
[7163]161
[7533]162    /**
163    @brief
164        Registers a PickupRepresentation on the host it was created.
165    @param representation
166        A pointer to the PickupRepresentation.
167    @return
168        Returns true if successful, false if not.
169    */
170    bool PickupManager::registerRepresentation(PickupRepresentation* representation)
171    {
172        assert(representation);
173
174        // If the list is not empty and PickupRepresentation is already registered.
175        if(!this->representationsNetworked_.empty() && this->representationsNetworked_.find(representation->getObjectID()) != this->representationsNetworked_.end())
176            return false;
177
178        this->representationsNetworked_[representation->getObjectID()] = representation;
179        return true;
180    }
181
182    /**
183    @brief
184        Unregisters a PickupRepresentation on the host it is being destroyed (which is the same host on which it was created).
185    @param representation
186        A pointer to the Pickuprepresentation.
187    @return
188        Returns true if successful, false if not.
189    */
[7504]190    bool PickupManager::unregisterRepresentation(PickupRepresentation* representation)
191    {
192        assert(representation);
193
194        std::map<uint32_t, PickupRepresentation*>::iterator it = this->representationsNetworked_.find(representation->getObjectID());
[7533]195        if(it == this->representationsNetworked_.end()) // If the Pickupable is not registered in the first place.
[7504]196            return false;
197
198        this->representationsNetworked_.erase(it);
199        return true;
200    }
201
[6725]202    /**
203    @brief
[6474]204        Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
205    @param identifier
206        The PickupIdentifier.
207    @return
208        Returns a pointer to the PickupRepresentation.
209    */
210    PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)
211    {
[6475]212        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
[7533]213        if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input PickupIdentifier.
[6474]214        {
215            COUT(4) << "PickupManager::getRepresentation() returned default representation." << std::endl;
216            return this->defaultRepresentation_;
217        }
[7163]218
[6474]219        return it->second;
220    }
[7163]221
[7206]222    /**
223    @brief
[7533]224        Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input used state.
[7206]225    @param pickup
[7533]226        The Pickupable whose used status changed.
227    @param used
228        The used status the Pickupable changed to.
[7206]229    */
[7504]230    void PickupManager::pickupChangedUsed(Pickupable* pickup, bool used)
231    {
232        assert(pickup);
233
234        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
235            return;
236
237        CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(pickup);
[7533]238        // If the Pickupable is part of a PickupCollection it isn't displayed in the PickupInventory, just the PickupCollection is.
[7504]239        if(collectible != NULL && collectible->isInCollection())
240            return;
241
[7533]242        // Getting clientId of the host this change of the pickup's used status concerns.
[7504]243        PickupCarrier* carrier = pickup->getCarrier();
244        while(carrier->getCarrierParent() != NULL)
245            carrier = carrier->getCarrierParent();
246        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
247        if(pawn == NULL)
248            return;
249        PlayerInfo* info = pawn->getPlayer();
250        if(info == NULL)
251            return;
252        unsigned int clientId = info->getClientID();
253
[7533]254        // Get the number identifying the pickup.
255        std::map<Pickupable*, uint32_t>::iterator it = this->indexes_.find(pickup);
[7504]256        assert(it != this->indexes_.end());
[7533]257        uint32_t index = it->second;
[7504]258
[7533]259        // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
[7504]260        if(GameMode::isStandalone() || Host::getPlayerID() == clientId)
261        {
262            PickupManager::pickupChangedUsedNetwork(index, used, pickup->isUsable(), pickup->isUnusable());
263        }
[7533]264        // If the concerned host is somewhere in the network, we call pickupChangedUsedNetwork() on its PickupManager.
[7504]265        else
266        {
267            callStaticNetworkFunction(PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());
268        }
269    }
270
[7533]271    /**
272    @brief
273        Helper method to react to the change in the used status of a Pickupable.
274        Static method that is used by the server to inform the client it concerns about the status change.
275        The parameters that are given are used to update the information (i.e. the PickupInventoryContainer) the concerning PickupManager has about the Pickupable that changed.
276    @param pickup
277        A number identifying the Pickupable that changed its used status.
278    @param inUse
279        The used status the Pickupable changed to. (i.e. whether the Pickupable is in use or not).
280    @param usable
281        Whether the Pickupable's used status can be changed used in the PickupInventory.
282    @param unusable
283        Whether the Pickupable's used status can be changed to unused in the PickupInventory.
284    */
285    /*static*/ void PickupManager::pickupChangedUsedNetwork(uint32_t pickup, bool inUse, bool usable, bool unusable)
[7504]286    {
[7533]287        PickupManager& manager = PickupManager::getInstance(); // Get the PickupManager singleton on this host.
288        // If the input Pickupable (i.e its identifier) is not present in the list the PickupManager has.
[7504]289        if(manager.pickupInventoryContainers_.find(pickup) == manager.pickupInventoryContainers_.end())
290        {
291            COUT(1) << "Error: Pickupable &(" << pickup << ") was not registered with PickupManager for the PickupInventory, when it changed used." << std::endl;
292            return;
293        }
294
[7533]295        // Update the Pickupable's container with the information transferred.
[7504]296        manager.pickupInventoryContainers_[pickup]->inUse = inUse;
297        manager.pickupInventoryContainers_[pickup]->usable = usable;
298        manager.pickupInventoryContainers_[pickup]->unusable = unusable;
299
[7533]300        manager.updateGUI(); // Tell the PickupInventory that something has changed.
[7504]301    }
302
[7533]303    /**
304    @brief
305        Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input pickedUp state.
306    @param pickup
307        The Pickupable whose pickedUp status changed.
308    @param pickedUp
309        The pickedUp status the Pickupable changed to.
310    */
[7504]311    void PickupManager::pickupChangedPickedUp(Pickupable* pickup, bool pickedUp)
312    {
313        assert(pickup);
314
[7533]315        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
[7504]316            return;
317
318        CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(pickup);
[7533]319        // If the Pickupable is part of a PickupCollection it isn't displayed in the PickupInventory, just the PickupCollection is.
[7504]320        if(collectible != NULL && collectible->isInCollection())
321            return;
322
[7533]323        // Getting clientId of the host this change of the pickup's pickedUp status concerns.
[7504]324        PickupCarrier* carrier = pickup->getCarrier();
325        while(carrier->getCarrierParent() != NULL)
326            carrier = carrier->getCarrierParent();
327        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
328        if(pawn == NULL)
329            return;
[7533]330        PlayerInfo* info = pawn->getFormerPlayer();
[7504]331        if(info == NULL)
332            return;
333        unsigned int clientId = info->getClientID();
334
[7533]335        uint32_t index = 0;
336        if(pickedUp) // If the Pickupable has changed to picked up, it is added to the required lists.
[7504]337        {
[7533]338            index = this->getPickupIndex(); // Ge a new identifier (index) for the Pickupable.
339            // Add the Pickupable to the indexes_ and pickups_ lists.
[7504]340            this->indexes_[pickup] = index;
341            this->pickups_[index] = new WeakPtr<Pickupable>(pickup);
342        }
[7533]343        else // If it was dropped, it is removed from the required lists.
[7504]344        {
[7533]345            // Get the indentifier (index) that identifies the input Pickupable.
346            std::map<Pickupable*, uint32_t>::iterator it = this->indexes_.find(pickup);
[7504]347            index = it->second;
[7533]348
349            // Remove the Pickupable form the indexes_ and pickups_ list.
[7504]350            WeakPtr<Pickupable>* ptr = this->pickups_[index];
351            this->indexes_.erase(it);
352            this->pickups_.erase(index);
353            delete ptr;
354        }
355
[7533]356        // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
[7504]357        if(GameMode::isStandalone() || Host::getPlayerID() == clientId)
358        {
[7533]359            // If there is no PickupRepresentation registered the default representation is used.
[7531]360            if(this->representations_.find(pickup->getPickupIdentifier()) == this->representations_.end())
361                PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
362            else
363                PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->representations_[pickup->getPickupIdentifier()]->getObjectID(), pickedUp);
[7504]364        }
[7533]365        // If the concerned host is somewhere in the network, we call pickupChangedPickedUpNetwork() on its PickupManager.
[7504]366        else
367        {
[7533]368            // If there is no PickupRepresentation registered the default representation is used.
[7531]369            if(this->representations_.find(pickup->getPickupIdentifier()) == this->representations_.end())
370            {
371                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
372            }
373            else
374            {
375                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getPickupIdentifier()]->getObjectID(), pickedUp);
376            }
[7504]377        }
378
379    }
380
[7533]381    /**
382    @brief
383        Helper method to react to the change in the pickedUp status of a Pickupable.
384        Static method that is used by the server to inform the client it concerns about the status change.
385        The parameters that are given are used to update the information (i.e. the PickupInventoryContainer) the concerning PickupManager has about the Pickupable that changed.
386    @param pickup
387        A number identifying the Pickupable that changed its pickedUp status.
[7547]388    @param usable
389        Whether the Pickupable's used status can be changed to used in the PickupInventory.
[7533]390    @param representationObjectId
391        The objectId identifying (over the network) the PickupRepresentation that represents this Pickupable.
392    @param pickedUp
393        The pickedUp status the Pickupable changed to.
394    */
395    /*static*/ void PickupManager::pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, bool pickedUp)
[7504]396    {
[7533]397        PickupManager& manager = PickupManager::getInstance(); // Get the PickupManager singleton on this host.
398        // If the Pickupable has been picked up, we create a new PickupInventoryContainer for it.
[7504]399        if(pickedUp)
400        {
[7533]401            // Create a new PickupInventoryContainer for the Pickupable and set all the necessary information.
[7504]402            PickupInventoryContainer* container = new PickupInventoryContainer;
403            container->pickup = pickup;
404            container->inUse = false;
405            container->pickedUp = pickedUp;
406            container->usable = usable;
407            container->unusable = false;
408            container->representationObjectId = representationObjectId;
[7533]409            // Insert the container into the pickupInventoryContainers_ list.
410            manager.pickupInventoryContainers_.insert(std::pair<uint32_t, PickupInventoryContainer*>(pickup, container));
[7504]411
[7533]412            manager.updateGUI(); // Tell the PickupInventory that something has changed.
[7504]413        }
[7533]414        // If the Pickupable has been dropped, we remove it from the pickupInventoryContainers_ list.
[7504]415        else
416        {
[7533]417            std::map<uint32_t, PickupInventoryContainer*>::iterator it = manager.pickupInventoryContainers_.find(pickup);
[7504]418            if(it != manager.pickupInventoryContainers_.end())
419                delete it->second;
420            manager.pickupInventoryContainers_.erase(pickup);
421
[7533]422            manager.updateGUI(); // Tell the PickupInventory that something has changed.
[7504]423        }
424    }
425
[7533]426    /**
427    @brief
428        Get the PickupRepresentation of an input Pickupable.
429        This method spares us the hassle to export the PickupIdentifier class to lua.
430    @param pickup
431        The number identifying the Pickupable whose PickupRepresentation should be returned.
432    @return
433        Returns the PickupRepresentation of the input Pickupable or NULL if an error occurred.
434    */
435    orxonox::PickupRepresentation* PickupManager::getPickupRepresentation(uint32_t pickup)
436    {
437        // Clear and rebuild the representationsNetworked_ list.
438        //TODO: Better solution?
439        this->representationsNetworked_.clear();
440        for(ObjectList<PickupRepresentation>::iterator it = ObjectList<PickupRepresentation>::begin(); it != ObjectList<PickupRepresentation>::end(); ++it)
441            this->representationsNetworked_[it->getObjectID()] = *it;
442
443        // Get the container belonging to the input pickup, if not found return the default representation.
444        std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.find(pickup);
445        if(it == this->pickupInventoryContainers_.end())
446            return this->defaultRepresentation_;
447
448        // Get the PickupRepresentation of the input pickup (through the objecId of the representation stored in the PickupInventoryContainer belonging to the pickup), if not found return the default representation.
449        std::map<uint32_t, PickupRepresentation*>::iterator it2 = this->representationsNetworked_.find(it->second->representationObjectId);
450        if(it2 == this->representationsNetworked_.end())
451            return this->defaultRepresentation_;
452
453        return it2->second;
454    }
455
456    /**
457    @brief
458        Get the number of pickups currently picked up by the player.
459        This method is used in lua to populate the PickupInventory. The intended usage is to call this method to reset the iterator of the list of PickupInventoryContainers and then use popPickup() to get the individual PickupInventoryContainers.
460    @return
461        Returns the number of the players picked up Pickupables.
462    */
463    int PickupManager::getNumPickups(void)
464    {
465        this->pickupsIterator_ = this->pickupInventoryContainers_.begin(); // Reset iterator.
466
467        return this->pickupInventoryContainers_.size();
468    }
469
470    /**
471    @brief
472        Drop the input Pickupable.
473        This method checks whether the input Pickupable still exists and drops it, if so.
474    @param pickup
475        The identifier of the Pickupable to be dropped.
476    */
477    void PickupManager::dropPickup(uint32_t pickup)
478    {
479        // If we're either server or standalone and the list of pickups is not empty, we find and drop the input pickup.
[7539]480        if(GameMode::isMaster())
[7533]481        {
[7539]482            if(this->pickups_.empty())
483                return;
[7533]484            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
485            if(pickupable != NULL)
486                pickupable->drop();
487        }
488        // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server.
489        else
490        {
491            callStaticNetworkFunction(PickupManager::dropPickupNetworked, 0, pickup);
492        }
493    }
494
495    /**
496    @brief
497        Helper method to drop the input pickup on the server.
498        Static method that is used by clients to instruct the server to drop the input pickup.
499    @param pickup
500        The identifier of the Pickupable to be dropped.
501    */
502    /*static*/ void PickupManager::dropPickupNetworked(uint32_t pickup)
503    {
504        if(GameMode::isServer()) // Obviously we only want to do this on the server.
505        {
506            PickupManager& manager = PickupManager::getInstance();
[7539]507            manager.dropPickup(pickup);
[7533]508        }
509    }
510
511    /**
512    @brief
513        Use (or unuse) the input Pickupable.
514        This method checks whether the input Pickupable still exists and uses (or unuses) it, if so,
515    @param pickup
516        The identifier of the Pickupable to be used (or unused).
517    @param use
518        If true the input Pickupable is used, if false it is unused.
519    */
520    void PickupManager::usePickup(uint32_t pickup, bool use)
521    {
522        // If we're either server or standalone and the list of pickups is not empty, we find and change the used status of the input pickup.
[7539]523        if(GameMode::isMaster())
[7533]524        {
[7539]525            if(this->pickups_.empty())
526                return;
[7533]527            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
528            if(pickupable != NULL)
529                pickupable->setUsed(use);
530        }
531        // If we're neither server nor standalone we change the used status of the pickup by calling usePickupNetworked() of the PickupManager on the server.
532        else
533        {
534            callStaticNetworkFunction(PickupManager::usePickupNetworked, 0, pickup, use);
535        }
536    }
537
538    /**
539    @brief
540        Helper method to use (or unuse) the input Pickupable on the server.
541        Static method that is used by clients to instruct the server to use (or unuse) the input pickup.
542    @param pickup
543        The identifier of the Pickupable to be used (or unused).
544    @param use
545        If true the input Pickupable is used, if false it is unused.
546    */
547    /*static*/ void PickupManager::usePickupNetworked(uint32_t pickup, bool use)
548    {
549        if(GameMode::isServer())
550        {
551            PickupManager& manager = PickupManager::getInstance();
[7539]552            manager.usePickup(pickup, use);
[7533]553        }
554    }
555
556    /**
557    @brief
558        Updates the PickupInventory GUI.
559        Also loads the PickupInventory GUI if is hasn't been done already.
560    */
[7504]561    inline void PickupManager::updateGUI(void)
562    {
[7533]563        // We only need to update (and load) the GUI if this host shows graphics.
[7504]564        if(GameMode::showsGraphics())
565        {
[7533]566            if(!this->guiLoaded_) // If the GUI hasn't been loaded, yet, we load it.
[7504]567            {
568                GUIManager::getInstance().loadGUI(PickupManager::guiName_s);
569                this->guiLoaded_ = true;
570            }
[7533]571
572            // Update the GUI.
[7504]573            GUIManager::getInstance().getLuaState()->doString(PickupManager::guiName_s + ".update()");
574        }
575    }
576
[7533]577    /**
578    @brief
579        Get a new index for a Pickupable.
580        This will work as long as the number of Pickupables that are picked up is sufficiently small and as long as they don't exist forever.
581    @return
582        Returns the new index.
583    */
584    uint32_t PickupManager::getPickupIndex(void)
[7504]585    {
[7533]586        if(this->pickupHighestIndex_ == uint32_t(~0x0)-1) // If we've reached the highest possible number, we wrap around.
587            this->pickupHighestIndex_ = 0;
588        return this->pickupHighestIndex_++;
[7504]589    }
590
[6474]591}
Note: See TracBrowser for help on using the repository browser.