Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 18, 2012, 10:36:24 PM (12 years ago)
Author:
landauf
Message:

removed PickupIdentifier for a number of reasons (I talked to Damian about it before)
a pickup now references the PickupRepresentation by name with the "representation" attribute

Location:
code/branches/presentation2012merge/src/modules/pickup
Files:
2 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/modules/pickup/CMakeLists.txt

    r7163 r9318  
    44  Pickup.cc
    55  PickupCollection.cc
    6   PickupCollectionIdentifier.cc
    76  PickupManager.cc
    87  PickupRepresentation.cc
  • code/branches/presentation2012merge/src/modules/pickup/Pickup.cc

    r9313 r9318  
    3636#include "core/CoreIncludes.h"
    3737#include "util/StringUtils.h"
    38 
    39 #include "pickup/PickupIdentifier.h"
    4038
    4139#include "DroppedPickup.h"
     
    8684    /**
    8785    @brief
    88         Initializes the PickupIdentififer of this Pickup.
    89     */
    90     void Pickup::initializeIdentifier(void)
    91     {
    92         this->pickupIdentifier_->addParameter("activationType", this->getActivationType());
    93         this->pickupIdentifier_->addParameter("durationType", this->getDurationType());
    94     }
    95 
    96     /**
    97     @brief
    9886        Method for creating a Pickup object through XML.
    9987    */
     
    10290        SUPER(Pickup, XMLPort, xmlelement, mode);
    10391
     92        XMLPortParam(Pickup, "representation", setRepresentationName, getRepresentationName, xmlelement, mode);
    10493        XMLPortParam(Pickup, "activationType", setActivationTypeAsString, getActivationTypeAsString, xmlelement, mode);
    10594        XMLPortParam(Pickup, "durationType", setDurationTypeAsString, getDurationTypeAsString, xmlelement, mode);
    106 
    107         this->initializeIdentifier();
    10895    }
    10996
     
    206193
    207194        Pickup* pickup = orxonox_cast<Pickup*>(item);
     195        pickup->setRepresentationName(this->getRepresentationName());
    208196        pickup->setActivationType(this->getActivationType());
    209197        pickup->setDurationType(this->getDurationType());
    210 
    211         pickup->initializeIdentifier();
    212198    }
    213199
  • code/branches/presentation2012merge/src/modules/pickup/Pickup.h

    r9313 r9318  
    105105            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    106106
     107            virtual const std::string& getRepresentationName() const
     108                { return this->representationName_; }
     109
    107110            /**
    108111            @brief Get the activation type of the Pickup.
     
    150153
    151154        protected:
    152             void initializeIdentifier(void);
     155            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    153156
    154             virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     157            /**
     158            @brief Sets the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup.
     159            */
     160            inline void setRepresentationName(const std::string& name)
     161                { this->representationName_ = name; }
    155162
    156163            /**
     
    173180            void initialize(void); //!< Initializes the member variables.
    174181
     182            std::string representationName_; //!< The name of the associated PickupRepresentation.
    175183            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
    176184            pickupDurationType::Value durationType_; //!< The duration type of the Pickup.
  • code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc

    r9296 r9318  
    3939#include "CollectiblePickup.h"
    4040#include "DroppedPickup.h"
    41 #include "PickupCollectionIdentifier.h"
    4241
    4342#include "PickupCollection.h"
     
    5453        The creator of the object.
    5554    */
    56     PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator), pickupCollectionIdentifier_(NULL)
     55    PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator)
    5756    {
    5857        RegisterObject(PickupCollection);
    5958
    60         this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
    6159        this->processingUsed_ = false;
    6260        this->processingPickedUp_ = false;
     
    7674        }
    7775        this->pickups_.clear();
    78 
    79         if(this->pickupCollectionIdentifier_ != NULL)
    80             this->pickupCollectionIdentifier_->destroy();
    8176    }
    8277
     
    8984        SUPER(PickupCollection, XMLPort, xmlelement, mode);
    9085
     86        XMLPortParam(PickupCollection, "representation", setRepresentationName, getRepresentationName, xmlelement, mode);
    9187        XMLPortObject(PickupCollection, CollectiblePickup, "pickupables", addPickupable, getPickupable, xmlelement, mode);
    9288    }
     
    217213
    218214        PickupCollection* pickup = orxonox_cast<PickupCollection*>(item);
     215        pickup->setRepresentationName(this->getRepresentationName());
    219216        // Clone all Pickupables this PickupCollection consist of.
    220217        for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
     
    243240
    244241        return true;
    245     }
    246 
    247     /**
    248     @brief
    249         Get the PickupIdentifier of this PickupCollection.
    250         This is in fact the PickupCollectionIdentifier.
    251     @return
    252         Returns a pointer to the PickupIdentifier of this PickupCollection.
    253     */
    254     const PickupIdentifier* PickupCollection::getPickupIdentifier(void) const
    255     {
    256         return this->pickupCollectionIdentifier_;
    257242    }
    258243
  • code/branches/presentation2012merge/src/modules/pickup/PickupCollection.h

    r9295 r9318  
    5050        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".
    5151
    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 
    5452        A PickupCollection can be created in XML as follows:
    5553        @code
     
    8583            virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
    8684
    87             virtual const PickupIdentifier* getPickupIdentifier(void) const; //!< Get the PickupIdentifier of this PickupCollection.
     85            inline void setRepresentationName(const std::string& name)
     86                { this->representationName_ = name; }
     87            virtual const std::string& getRepresentationName() const
     88                { return this->representationName_; }
    8889
    8990            bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
     
    101102            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    102103
    103             PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.
    104 
    105104        private:
    106105            void changedUsedAction(void); //!< Helper method.
     
    108107            void pickupsChanged(void); //!< Helper method.
    109108
     109            std::string representationName_; //!< The name of the associated PickupRepresentation.
    110110            std::list<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.
    111111
  • code/branches/presentation2012merge/src/modules/pickup/PickupManager.cc

    r8858 r9318  
    8787
    8888        this->representations_.clear();
    89         this->representationsNetworked_.clear();
    9089
    9190        // Destroying all the PickupInventoryContainers that are still there.
     
    106105    /**
    107106    @brief
    108         Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode).
    109         For every type of Pickupable (uniquely identified by a PickupIdentifier) there can be one (and just one) PickupRepresentation registered.
    110     @param identifier
    111         The PickupIdentifier identifying the Pickupable.
     107        Registers a PickupRepresentation.
     108    @param name
     109        The representation's name.
    112110    @param representation
    113111        A pointer to the PickupRepresentation.
     
    115113        Returns true if successful and false if not.
    116114    */
    117     bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    118     {
    119         assert(identifier);
     115    bool PickupManager::registerRepresentation(const std::string& name, PickupRepresentation* representation)
     116    {
    120117        assert(representation);
    121118
    122119        // If the list is not empty and Pickupable already has a Representation registered.
    123         if(!this->representations_.empty() && this->representations_.find(identifier) != this->representations_.end())
     120        if(!this->representations_.empty() && this->representations_.find(name) != this->representations_.end())
    124121            return false;
    125122
    126         this->representations_[identifier] = representation;
     123        this->representations_[name] = representation;
    127124
    128125        orxout(verbose, context::pickups) << "PickupRepresentation &" << representation << " registered with the PickupManager." << endl;
     
    132129    /**
    133130    @brief
    134         Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode).
    135     @param identifier
    136         The PickupIdentifier identifying the Pickupable.
    137     @param representation
    138         A pointer to the PickupRepresentation.
     131        Unegisters a PickupRepresentation.
     132    @param name
     133        The representation's name.
    139134    @return
    140135        Returns true if successful and false if not.
    141136    */
    142     bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    143     {
    144         assert(identifier);
    145         assert(representation);
    146 
    147         std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
     137    bool PickupManager::unregisterRepresentation(const std::string& name)
     138    {
     139        std::map<std::string, PickupRepresentation*>::iterator it = this->representations_.find(name);
    148140        if(it == this->representations_.end()) // If the Pickupable is not registered in the first place.
    149141            return false;
     
    151143        this->representations_.erase(it);
    152144
    153         orxout(verbose, context::pickups) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << endl;
     145        orxout(verbose, context::pickups) << "PickupRepresentation &" << name << " unregistered with the PickupManager." << endl;
    154146        return true;
    155147    }
     
    157149    /**
    158150    @brief
    159         Registers a PickupRepresentation on the host it was created.
    160     @param representation
    161         A pointer to the PickupRepresentation.
    162     @return
    163         Returns true if successful, false if not.
    164     */
    165     bool PickupManager::registerRepresentation(PickupRepresentation* representation)
    166     {
    167         assert(representation);
    168 
    169         // If the list is not empty and PickupRepresentation is already registered.
    170         if(!this->representationsNetworked_.empty() && this->representationsNetworked_.find(representation->getObjectID()) != this->representationsNetworked_.end())
    171             return false;
    172 
    173         this->representationsNetworked_[representation->getObjectID()] = representation;
    174         return true;
    175     }
    176 
    177     /**
    178     @brief
    179         Unregisters a PickupRepresentation on the host it is being destroyed (which is the same host on which it was created).
    180     @param representation
    181         A pointer to the Pickuprepresentation.
    182     @return
    183         Returns true if successful, false if not.
    184     */
    185     bool PickupManager::unregisterRepresentation(PickupRepresentation* representation)
    186     {
    187         assert(representation);
    188 
    189         std::map<uint32_t, PickupRepresentation*>::iterator it = this->representationsNetworked_.find(representation->getObjectID());
    190         if(it == this->representationsNetworked_.end()) // If the Pickupable is not registered in the first place.
    191             return false;
    192 
    193         this->representationsNetworked_.erase(it);
    194         return true;
    195     }
    196 
    197     /**
    198     @brief
    199         Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
    200     @param identifier
    201         The PickupIdentifier.
     151        Get the PickupRepresentation with the given name.
     152    @param name
     153        The name of the PickupRepresentation.
    202154    @return
    203155        Returns a pointer to the PickupRepresentation.
    204156    */
    205     PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)
    206     {
    207         std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
    208         if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input PickupIdentifier.
     157    PickupRepresentation* PickupManager::getRepresentation(const std::string& name)
     158    {
     159        std::map<std::string, PickupRepresentation*>::iterator it = this->representations_.find(name);
     160        if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input name.
    209161        {
    210162            orxout(verbose, context::pickups) << "PickupManager::getRepresentation() returned default representation." << endl;
     
    353305        {
    354306            // If there is no PickupRepresentation registered the default representation is used.
    355             if(this->representations_.find(pickup->getPickupIdentifier()) == this->representations_.end())
    356                 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
     307            if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end())
     308                PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickup->getRepresentationName(), pickedUp);
    357309            else
    358                 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->representations_[pickup->getPickupIdentifier()]->getObjectID(), pickedUp);
     310                PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickup->getRepresentationName(), pickedUp);
    359311        }
    360312        // If the concerned host is somewhere in the network, we call pickupChangedPickedUpNetwork() on its PickupManager.
     
    362314        {
    363315            // If there is no PickupRepresentation registered the default representation is used.
    364             if(this->representations_.find(pickup->getPickupIdentifier()) == this->representations_.end())
     316            if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end())
    365317            {
    366318                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
     
    368320            else
    369321            {
    370                 callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getPickupIdentifier()]->getObjectID(), pickedUp);
     322                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);
    371323            }
    372324        }
     
    388340        The pickedUp status the Pickupable changed to.
    389341    */
    390     /*static*/ void PickupManager::pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, bool pickedUp)
     342    /*static*/ void PickupManager::pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, const std::string& representationName, bool pickedUp)
    391343    {
    392344        PickupManager& manager = PickupManager::getInstance(); // Get the PickupManager singleton on this host.
     
    402354            container->unusable = false;
    403355            container->representationObjectId = representationObjectId;
     356            container->representationName = representationName;
    404357            // Insert the container into the pickupInventoryContainers_ list.
    405358            manager.pickupInventoryContainers_.insert(std::pair<uint32_t, PickupInventoryContainer*>(pickup, container));
     
    417370            manager.updateGUI(); // Tell the PickupInventory that something has changed.
    418371        }
    419     }
    420 
    421     /**
    422     @brief
    423         Get the PickupRepresentation of an input Pickupable.
    424         This method spares us the hassle to export the PickupIdentifier class to lua.
    425     @param pickup
    426         The number identifying the Pickupable whose PickupRepresentation should be returned.
    427     @return
    428         Returns the PickupRepresentation of the input Pickupable or NULL if an error occurred.
    429     */
    430     orxonox::PickupRepresentation* PickupManager::getPickupRepresentation(uint32_t pickup)
    431     {
    432         // Clear and rebuild the representationsNetworked_ list.
    433         //TODO: Better solution?
    434         this->representationsNetworked_.clear();
    435         for(ObjectList<PickupRepresentation>::iterator it = ObjectList<PickupRepresentation>::begin(); it != ObjectList<PickupRepresentation>::end(); ++it)
    436             this->representationsNetworked_[it->getObjectID()] = *it;
    437 
    438         // Get the container belonging to the input pickup, if not found return the default representation.
    439         std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.find(pickup);
    440         if(it == this->pickupInventoryContainers_.end())
    441             return this->defaultRepresentation_;
    442 
    443         // 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.
    444         std::map<uint32_t, PickupRepresentation*>::iterator it2 = this->representationsNetworked_.find(it->second->representationObjectId);
    445         if(it2 == this->representationsNetworked_.end())
    446             return this->defaultRepresentation_;
    447 
    448         return it2->second;
    449372    }
    450373
  • code/branches/presentation2012merge/src/modules/pickup/PickupManager.h

    r8706 r9318  
    4141#include "core/WeakPtr.h"
    4242
    43 #include "pickup/PickupIdentifier.h"
    44 
    4543#include "PickupRepresentation.h"
    4644
     
    6765        bool unusable; //!< Whether the @ref orxonox::Pickupable "Pickupable" is droppable.
    6866        uint32_t representationObjectId; //!< The objectId of the @ref orxonox::PickupRepresentation "PickupRepresentation" that represents the @ref orxonox::Pickupable "Pickupable".
     67        std::string representationName; //!< The name of the associated PickupRepresentation
    6968    };
    7069    // tolua_end
     
    7473        The PickupManager class manages @ref orxonox::Pickupable "Pickupables".
    7574
    76         It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their @ref orxonox::PickupIdentifier "PickupIdentifiers") to their respective @ref orxonox::PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref orxonox::Pickupable "Pickupables" for the covenience of the user.)
     75        It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their representation-name attribute) to the respective @ref orxonox::PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref orxonox::Pickupable "Pickupables" for the covenience of the user.)
    7776
    7877        @section PickupManagerTechnicalDetails Technical details
     
    8685
    8786        Firstly there are a number of lists (where by list I really mean any kind of ordered data structure) kept.
    88         - The @ref orxonox::PickupManager::representations_ "representations_" list links @ref orxonox::PickupRepresentation "PickupRepresentations" with @ref orxonox::PickupIdentifier "PickupIdentifiers" and can be used to get the @ref orxonox::PickupRepresentation "PickupRepresentation" for a given @ref orxonox::Pickupable "Pickupable". It is only populated on the server (or in standalone mode). Each @ref orxonox::PickupRepresentation "PickupRepresentation" that is generated through XML registers itself with the PickupManager and is thereby added to the list.
    89         - The @ref orxonox::PickupManager::representationsNetworked_ "representationsNetworked_" list is the networked (hence the name) equivalent to the @ref orxonox::PickupManager::representations_ "representations_" list. It links an objectId of a @ref orxonox::PickupRepresentation "PickupRepresentation" to a @ref orxonox::PickupRepresentation "PickupRepresentation". This list is maintained on all hosts, each representation registers itself (in its constructor) with the PickupManager. Since the representations are synchronised they are created on each host. The "same" instance on each host is identified by the same objectId and that is why we store the representations with the objectId as key. We can then use this list to get a @ref orxonox::PickupRepresentation "PickupRepresentation" for a specific @ref orxonox::Pickupable "Pickupable" (or more precisely a number identifiying that particular pickup, but we'll see that, when we look at the next list) on a client to be used in the PickupInventory.
     87        - The @ref orxonox::PickupManager::representations_ "representations_" list links @ref orxonox::PickupRepresentation "PickupRepresentations" with its name and can be used to get the @ref orxonox::PickupRepresentation "PickupRepresentation" for a given @ref orxonox::Pickupable "Pickupable". It is only populated on the server (or in standalone mode). Each @ref orxonox::PickupRepresentation "PickupRepresentation" that is generated through XML registers itself with the PickupManager and is thereby added to the list.
    9088        - The @ref orxonox::PickupManager::pickupInventoryContainers_ "pickupInventoryContainers_" list links a number identifying a @ref orxonox::Pickupable "Pickupable" to a data structure (the @ref orxonox::PickupInventoryContainer "PickupInventoryContainer"), which contains all necessary information about that @ref orxonox::Pickupable "Pickupable". This list is maintained on all hosts, a new container is inserted when a @ref orxonox::Pickupable "Pickupable" is picked up, but only if it has been picked up by the repsective host. This list is then used by the PickupInventory to access the required information and to get the correct @ref orxonox::PickupRepresentation "PickupRepresentation".
    9189        - The @ref orxonox::PickupManager::pickups_ "pickups_" list links a number identifiying a @ref orxonox::Pickupable "Pickupable" to a (weak pointer to a) @ref orxonox::Pickupable "Pickupable". It is only maintained by the server (or in standalone mode), to be able to use, unuse and drop @ref orxonox::Pickupable "Pickupables" through the PickupInventory. Since @ref orxonox::Pickupable "Pickupables" only exist on the server a client that wants to change a pickups status has so send a request over the network (with the number identifying the pickup) to the server and then the server facilitates the change, using this list to map from the identifyer to the actual @ref orxonox::Pickupable "Pickupable".
     
    114112            static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
    115113
    116             bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
    117             bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
     114            bool registerRepresentation(const std::string& name, PickupRepresentation* representation);
     115            bool unregisterRepresentation(const std::string& name);
    118116
    119             bool registerRepresentation(PickupRepresentation* representation); //!< Registers a PickupRepresentation on the host it was created.
    120             bool unregisterRepresentation(PickupRepresentation* representation); //!< Unregisters a PickupRepresentation on the host it is being destroyed.
    121 
    122             PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
     117            PickupRepresentation* getRepresentation(const std::string& name); // tolua_export
    123118
    124119            virtual void pickupChangedUsed(Pickupable* pickup, bool used); //!< Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input used state.
    125120            static void pickupChangedUsedNetwork(uint32_t pickup, bool inUse, bool usable, bool unusable); //!< Helper method to react to the change in the used status of a Pickupable.
    126121            virtual void pickupChangedPickedUp(Pickupable* pickup, bool pickedUp); //!< Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input pickedUp state.
    127             static void pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, bool pickedUp); //!< Helper method to react to the change in the pickedUp status of a Pickupable.
     122            static void pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, const std::string& representationName, bool pickedUp); //!< Helper method to react to the change in the pickedUp status of a Pickupable.
    128123
    129124        // Methods to be used by the PickupInventory.
    130125        public:
    131126            // tolua_begin
    132             orxonox::PickupRepresentation* getPickupRepresentation(uint32_t pickup); //!< Get the PickupRepresentation of an input indentifier for Pickupable.
    133 
    134127            int getNumPickups(void); //!< Get the number of pickups currently picked up by the player.
    135128            /**
     
    163156            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    164157
    165             std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types of Pickupables) and PickupRepresentations.
    166             std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the PickupRepresentation's objectId to the PickupRepresentation itself. It is used for networking purposes.
     158            std::map<std::string, PickupRepresentation*> representations_; //!< Map linking PickupRepresentations and their names.
    167159
    168160            std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all necessary information about that Pickupable.
  • code/branches/presentation2012merge/src/modules/pickup/PickupPrereqs.h

    r9269 r9318  
    7373    class Pickup;
    7474    class PickupCollection;
    75     class PickupCollectionIdentifier;
    7675    class PickupManager;
    7776    class PickupRepresentation;
  • code/branches/presentation2012merge/src/modules/pickup/PickupRepresentation.cc

    r9302 r9318  
    5252        This is primarily for use of the PickupManager in creating a default PickupRepresentation.
    5353    */
    54     PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL), pickup_(NULL)
     54    PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL)
    5555    {
    5656        RegisterObject(PickupRepresentation);
     
    6464        Default Constructor. Registers the object and initializes its member variables.
    6565    */
    66     PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL), pickup_(NULL)
     66    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL)
    6767    {
    6868        RegisterObject(PickupRepresentation);
     
    7070        this->initialize();
    7171        this->registerVariables();
    72 
    73         PickupManager::getInstance().registerRepresentation(this); // Registers the PickupRepresentation with the PickupManager.
    7472    }
    7573
     
    8482
    8583        if(this->isInitialized())
    86         {
    87             if(GameMode::isMaster() && this->pickup_ != NULL)
    88             {
    89                 PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this);
    90             }
    91             PickupManager::getInstance().unregisterRepresentation(this);
    92         }
     84            PickupManager::getInstance().unregisterRepresentation(this->getName());
    9385    }
    9486
     
    128120        XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
    129121        XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode);
    130         XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
    131122        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
    132 
    133         if(GameMode::isMaster())
    134         {
    135             // Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
    136             PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this);
    137         }
    138 
    139         if(this->spawnerRepresentation_ != NULL)
    140             this->spawnerRepresentation_->setVisible(false);
    141123
    142124        orxout(verbose, context::pickups) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << endl;
     
    172154    }
    173155
     156    void PickupRepresentation::changedName()
     157    {
     158        // Registers the PickupRepresentation with the PickupManager.
     159        PickupManager::getInstance().unregisterRepresentation(this->getOldName());
     160        PickupManager::getInstance().registerRepresentation(this->getName(), this);
     161    }
     162
     163    void PickupRepresentation::setSpawnerRepresentation(StaticEntity* representation)
     164    {
     165        this->spawnerRepresentation_ = representation;
     166        if(this->spawnerRepresentation_ != NULL)
     167            this->spawnerRepresentation_->setVisible(false);
     168    }
     169
    174170    /**
    175171    @brief
  • code/branches/presentation2012merge/src/modules/pickup/PickupRepresentation.h

    r9302 r9318  
    4141
    4242#include "interfaces/Pickupable.h"
    43 #include "pickup/PickupIdentifier.h"
    4443#include "worldentities/StaticEntity.h"
    4544
     
    5453    /**
    5554    @brief
    56         The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentifier "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.
     55        The PickupRepresentation class represents a specific pickup type. It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.
    5756        They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager".
    5857
     
    6463            spawnerTemplate = "awesomePickupRepresentation"
    6564            inventoryRepresentation = "AwesomePickup"
    66         >
    67             <pickup>
    68                 <SomePickup />
    69             </pickup>
    70         </PickupRepresentation>
     65        />
    7166        @endcode
    7267        As you might have noticed, there is a parameter called <em>spawnerTemplate</em> and also another parameter called <em>inventoryRepresentation</em>. Let's first explain the second one, <em>inventoryRepresentation</em>.
     
    133128            */
    134129            inline const std::string& getInventoryRepresentation(void) const { return this->inventoryRepresentation_; } // tolua_export
    135             /**
    136             @brief Get the Pickupable represented by this PickupRepresentation.
    137             @param index The index.
    138             @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
    139             */
    140             inline const Pickupable* getPickup(unsigned int index) const
    141                 { if(index == 0) return this->pickup_; return NULL; }
     130
     131            virtual void changedName();
    142132
    143133            StaticEntity* createSpawnerRepresentation(PickupSpawner* spawner); //!< Create a spawnerRepresentation for a specific PickupSpawner.
     
    168158            @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
    169159            */
    170             inline void setSpawnerRepresentation(StaticEntity* representation)
    171                 { this->spawnerRepresentation_ = representation; }
     160            void setSpawnerRepresentation(StaticEntity* representation);
     161
    172162            /**
    173163            @brief Set the image representing the pickup in the PickupInventory.
     
    176166            inline void setInventoryRepresentation(const std::string& image)
    177167                { this->inventoryRepresentation_ = image; }
    178             /**
    179             @brief Set the Pickupable that is represented by this PickupRepresentation.
    180             @param pickup A pointer to the Pickupable.
    181             */
    182             inline void setPickup(Pickupable* pickup)
    183                 { this->pickup_ = pickup; }
    184168
    185169        private:
     
    195179            std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory.
    196180
    197             Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
    198 
    199181    }; // tolua_export
    200182
  • code/branches/presentation2012merge/src/modules/pickup/PickupSpawner.cc

    r9302 r9318  
    9595        else
    9696        {
    97             PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
     97            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getRepresentationName());
    9898            this->attach(representation->createSpawnerRepresentation(this));
    9999            this->setActive(true);
     
    149149        else
    150150        {
    151             PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
     151            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getRepresentationName());
    152152            this->attach(representation->createSpawnerRepresentation(this));
    153153            this->setActive(true);
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc

    r9305 r9318  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/SpaceShip.h"
    4241
     
    7877    /**
    7978    @brief
    80         Initializes the PickupIdentifier of this pickup.
    81     */
    82     void DamageBoostPickup::initializeIdentifier(void)
    83     {
    84         this->pickupIdentifier_->addParameter("duration", this->getDuration());
    85         this->pickupIdentifier_->addParameter("damageMultiplier", this->getDamageMultiplier());
    86     }
    87 
    88     /**
    89     @brief
    9079        Method for creating a DamageBoostPickup object through XML.
    9180    */
     
    9685        XMLPortParam(DamageBoostPickup, "duration", setDuration, getDuration, xmlelement, mode);
    9786        XMLPortParam(DamageBoostPickup, "damageMultiplier", setDamageMultiplier, getDamageMultiplier, xmlelement, mode);
    98 
    99         this->initializeIdentifier();
    10087    }
    10188
     
    196183        pickup->setDuration(this->getDuration());
    197184        pickup->setDamageMultiplier(this->getDamageMultiplier());
    198         pickup->initializeIdentifier();
    199185    }
    200186
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.h

    r9272 r9318  
    7979
    8080        protected:
    81             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    8281            void setDamageMultiplier(float damageMultiplier); //!< Sets the DamageMultiplier according to the XML.
    8382
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc

    r9313 r9318  
    3939
    4040#include "controllers/DroneController.h"
    41 #include "pickup/PickupIdentifier.h"
    4241#include "worldentities/Drone.h"
    4342#include "worldentities/pawns/Pawn.h"
     
    8180    /**
    8281    @brief
    83         Initializes the PickupIdentifier of this pickup.
    84     */
    85     void DronePickup::initializeIdentifier(void)
    86     {
    87         this->pickupIdentifier_->addParameter("droneTemplate", this->getDroneTemplate());
    88     }
    89 
    90     /**
    91     @brief
    9282        Method for creating a DronePickup object through XML.
    9383    */
     
    9686        SUPER(DronePickup, XMLPort, xmlelement, mode);
    9787        XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode);
    98 
    99         this->initializeIdentifier();
    10088    }
    10189
     
    198186        DronePickup* pickup = orxonox_cast<DronePickup*>(item);
    199187        pickup->setDroneTemplate(this->getDroneTemplate());
    200 
    201         pickup->initializeIdentifier();
    202188    }
    203189}
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h

    r9312 r9318  
    7575
    7676        protected:
    77             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    78 
    7977            void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate.
    8078
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc

    r9312 r9318  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/Pawn.h"
    4241
     
    8786    /**
    8887    @brief
    89         Initializes the PickupIdentifier of this pickup.
    90     */
    91     void HealthPickup::initializeIdentifier(void)
    92     {
    93         this->pickupIdentifier_->addParameter("health", this->getHealth());
    94         this->pickupIdentifier_->addParameter("healthType", this->getHealthType());
    95         this->pickupIdentifier_->addParameter("healthRate", this->getHealthRate());
    96     }
    97 
    98     /**
    99     @brief
    10088        Method for creating a HealthPickup object through XML.
    10189    */
     
    11098        if(!this->isContinuous())
    11199            this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort
    112 
    113         this->initializeIdentifier();
    114100    }
    115101
     
    277263        pickup->setHealthRate(this->getHealthRate());
    278264        pickup->setHealthType(this->getHealthType());
    279 
    280         pickup->initializeIdentifier();
    281265    }
    282266
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h

    r9312 r9318  
    121121
    122122        protected:
    123             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    124 
    125123            void setHealth(float health); //!< Sets the health.
    126124            void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous.
  • code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc

    r9305 r9318  
    4040#include "core/XMLPort.h"
    4141
    42 #include "pickup/PickupIdentifier.h"
    4342#include "worldentities/pawns/Pawn.h"
    4443
     
    7978    /**
    8079    @brief
    81         Initializes the PickupIdentifier of this pickup.
    82     */
    83     void InvisiblePickup::initializeIdentifier(void)
    84     {
    85         this->pickupIdentifier_->addParameter("duration", this->getDuration());
    86     }
    87 
    88     /**
    89     @brief
    9080        Method for creating a HealthPickup object through XML.
    9181    */
     
    9484        SUPER(InvisiblePickup, XMLPort, xmlelement, mode);
    9585        XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
    96 
    97         this->initializeIdentifier();
    9886    }
    9987
     
    157145        InvisiblePickup* pickup = orxonox_cast<InvisiblePickup*>(item);
    158146        pickup->setDuration(this->getDuration());
    159         pickup->initializeIdentifier();
    160147    }
    161148
  • code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.h

    r7547 r9318  
    7272            InvisiblePickup(BaseObject* creator); //!< Constructor.
    7373            virtual ~InvisiblePickup(); //!< Destructor.
    74            
     74
    7575            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
    7676            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
     
    9191
    9292        protected:
    93             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    94 
    9593            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
    9694            void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last.
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc

    r9313 r9318  
    3636
    3737#include "interfaces/PickupCarrier.h"
    38 #include "pickup/PickupIdentifier.h"
    3938#include "worldentities/pawns/Pawn.h"
    4039
     
    8685    /**
    8786    @brief
    88         Helper method to initialize the PickupIdentifier.
    89     */
    90     void MetaPickup::initializeIdentifier(void)
    91     {
    92         this->pickupIdentifier_->addParameter("metaType", this->getMetaType());
    93     }
    94 
    95     /**
    96     @brief
    9787        Method for creating a MetaPickup object through XML.
    9888    */
     
    10292
    10393        XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode);
    104 
    105         this->initializeIdentifier();
    10694    }
    10795
     
    172160        MetaPickup* pickup = orxonox_cast<MetaPickup*>(item);
    173161        pickup->setMetaType(this->getMetaType());
    174 
    175         pickup->initializeIdentifier();
    176162    }
    177163
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h

    r9312 r9318  
    106106
    107107        protected:
    108             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    109 
    110108            /**
    111109            @brief Set the meta type of the MetaPickup.
  • code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc

    r9305 r9318  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/Pawn.h"
    4241
     
    8079    /**
    8180    @brief
    82         Initializes the PickupIdentifier of this pickup.
    83     */
    84     void ShieldPickup::initializeIdentifier(void)
    85     {
    86         this->pickupIdentifier_->addParameter("duration", this->getDuration());
    87         this->pickupIdentifier_->addParameter("ShieldHealth", this->getShieldHealth());
    88         this->pickupIdentifier_->addParameter("ShieldAbsorption", this->getShieldAbsorption());
    89     }
    90 
    91     /**
    92     @brief
    9381        Method for creating a ShieldPickup object through XML.
    9482    */
     
    10088        XMLPortParam(ShieldPickup, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode);
    10189        XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode);
    102 
    103         this->initializeIdentifier();
    10490    }
    10591
     
    188174        pickup->setShieldAbsorption(this->getShieldAbsorption());
    189175        pickup->setShieldHealth(this->getShieldHealth());
    190         pickup->initializeIdentifier();
    191176    }
    192177
  • code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.h

    r7547 r9318  
    104104
    105105        protected:
    106             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    107106            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
    108107
  • code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc

    r9305 r9318  
    4040#include "core/XMLPort.h"
    4141
    42 #include "pickup/PickupIdentifier.h"
    4342#include "worldentities/pawns/Pawn.h"
    4443
     
    8180    }
    8281
    83     void ShrinkPickup::initializeIdentifier(void)
    84     {
    85         this->pickupIdentifier_->addParameter("shrinkFactor", this->getShrinkFactor());
    86         this->pickupIdentifier_->addParameter("duration", this->getDuration());
    87         this->pickupIdentifier_->addParameter("shrinkDuration", this->getShrinkDuration());
    88     }
    89 
    9082   /**
    9183    @brief
     
    9991        XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode);
    10092        XMLPortParam(ShrinkPickup, "shrinkDuration", setShrinkDuration, getShrinkDuration, xmlelement, mode);
    101 
    102         this->initializeIdentifier();
    10393    }
    10494
     
    321311        pickup->setDuration(this->getDuration());
    322312        pickup->setShrinkDuration(this->getShrinkDuration());
    323 
    324         pickup->initializeIdentifier();
    325313    }
    326314}
  • code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.h

    r8858 r9318  
    119119                { if(speed <= 0.0f) { orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; }
    120120
    121         protected:
    122             void initializeIdentifier(void);
    123 
    124121        private:
    125122            void initialize(void);
     
    135132            float currentFactor_;       //!< The shrink factor that is currently applied.
    136133            float timeRemainig_;        //!< The remaining shrink time.
    137            
     134
    138135            Pawn* carrierToPawnHelper(void);
    139136            Timer durationTimer_;
  • code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc

    r9305 r9318  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/SpaceShip.h"
    4241
     
    8079    /**
    8180    @brief
    82         Initializes the PickupIdentifier of this pickup.
    83     */
    84     void SpeedPickup::initializeIdentifier(void)
    85     {
    86         this->pickupIdentifier_->addParameter("duration", this->getDuration());
    87         this->pickupIdentifier_->addParameter("speedAdd", this->getSpeedAdd());
    88         this->pickupIdentifier_->addParameter("speedMultiply", this->getSpeedMultiply());
    89     }
    90 
    91     /**
    92     @brief
    9381        Method for creating a SpeedPickup object through XML.
    9482    */
     
    10088        XMLPortParam(SpeedPickup, "speedAdd", setSpeedAdd, getSpeedAdd, xmlelement, mode);
    10189        XMLPortParam(SpeedPickup, "speedMultiply", setSpeedMultiply, getSpeedMultiply, xmlelement, mode);
    102 
    103         this->initializeIdentifier();
    10490    }
    10591
     
    189175        pickup->setSpeedAdd(this->getSpeedAdd());
    190176        pickup->setSpeedMultiply(this->getSpeedMultiply());
    191 
    192         pickup->initializeIdentifier();
    193177    }
    194178
  • code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.h

    r9269 r9318  
    103103
    104104        protected:
    105             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    106105            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    107106
Note: See TracChangeset for help on using the changeset viewer.