Changeset 6725 for code/trunk/src/modules/pickup
- Timestamp:
- Apr 13, 2010, 10:39:54 PM (15 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/PickupManager.cc
r6711 r6725 51 51 DeclareToluaInterface(Pickup); 52 52 53 ManageScopedSingleton(PickupManager, ScopeID:: Root, false);53 ManageScopedSingleton(PickupManager, ScopeID::Graphics, false); 54 54 55 55 /*static*/ const std::string PickupManager::guiName_s = "PickupInventory"; … … 64 64 65 65 this->defaultRepresentation_ = new PickupRepresentation(); 66 67 COUT(3) << "PickupManager created." << std::endl; 66 68 } 67 69 … … 75 77 if(this->defaultRepresentation_ != NULL) 76 78 this->defaultRepresentation_->destroy(); 79 80 this->representations_.clear(); 81 82 COUT(3) << "PickupManager destroyed." << std::endl; 77 83 } 78 84 … … 89 95 */ 90 96 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 91 { 92 if( this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered.97 { 98 if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered. 93 99 return false; 94 100 … … 96 102 97 103 COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl; 104 return true; 105 } 106 107 /** 108 @brief 109 Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 110 @param identifier 111 The PickupIdentifier identifying the Pickupable. 112 @param representation 113 A pointer to the PickupRepresentation. 114 @return 115 Returns true if successful and false if not. 116 */ 117 bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 118 { 119 if(identifier == NULL || representation == NULL) 120 return false; 121 122 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier); 123 if(it == this->representations_.end()) //!< If the Pickupable is not registered in the first place. 124 return false; 125 126 this->representations_.erase(it); 127 128 COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl; 98 129 return true; 99 130 } -
code/trunk/src/modules/pickup/PickupManager.h
r6711 r6725 67 67 68 68 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 69 bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 69 70 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 70 71 -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r6711 r6725 49 49 This is primarily for use of the PickupManager in creating a default PickupRepresentation. 50 50 */ 51 PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL) 51 PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL), pickup_(NULL) 52 52 { 53 53 RegisterObject(PickupRepresentation); … … 60 60 Default Constructor. Registers the object and initializes its member variables. 61 61 */ 62 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL) 62 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL), pickup_(NULL) 63 63 { 64 64 RegisterObject(PickupRepresentation); … … 75 75 if(this->spawnerRepresentation_ != NULL) 76 76 this->spawnerRepresentation_->destroy(); 77 78 if(this->pickup_ != NULL) 79 PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this); 77 80 } 78 81 … … 87 90 this->spawnerTemplate_ = ""; 88 91 this->inventoryRepresentation_ = "Default"; 89 this->pickup_ = NULL;90 92 } 91 93
Note: See TracChangeset
for help on using the changeset viewer.