Changeset 7494 for code/trunk/src/modules/pickup
- Timestamp:
- Sep 28, 2010, 5:31:59 PM (14 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/CollectiblePickup.cc
r7285 r7494 35 35 36 36 #include "core/CoreIncludes.h" 37 37 38 #include "PickupCollection.h" 38 39 -
code/trunk/src/modules/pickup/CollectiblePickup.h
r7493 r7494 46 46 The CollectiblePickup class encompasses all @ref orxonox::Pickupable "Pickupables" that can be added to a @ref orxonox::PickupCollection "PickupCollection" and thus be part of such. 47 47 48 All you need to do to make your @ref orxonox: .Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup Pickupclass, for example, is already a CollectiblePickup).48 All you need to do to make your @ref orxonox::Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup "Pickup" class, for example, is already a CollectiblePickup). 49 49 50 50 @author … … 63 63 /** 64 64 @brief Check whether the given CollectiblePickup is par of a PickupCollection. 65 @return Returns true if the Col elctiblePickup is part of a PickupCollection.65 @return Returns true if the CollectiblePickup is part of a PickupCollection. 66 66 */ 67 67 bool isInCollection(void) 68 68 { return this->isInCollection_; } 69 69 70 70 bool addToCollection(PickupCollection* collection); //!< Adds this CollectiblePickup to the input PickupCollection. 71 71 bool removeFromCollection(void); //!< Removes this CollectiblePickup from its PickupCollection. … … 75 75 protected: 76 76 virtual void preDestroy(void); //!< Is called by OrxonoxClass::destroy() before the object is actually destroyed. 77 virtual void destroyPickup(void); //!< //!<Destroys a Pickupable.77 virtual void destroyPickup(void); //!< Destroys a Pickupable. 78 78 79 79 private: -
code/trunk/src/modules/pickup/DroppedPickup.cc
r7493 r7494 35 35 36 36 #include "core/CoreIncludes.h" 37 37 38 #include "interfaces/Pickupable.h" 38 39 #include "interfaces/PickupCarrier.h" 39 #include "graphics/Model.h"40 40 41 41 namespace orxonox -
code/trunk/src/modules/pickup/Pickup.cc
r7401 r7494 36 36 #include "core/CoreIncludes.h" 37 37 #include "util/StringUtils.h" 38 38 39 #include "pickup/PickupIdentifier.h" 40 39 41 #include "DroppedPickup.h" 40 41 #include "tools/Timer.h"42 42 43 43 namespace orxonox … … 51 51 CreateUnloadableFactory(Pickup); 52 52 53 /** 54 @brief 55 Constructor. Registers and initializes the object. 56 @param creator 57 The objects creator. 58 */ 53 59 Pickup::Pickup(BaseObject* creator) : BaseObject(creator) 54 60 { … … 58 64 } 59 65 66 /** 67 @brief 68 Destructor. 69 */ 60 70 Pickup::~Pickup() 61 71 { … … 158 168 else 159 169 { 160 COUT(1) << "Invalid activationType in pickup." << std::endl;170 COUT(1) << "Invalid activationType '" << type << "' in pickup." << std::endl; 161 171 } 162 172 } … … 180 190 else 181 191 { 182 COUT(1) << "Invalid durationType in pickup." << std::endl;192 COUT(1) << "Invalid durationType '" << type << "' in pickup." << std::endl; 183 193 } 184 194 } … … 193 203 SUPER(Pickup, changedPickedUp); 194 204 195 // !Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.205 // Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up. 196 206 if(this->isPickedUp() && this->isImmediate()) 197 {198 207 this->setUsed(true); 199 } 200 } 201 202 /** 203 @brief 204 Creates a duplicate of the Pickup. 205 @return 206 Returns the clone of this pickup as a pointer to a Pickupable. 208 } 209 210 /** 211 @brief 212 Creates a duplicate of the OrxonoxClass. 213 @param item 214 A reference to the pointer of the item that we're duplicating. 207 215 */ 208 216 void Pickup::clone(OrxonoxClass*& item) -
code/trunk/src/modules/pickup/Pickup.h
r7456 r7494 48 48 { 49 49 50 //! Enum for the activation type.50 //! Enum for the @ref orxonox::Pickup "Pickup" activation type. 51 51 namespace pickupActivationType 52 52 { 53 53 enum Value 54 54 { 55 immediate, 56 onUse, 55 immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup. 56 onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence. 57 57 }; 58 58 } 59 59 60 //! Enum for the duration tyoe.60 //! Enum for the @ref orxonox::Pickup "Pickup" duration type. 61 61 namespace pickupDurationType 62 62 { 63 63 enum Value 64 64 { 65 once, 66 continuous, 65 once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant. 66 continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan. 67 67 }; 68 68 } … … 70 70 /** 71 71 @brief 72 Pickup class. Offers base functionality for a wide range of pickups. 73 Pickups ingeriting from this class cann choose an activation type and a duration type. 72 The Pickup class offers (useful) base functionality for a wide range of pickups. 73 74 Pickups ingeriting from this class can choose an activation type and a duration type. 75 - The <b>activation type</b> deals with what happens to the Pickup as soon as it is picked up. It can either be set to <em>immediate</em>, which means that the Pickup is activated/used immediately upon being picked up. Or to <em>onUse</em>, which means, that the Pickup will be activated/used if some outside entity (most commonly the player through the PickupInventory) decides to use it. 76 - The <b>duration type</b> deals with whether the Pickup has a continuous effect or whether its effect is focused on a singular instant. It can either be set to <em>once</em>, which means, that the Pickup just has an effect (at a singular instant in time) and is done once that effect has been applied. Or to <em>continuous</em>, which means that the effect of the Pickup unfolds over some timespan. 77 78 If it were not an abstract class it could for example be used as follows in XML. 79 @code 80 <Pickup activationType="onUse" durationType="continuous" /> 81 @endcode 82 In reality you can (naturally) use the parameters <b>activation type</b> and <b>duration type</b> in any pickup inheriting from Pickup, unless the pickup already specifies one (or both) of the parameters. 83 74 84 @author 75 85 Damian 'Mozork' Frick … … 85 95 86 96 /** 87 @brief Get the activation type of the pickup.88 @return Returns the activation type of the pickup.97 @brief Get the activation type of the Pickup. 98 @return Returns the activation type of the Pickup. 89 99 */ 90 100 inline pickupActivationType::Value getActivationTypeDirect(void) 91 101 { return this->activationType_; } 92 102 /** 93 @brief Get the duration type of the pickup.94 @return Returns the duration type of the pickup.103 @brief Get the duration type of the Pickup. 104 @return Returns the duration type of the Pickup. 95 105 */ 96 106 inline pickupDurationType::Value getDurationTypeDirect(void) 97 107 { return this->durationType_; } 98 108 99 const std::string& getActivationType(void); //!< Get the activation type of the pickup.100 const std::string& getDurationType(void); //!< Get the duration type of the pickup.109 const std::string& getActivationType(void); //!< Get the activation type of the Pickup. 110 const std::string& getDurationType(void); //!< Get the duration type of the Pickup. 101 111 102 112 /** … … 127 137 virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around. 128 138 129 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.139 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the OrxonoxClass. 130 140 131 141 protected: … … 135 145 136 146 /** 137 @brief Set the activation type of the pickup.138 @param type The activation type of the pickup.147 @brief Set the activation type of the Pickup. 148 @param type The activation type of the Pickup. 139 149 */ 140 150 inline void setActivationTypeDirect(pickupActivationType::Value type) 141 151 { this->activationType_ = type; } 142 152 /** 143 @brief Set the duration type of the pickup.144 @param type The duration type of the pickup.153 @brief Set the duration type of the Pickup. 154 @param type The duration type of the Pickup. 145 155 */ 146 156 inline void setDurationTypeDirect(pickupDurationType::Value type) 147 157 { this->durationType_ = type; } 148 158 149 void setActivationType(const std::string& type); //!< Set the activation type of the pickup.150 void setDurationType(const std::string& type); //!< Set the duration type of the pickup159 void setActivationType(const std::string& type); //!< Set the activation type of the Pickup. 160 void setDurationType(const std::string& type); //!< Set the duration type of the Pickup. 151 161 152 162 private: … … 154 164 155 165 pickupActivationType::Value activationType_; //!< The activation type of the Pickup. 156 pickupDurationType::Value durationType_; //!< The duration type of the pickup.166 pickupDurationType::Value durationType_; //!< The duration type of the Pickup. 157 167 158 168 //! Strings for the activation and duration types. -
code/trunk/src/modules/pickup/PickupCollection.cc
r7401 r7494 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 36 37 #include "interfaces/PickupCarrier.h" 38 37 39 #include "CollectiblePickup.h" 38 40 #include "DroppedPickup.h" … … 49 51 @brief 50 52 Default Constructor. 53 @param creator 54 The creator of the object. 51 55 */ 52 56 PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator) … … 201 205 /** 202 206 @brief 203 Creates a duplicate of the input OrxonoxClass.207 Creates a duplicate of the input Pickupable. 204 208 This method needs to be implemented by any Class inheriting from Pickupable. 205 209 @param item -
code/trunk/src/modules/pickup/PickupCollection.h
r7456 r7494 48 48 /** 49 49 @brief 50 The PickupCollection combines different Pickupables to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one Pickupable. 50 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". 51 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 54 A PickupCollection can be created in XML as follows: 55 @code 56 <PickupCollection> 57 <pickupables> 58 <CollectiblePickup ... /> 59 ... 60 <CollectiblePickup ... /> 61 </pickupables> 62 </PickupCollection> 63 @endcode 64 51 65 @author 52 66 Damian 'Mozork' Frick … … 65 79 virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around. 66 80 67 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.81 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input pickup. 68 82 69 83 virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. … … 88 102 void changedUsedAction(void); //!< Helper method. 89 103 void changedPickedUpAction(void); //!< Helper method. 90 104 91 105 std::vector<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. 92 106 -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
r7401 r7494 67 67 int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const 68 68 { 69 assert(identifier); 70 69 71 // Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier. 70 72 PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier); 71 const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);73 const PickupCollectionIdentifier* collectionIdentifier = orxonox_cast<PickupCollectionIdentifier*>(temp); 72 74 73 75 // If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared. … … 92 94 } 93 95 94 // !Means they are equal.96 // Means they are equal. 95 97 return 0; 96 98 } -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
r7456 r7494 38 38 #include "PickupPrereqs.h" 39 39 40 #include <set> 41 40 42 #include "pickup/PickupIdentifier.h" 41 42 #include <set>43 43 44 44 namespace orxonox … … 47 47 /** 48 48 @brief 49 The PickupCollectionIdentifier is the specialization of the PickupIdentifier for the PickupCollection class. 50 It identifies PickupCollections based on the different Pickupables they consist of. 51 Pickupables can be added to the PickupCollectionIdentifier via the addPickup method. 49 The PickupCollectionIdentifier is the specialization of the PickupIdentifier for the @ref orxonox::PickupCollection "PickupCollection" class. 50 It identifies @ref orxonox::PickupCollection "PickupCollections" based on the different @ref orxonox::CollectiblePickup "CollectiblePickups" they consist of. 51 52 @ref orxonox::Pickupable "Pickupables" (resp. @ref orxonox::CollectiblePickup "CollectiblePickups") can be added to the PickupCollectionIdentifier via the addPickup method. 52 53 @author 53 54 Damian 'Mozork' Frick … … 62 63 virtual int compare(const PickupIdentifier* identifier) const; //!< Compares a PickupCollectionIdentifier with a PickupIdentifier. 63 64 64 void addPickup(const PickupIdentifier* identifier); //!< Add a Pickupableto the PickupCollectionIdentifier.65 void addPickup(const PickupIdentifier* identifier); //!< Add a @ref orxonox::Pickupable "Pickupable" to the PickupCollectionIdentifier. 65 66 66 67 private: 67 std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the Pickupables the PickupCollection with this PickupCollectionIdentifier consists of, ordered by the rule set by PickupIdentifierCompare.68 std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the @ref orxonox::Pickupable "Pickupables", the @ref orxonox::PickupCollection "PickupCollection" with this PickupCollectionIdentifier consists of, ordered by the rule set by @ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare". 68 69 69 70 }; -
code/trunk/src/modules/pickup/PickupManager.cc
r7284 r7494 21 21 * 22 22 * Author: 23 * ...23 * Damian 'Mozork' Frick 24 24 * Co-authors: 25 25 * ... … … 100 100 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 101 101 { 102 if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered. 102 assert(identifier); 103 assert(representation); 104 105 if(this->representations_.find(identifier) != this->representations_.end()) // If the Pickupable already has a Representation registered. 103 106 return false; 104 107 105 108 this->representations_[identifier] = representation; 106 109 107 COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;110 COUT(4) << "PickupRepresentation &" << representation << " registered with the PickupManager." << std::endl; 108 111 return true; 109 112 } … … 121 124 bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 122 125 { 123 if(identifier == NULL || representation == NULL)124 return false;126 assert(identifier); 127 assert(representation); 125 128 126 129 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier); … … 130 133 this->representations_.erase(it); 131 134 132 COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl;135 COUT(4) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << std::endl; 133 136 return true; 134 137 } … … 167 170 if(pickup != NULL) 168 171 return this->getRepresentation(pickup->getPickupIdentifier()); 169 172 170 173 return NULL; 171 174 } … … 268 271 if(pickup == NULL) 269 272 return; 270 273 271 274 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); // Get the WeakPointer of the Pickupable. 272 275 // If either the input Pickupable is not in the PickupManagers list or it no longer exists, the method returns. -
code/trunk/src/modules/pickup/PickupSpawner.h
r7456 r7494 51 51 The PickupSpawner class is responsible for spawning pickups of a specific type. 52 52 Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things. 53 53 54 @author 54 55 Daniel 'Huty' Haggenmueller 56 @author 55 57 Damian 'Mozork' Frick 56 58 */
Note: See TracChangeset
for help on using the changeset viewer.