Changeset 6475 for code/branches/pickup3/src/modules/pickup
- Timestamp:
- Mar 5, 2010, 6:26:54 PM (15 years ago)
- Location:
- code/branches/pickup3/src/modules/pickup
- Files:
-
- 15 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/modules/pickup/CMakeLists.txt
r6466 r6475 1 1 SET_SOURCE_FILES(PICKUP_SRC_FILES 2 Dropped Item.cc2 DroppedPickup.cc 3 3 Pickup.cc 4 4 PickupCollection.cc -
code/branches/pickup3/src/modules/pickup/DroppedPickup.cc
r6466 r6475 23 23 * Daniel 'Huty' Haggenmueller 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ 28 28 29 #include "DroppedItem.h" 29 /** 30 @file 31 @brief Implementation of the DroppedPickup class. 32 */ 33 34 #include "DroppedPickup.h" 30 35 31 36 #include "core/CoreIncludes.h" … … 37 42 /** 38 43 @brief 39 Constructor. Registers object and sets default values.44 Default constructor. Registers object and sets default values. 40 45 */ 41 Dropped Item::DroppedItem(BaseObject* creator) : PickupSpawner(creator)46 DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator) 42 47 { 48 RegisterObject(DroppedPickup); 49 43 50 this->initialize(); 44 }45 46 DroppedItem::DroppedItem(BaseObject* creator, Pickupable* item, const Vector3& position, float triggerDistance) : PickupSpawner(creator, item, triggerDistance, 0, 1)47 {48 this->initialize();49 50 this->createDrop(position);51 }52 53 void DroppedItem::initialize(void)54 {55 RegisterObject(DroppedItem);56 57 this->gotPickedUp_ = false;58 51 } 59 52 60 53 /** 61 54 @brief 62 Default destructor. 55 Constructor. Registers the object and sets values. 56 @param creator 57 The creator of the DroppedPickup. 58 @param pickup 59 The Pickupable that was dropped. 60 @param position 61 The position at which the DroppedPickup should be created. 62 @param triggerDistance 63 The distance at which the PickupSpawner triggers. Default is 10. 63 64 */ 64 DroppedItem::~DroppedItem() 65 DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 0, 1) 66 { 67 RegisterObject(DroppedPickup); 68 69 this->initialize(); 70 71 this->setPosition(position); 72 } 73 74 /** 75 @brief 76 Destructor. 77 */ 78 DroppedPickup::~DroppedPickup() 65 79 { 66 80 if(this->gotPickedUp_ && this->pickup_ != NULL) … … 69 83 } 70 84 } 85 86 /** 87 @brief 88 Initializes the member variables of the object. 89 */ 90 void DroppedPickup::initialize(void) 91 { 92 this->gotPickedUp_ = false; 93 } 71 94 72 Pickupable* DroppedItem::getPickup(void) 95 /** 96 @brief 97 Creates the Pickupable that is going to get picked up. 98 In the case of the DroppedItem it is the one and only Pickupable that was dropped. No additional Pickupables of the same type are created. 99 */ 100 Pickupable* DroppedPickup::getPickup(void) 73 101 { 74 102 return this->pickup_; 75 103 } 76 77 //TODO; Doesn't seem to be needed anymore, just put setPosition in the constructor.78 void DroppedItem::createDrop(const Vector3& position)79 {80 this->setPosition(position);81 82 //TODO: Make this work.83 //const Model& model = PickupManager::getModel(item->getPickupIdentifier());84 //this->attach(model);85 }86 104 87 //TODO: Remove.88 //TODO: Comment.89 //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.90 // /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)91 // {92 // //TODO: triggerDistance?93 // float triggerDistance = 20.0;94 // DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1);95 //96 // //TODO: Do this somehwere else?97 // Model* model = new Model(item);98 // Billboard* billboard = new Billboard(item);99 //100 // model->setMeshSource("sphere.mesh");101 // model->setScale(3.0f);102 //103 // billboard->setMaterial("Examples/Flare");104 // billboard->setColour(flareColour);105 // billboard->setScale(0.5f);106 //107 // droppedItem->setPosition(position);108 // droppedItem->attach(model);109 // droppedItem->attach(billboard);110 //111 // COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;112 //113 // return droppedItem;114 // }115 116 //TODO: See one function above.117 // DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)118 // {119 // Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);120 // return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive);121 // }122 105 } -
code/branches/pickup3/src/modules/pickup/DroppedPickup.h
r6466 r6475 23 23 * Daniel 'Huty' Haggenmueller 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ … … 29 29 /** 30 30 @file 31 @brief Definition of DroppedItem31 @brief Definition of the DroppedPickup class. 32 32 */ 33 33 34 #ifndef _Dropped Item_H__35 #define _Dropped Item_H__34 #ifndef _DroppedPickup_H__ 35 #define _DroppedPickup_H__ 36 36 37 37 #include "PickupPrereqs.h" … … 41 41 namespace orxonox 42 42 { 43 class _OrxonoxExport DroppedItem : public PickupSpawner 43 44 /** 45 @brief 46 Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped. 47 @author 48 Daniel 'Huty' Haggenmueller 49 Damian 'Mozork' Frick 50 */ 51 class _OrxonoxExport DroppedPickup : public PickupSpawner 44 52 { 45 53 public: 46 Dropped Item(BaseObject* creator);47 Dropped Item(BaseObject* creator, Pickupable* item, const Vector3& position, float triggerDistance);48 virtual ~Dropped Item();54 DroppedPickup(BaseObject* creator); //!< Default constructor. 55 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor. 56 virtual ~DroppedPickup(); //!< Destructor. 49 57 50 58 protected: 51 virtual Pickupable* getPickup(void); 59 virtual Pickupable* getPickup(void); //!< Creates the Pickupable that is going to get picked up. 52 60 53 61 private: 54 void initialize(void); 55 void createDrop(const Vector3& position); 62 void initialize(void); //!< Initializes the member variables of the object. 56 63 57 bool gotPickedUp_; 64 bool gotPickedUp_; //!< Whether the pickup got picked up or not. 58 65 59 66 }; 60 67 } 61 68 62 #endif /* _Dropped Item_H__ */69 #endif /* _DroppedPickup_H__ */ -
code/branches/pickup3/src/modules/pickup/Pickup.cc
r6474 r6475 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "util/StringUtils.h" 33 #include "pickup/PickupIdentifier.h" 34 #include "DroppedPickup.h" 32 35 33 36 namespace orxonox … … 38 41 /*static*/ const std::string Pickup::durationTypeOnce_s = "once"; 39 42 /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous"; 40 /*static*/ const std::string Pickup::blankString_s = ""; 41 42 //TODO: Should this bee here? Does it work without? 43 44 //TODO: Should this be here? Does it work without? 43 45 CreateFactory(Pickup); 44 46 … … 47 49 RegisterObject(Pickup); 48 50 51 this->initialize(); 49 52 } 50 53 … … 54 57 } 55 58 59 /** 60 @brief 61 Initializes the member variables. 62 */ 63 void Pickup::initialize(void) 64 { 65 this->activationType_ = pickupActivationType::immediate; 66 this->durationType_ = pickupDurationType::once; 67 } 68 69 /** 70 @brief 71 Initializes the PickupIdentififer of this Pickup. 72 */ 56 73 void Pickup::initializeIdentifier(void) 57 74 { 58 this->pickupIdentifier_.addClass(this->getIdentifier()); 75 //TODO: Check whether this could not be done in the Constructor if Pickupable. Would be much more convenient. 76 this->pickupIdentifier_->addClass(this->getIdentifier()); 59 77 60 78 //TODO: Works? 61 79 std::string val1 = this->getActivationType(); 62 80 std::string type1 = "activationType"; 63 this->pickupIdentifier_ .addParameter(type1, val1);81 this->pickupIdentifier_->addParameter(type1, val1); 64 82 65 83 std::string val2 = this->getDurationType(); 66 84 std::string type2 = "durationType"; 67 this->pickupIdentifier_.addParameter(type2, val2); 68 } 69 85 this->pickupIdentifier_->addParameter(type2, val2); 86 } 87 88 /** 89 @brief 90 Method for creating a Pickup object through XML. 91 */ 70 92 void Pickup::XMLPort(Element& xmlelement, XMLPort::Mode mode) 71 93 { … … 81 103 @brief 82 104 Get the activation type of the pickup. 83 @ param buffer84 The buffer to store the activation type as string in.105 @return 106 Returns a string containing the activation type. 85 107 */ 86 108 const std::string& Pickup::getActivationType(void) … … 93 115 return activationTypeOnUse_s; 94 116 default: 95 return blankString_s;117 return BLANKSTRING; 96 118 } 97 119 } … … 100 122 @brief 101 123 Get the duration type of the pickup. 102 @ param buffer103 The buffer to store the duration type as string in.124 @return 125 Returns a string containing the duration type. 104 126 */ 105 127 const std::string& Pickup::getDurationType(void) … … 112 134 return durationTypeContinuous_s; 113 135 default: 114 return blankString_s;136 return BLANKSTRING; 115 137 } 116 138 } … … 162 184 /** 163 185 @brief 164 Creates a duplicate of the pickup. 186 Should be called when the pickup has transited from picked up to dropped or the other way around. 187 Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method. 188 */ 189 void Pickup::changedCarrier(void) 190 { 191 SUPER(Pickup, changedCarrier); 192 193 //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up. 194 if(this->isPickedUp() && this->isImmediate()) 195 { 196 this->setUsed(true); 197 } 198 } 199 200 /** 201 @brief 202 Creates a duplicate of the Pickup. 165 203 @return 166 204 Returns the clone of this pickup as a pointer to a Pickupable. … … 179 217 pickup->initializeIdentifier(); 180 218 } 181 182 void Pickup::changedCarrier(void) 183 { 184 SUPER(Pickup, changedCarrier); 185 186 if(this->isPickedUp() && this->isImmediate()) 187 { 188 this->setUsed(true); 189 } 219 220 /** 221 @brief 222 Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 223 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 224 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position); 225 @param position 226 The position at which the PickupSpawner should be placed. 227 @return 228 Returns true if a spawner was created, false if not. 229 */ 230 bool Pickup::createSpawner(const Vector3& position) 231 { 232 DroppedPickup::DroppedPickup(this, this, position); 233 return true; 190 234 } 191 235 -
code/branches/pickup3/src/modules/pickup/Pickup.h
r6474 r6475 28 28 29 29 #ifndef _Pickup_H__ 30 #define Pickup_H__30 #define _Pickup_H__ 31 31 32 32 #include "pickup/PickupPrereqs.h" 33 33 34 #include "interfaces/Pickupable.h"35 34 #include "core/BaseObject.h" 36 35 #include "core/XMLPort.h" 36 37 #include "interfaces/Pickupable.h" 37 38 38 39 namespace orxonox … … 59 60 } 60 61 62 /** 63 @brief 64 Pickup class. Offers base functionality for a wide range of pickups. 65 Pickups ingeriting from this class cann choose an activation type and a duration type. 66 @author 67 Damian 'Mozork' Frick 68 */ 61 69 class _PickupExport Pickup : public Pickupable, public BaseObject 62 70 { 63 71 64 72 public: 65 66 Pickup(BaseObject* creator); 67 virtual ~Pickup(); 73 Pickup(BaseObject* creator); //!< Constructor. 74 virtual ~Pickup(); //!< Destructor. 68 75 69 76 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 85 92 const std::string& getDurationType(void); //!< Get the duration type of the pickup. 86 93 94 /** 95 @brief Get whether the activation type is 'immediate'. 96 @return Returns true if the activation type is 'immediate'. 97 */ 87 98 inline bool isImmediate(void) 88 99 { return this->getActivationTypeDirect() == pickupActivationType::immediate; } 100 /** 101 @brief Get whether the activation type is 'onUse'. 102 @return Returns true if the activation type is 'onUse'. 103 */ 89 104 inline bool isOnUse(void) 90 105 { return this->getActivationTypeDirect() == pickupActivationType::onUse; } 106 /** 107 @brief Get whether the duration type is 'once'. 108 @return Returns true if the duration type is 'once'. 109 */ 91 110 inline bool isOnce(void) 92 111 { return this->getDurationTypeDirect() == pickupDurationType::once; } 112 /** 113 @brief Get whether the duration type is 'continuous'. 114 @return Returns true if the duration type is 'continuous'. 115 */ 93 116 inline bool isContinuous(void) 94 117 { return this->getDurationTypeDirect() == pickupDurationType::continuous; } 95 96 virtual void clone(OrxonoxClass* item);97 118 98 virtual void changedCarrier(void); 119 virtual void changedCarrier(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around. 120 121 virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the Pickup. 99 122 100 123 protected: 101 124 void initializeIdentifier(void); 125 126 virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 102 127 103 128 /** … … 118 143 119 144 private: 145 void initialize(void); //!< Initializes the member variables. 146 120 147 pickupActivationType::Value activationType_; //!< The activation type of the Pickup. 121 148 pickupDurationType::Value durationType_; //!< The duration type of the pickup. … … 125 152 static const std::string durationTypeOnce_s; 126 153 static const std::string durationTypeContinuous_s; 127 static const std::string blankString_s; //TODO: Maybe already implemented somewhere?128 154 129 155 }; -
code/branches/pickup3/src/modules/pickup/PickupCollection.cc
r6466 r6475 38 38 #include "core/XMLPort.h" 39 39 #include "interfaces/PickupCarrier.h" 40 #include "DroppedPickup.h" 41 42 #include "PickupCollectionIdentifier.h" 40 43 41 44 namespace orxonox … … 49 52 { 50 53 RegisterObject(PickupCollection); 54 55 this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(); 51 56 } 52 57 … … 60 65 for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 61 66 { 62 delete *it;67 (*it)->destroy(); 63 68 } 64 69 } … … 80 85 void PickupCollection::initializeIdentifier(void) 81 86 { 82 this->pickupCollectionIdentifier_ .addClass(this->getIdentifier());87 this->pickupCollectionIdentifier_->addClass(this->getIdentifier()); 83 88 84 89 for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 85 90 { 86 this->pickupCollectionIdentifier_ .addPickup((*it)->getPickupIdentifier());91 this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier()); 87 92 } 93 } 94 95 /** 96 @brief 97 Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 98 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 99 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position); 100 @param position 101 The position at which the PickupSpawner should be placed. 102 @return 103 Returns true if a spawner was created, false if not. 104 */ 105 bool PickupCollection::createSpawner(const Vector3& position) 106 { 107 DroppedPickup::DroppedPickup(this, this, position); 108 return true; 88 109 } 89 110 … … 159 180 } 160 181 182 const PickupIdentifier* PickupCollection::getPickupIdentifier(void) 183 { 184 return this->pickupCollectionIdentifier_; 185 } 186 161 187 } -
code/branches/pickup3/src/modules/pickup/PickupCollection.h
r6466 r6475 36 36 #include "core/XMLPort.h" 37 37 38 #include "PickupCollectionIdentifier.h"39 40 38 #include <list> 41 39 … … 66 64 virtual void clone(OrxonoxClass* item); 67 65 68 virtual const PickupIdentifier* getPickupIdentifier(void) 69 { return &this->pickupCollectionIdentifier_; } 66 virtual const PickupIdentifier* getPickupIdentifier(void); 70 67 71 68 bool addPickupable(Pickupable* pickup); … … 75 72 void initializeIdentifier(void); 76 73 77 PickupCollectionIdentifier pickupCollectionIdentifier_; 74 virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 75 76 PickupCollectionIdentifier* pickupCollectionIdentifier_; 78 77 79 78 private: -
code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc
r6474 r6475 44 44 } 45 45 46 int PickupCollectionIdentifier::compare(const PickupIdentifier &identifier) const46 int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const 47 47 { 48 PickupIdentifier* temp = const_cast<PickupIdentifier*>( &identifier);48 PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier); 49 49 const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp); 50 50 if(collectionIdentifier == NULL) … … 60 60 { 61 61 62 if((*it)->compare(* *it2) < 0)62 if((*it)->compare(*it2) < 0) 63 63 return -1; 64 if((*it2)->compare(* *it) < 0)64 if((*it2)->compare(*it) < 0) 65 65 return 1; 66 66 } -
code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h
r6474 r6475 45 45 ~PickupCollectionIdentifier(); 46 46 47 virtual int compare(const PickupIdentifier &identifier) const;47 virtual int compare(const PickupIdentifier* identifier) const; 48 48 49 49 void addPickup(const PickupIdentifier* identifier); 50 50 51 51 private: 52 std::set<const PickupIdentifier*, PickupIdentifier PtrCompare> identifiers_;52 std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; 53 53 54 54 }; -
code/branches/pickup3/src/modules/pickup/PickupManager.cc
r6474 r6475 83 83 */ 84 84 //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort. 85 bool PickupManager::registerRepresentation(const PickupIdentifier &identifier, PickupRepresentation* representation)85 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 86 86 { 87 87 if(this->representations_.find(identifier) == this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered. … … 104 104 PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier) 105 105 { 106 std::map<const PickupIdentifier , PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(*identifier);106 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier); 107 107 if(it == this->representations_.end()) 108 108 { -
code/branches/pickup3/src/modules/pickup/PickupManager.h
r6474 r6475 71 71 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } 72 72 73 bool registerRepresentation(const PickupIdentifier &identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.73 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 74 74 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 75 75 … … 81 81 82 82 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 83 std::map<const PickupIdentifier , PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.83 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 84 84 85 85 //TODO: Delete or utilize this. -
code/branches/pickup3/src/modules/pickup/PickupPrereqs.h
r6466 r6475 66 66 { 67 67 68 class Dropped Item;68 class DroppedPickup; 69 69 class Pickup; 70 70 class PickupCollection; -
code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc
r6474 r6475 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "graphics/Billboard.h" 33 #include "util/StringUtils.h" 32 34 #include "PickupManager.h" 33 #include "graphics/Billboard.h"34 35 35 36 namespace orxonox … … 38 39 CreateFactory(PickupRepresentation); 39 40 41 /** 42 @brief 43 Constructor. Registers the object and initializes its member variables. 44 This is primarily for use of the PickupManager in creating a default PickupRepresentation. 45 */ 40 46 PickupRepresentation::PickupRepresentation() : BaseObject(this) 41 47 { … … 45 51 } 46 52 53 /** 54 @brief 55 Default Constructor. Registers the object and initializes its member variables. 56 */ 47 57 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator) 48 58 { … … 52 62 } 53 63 64 /** 65 @brief 66 Destructor. 67 */ 54 68 PickupRepresentation::~PickupRepresentation() 55 69 { 56 70 if(this->spawnerRepresentation_ != NULL) 71 this->spawnerRepresentation_->destroy(); 57 72 } 58 73 74 /** 75 @brief 76 Initializes the member variables of this PickupRepresentation. 77 */ 59 78 void PickupRepresentation::initialize(void) 60 79 { … … 66 85 } 67 86 87 /** 88 @brief 89 Method for creating a PickupRepresentation object through XML. 90 */ 68 91 void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode) 69 92 { … … 76 99 XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode); 77 100 78 PickupManager::getInstance().registerRepresentation( *this->pickup_->getPickupIdentifier(), this);101 PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents. 79 102 } 80 103 104 /** 105 @brief 106 Get a spawnerRepresentation for a specific PickupSpawner. 107 @param spawner 108 A pointer to the PickupSpawner. 109 @return 110 Returns a pointer to the StaticEntity. 111 */ 81 112 StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner) 82 113 { … … 84 115 { 85 116 COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl; 86 if(this->spawnerTemplate_ == "")117 if(this->spawnerTemplate_ == BLANKSTRING) 87 118 { 88 119 COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl; 120 //!< If neither spawnerRepresentation nor spawnerTemplate was specified 89 121 return this->getDefaultSpawnerRepresentation(spawner); 90 122 } 91 123 this->addTemplate(this->spawnerTemplate_); 92 124 } 125 93 126 StaticEntity* representation = this->spawnerRepresentation_; 94 127 … … 98 131 } 99 132 133 /** 134 @brief 135 Get the default spawnerRepresentation for a specific PickupSpawner. 136 Helper method of internal use. 137 @param spawner 138 A pointer to the PickupSpawner. 139 @return 140 Returns a pointer to the StaticEntity. 141 */ 142 //TODO: Think of more elegant solution. 100 143 StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner) 101 144 { -
code/branches/pickup3/src/modules/pickup/PickupRepresentation.h
r6474 r6475 32 32 #include "PickupPrereqs.h" 33 33 34 #include "core/XMLPort.h" 35 #include "interfaces/Pickupable.h" 36 #include "pickup/PickupIdentifier.h" 37 #include "worldentities/StaticEntity.h" 38 #include "PickupSpawner.h" 39 34 40 #include "core/BaseObject.h" 35 36 #include "core/XMLPort.h"37 #include "pickup/PickupIdentifier.h"38 #include "interfaces/Pickupable.h"39 #include "pickup/PickupSpawner.h"40 #include "worldentities/StaticEntity.h"41 41 42 42 namespace orxonox 43 43 { 44 44 45 /** 46 @brief 47 The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like. 48 They are created through XML and are registered with the PickupManager. 49 */ 45 50 class _PickupExport PickupRepresentation : public BaseObject 46 51 { 47 52 48 53 public: 49 PickupRepresentation(); 50 PickupRepresentation(BaseObject* creator); 51 virtual ~PickupRepresentation(); 54 PickupRepresentation(); //!< Constructor 55 PickupRepresentation(BaseObject* creator); //!< Default constructor. 56 virtual ~PickupRepresentation(); //!< Destructor. 52 57 53 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 59 60 /** 61 @brief Set the name of the Pickupable represented by this PickupRepresentation. 62 @param name The name. 63 */ 55 64 inline void setName(const std::string& name) 56 65 { this->name_ = name; } 66 /** 67 @brief Set the description of the Pickupable represented by this PickupRepresentation. 68 @param description The Description. 69 */ 57 70 inline void setDescription(const std::string& description) 58 71 { this->description_ = description; } 72 /** 73 @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation. 74 The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. 75 @param spawnerTemplate The name of the template. 76 */ 59 77 inline void setSpawnerTemplate(const std::string& spawnerTemplate) 60 78 { this->spawnerTemplate_ = spawnerTemplate; } 79 /** 80 @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. 81 This will be set by the spawnerTemplate. Setting it when creating the PickupRepresentation without creating a template and specifying its name will be futile, because through the course of the game many PickupSpawners for one specific pickup type may have to be created, thus the StaticEntity that is the spawnerRepresentation has to be generated (with the template) for every new PickupSpawner spawning the Pickupable represented by this PickupRepresentation. The spawnerRepresentation that is set here, however can only be used once. 82 @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. 83 */ 61 84 inline void setSpawnerRepresentation(StaticEntity* representation) 62 85 { this->spawnerRepresentation_ = representation; } 86 /** 87 @brief Set the Pickupable that is represented by this PickupRepresentation. 88 @param pickup A pointer to the Pickupable. 89 */ 63 90 inline void setPickup(Pickupable* pickup) 64 91 { this->pickup_ = pickup; } 65 92 93 /** 94 @brief Get the name of the Pickupable represented by this PickupRepresentation. 95 @return Returns the name. 96 */ 66 97 inline const std::string& getName(void) 67 98 { return this->name_; } 99 /** 100 @brief Get the description of the Pickupable represented by this PickupRepresentation. 101 @return Returns the description. 102 */ 68 103 inline const std::string& getDescription(void) 69 104 { return this->description_; } 105 /** 106 @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. 107 @return Returns the name of the spawnerTemplate. 108 */ 70 109 inline const std::string& getSpawnerTemplate(void) 71 110 { return this->spawnerTemplate_; } 111 /** 112 @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. 113 @param index The index. 114 @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL. 115 */ 72 116 inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) 73 117 { if(index == 0) return this->spawnerRepresentation_; return NULL; } 118 /** 119 @brief Get the Pickupable represented by this PickupRepresentation. 120 @param index The index. 121 @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL. 122 */ 74 123 inline const Pickupable* getPickup(unsigned int index) 75 124 { if(index == 0) return this->pickup_; return NULL; } 76 125 77 StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); 126 StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner. 78 127 79 128 private: 80 void initialize(void); 81 StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); 129 void initialize(void); //!< Initializes the member variables of this PickupRepresentation. 130 StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. 82 131 83 std::string name_; 84 std::string description_; 85 std::string spawnerTemplate_; 86 StaticEntity* spawnerRepresentation_; 132 std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. 133 std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation. 134 std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. 135 StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. 87 136 88 Pickupable* pickup_; 89 137 Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. 90 138 91 139 }; -
code/branches/pickup3/src/modules/pickup/PickupSpawner.cc
r6474 r6475 35 35 36 36 #include "core/CoreIncludes.h" 37 //#include "core/GUIManager.h" // HACK; see below38 37 #include "core/Template.h" 39 38 #include "core/XMLPort.h" … … 41 40 #include "PickupManager.h" 42 41 #include "PickupRepresentation.h" 43 //#include "PickupInventory.h" // HACK; Only for hack, remove later44 45 42 46 43 namespace orxonox 47 44 { 48 49 // const float PickupSpawner::bounceSpeed_s = 6.0f;50 // const float PickupSpawner::rotationSpeed_s = 1.0f;51 // const float PickupSpawner::bounceDistance_s = 4.0f;52 45 53 46 CreateFactory(PickupSpawner); … … 64 57 65 58 this->initialize(); 66 67 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(NULL);68 this->attach(representation->getSpawnerRepresentation(this));69 59 } 70 60 … … 95 85 this->setMaxSpawnedItems(maxSpawnedItems); 96 86 97 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 98 this->attach(representation->getSpawnerRepresentation(this)); 87 if(this->pickup_ == NULL) 88 { 89 COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl; 90 this->setActive(false); 91 } 92 else 93 { 94 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 95 this->attach(representation->getSpawnerRepresentation(this)); 96 } 99 97 } 100 98 … … 109 107 this->triggerDistance_ = 20; 110 108 this->respawnTime_ = 0; 111 this->tickSum_ = 0;112 109 this->maxSpawnedItems_ = INF; 113 110 this->spawnsRemaining_ = INF; … … 141 138 XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode); 142 139 XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode); 143 144 //TODO: Kill hack. 145 // HACKs 146 // Load the GUI image as soon as the PickupSpawner gets loaded 147 // = less delays while running 148 // BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this); 149 // BaseItem* asItem = orxonox_cast<BaseItem*>(newObject); 150 // if (asItem) 151 // { 152 // asItem->addTemplate(this->itemTemplate_); 153 // PickupInventory::getImageForItem(asItem); 154 // newObject->destroy(); 155 // } 156 157 // & load the GUI itself too, along with some empty windows 158 // = even less delays 159 // GUIManager::getInstance().showGUI("PickupInventory"); 160 // GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")"); 161 // PickupInventory::getSingleton(); 140 141 if(this->pickup_ == NULL) 142 { 143 COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl; 144 this->setActive(false); 145 } 146 else 147 { 148 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 149 this->attach(representation->getSpawnerRepresentation(this)); 150 } 151 } 152 153 /** 154 @brief 155 Invoked when the activity has changed. Sets visibility of attached objects. 156 */ 157 void PickupSpawner::changedActivity() 158 { 159 SUPER(PickupSpawner, changedActivity); 160 161 for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++) 162 { 163 (*it)->setVisible(this->isActive()); 164 } 165 } 166 167 /** 168 @brief 169 Tick, checks if any Pawn is close enough to trigger. 170 @param dt 171 Time since last tick. 172 */ 173 //TODO: Replace this with a real DistanceTrigger? Or better with collisions? 174 void PickupSpawner::tick(float dt) 175 { 176 //! If the PickupSpawner is active. 177 if (this->isActive()) 178 { 179 //! Iterate trough all Pawns. 180 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 181 { 182 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 183 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance. 184 if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it)) 185 { 186 this->trigger(*it); 187 } 188 } 189 } 190 } 191 192 /** 193 @brief 194 Sets the maximum number of spawned items. 195 @param items 196 The maximum number of spawned items to be set. 197 */ 198 void PickupSpawner::setMaxSpawnedItems(int items) 199 { 200 this->maxSpawnedItems_ = items; 201 this->spawnsRemaining_ = items; 202 } 203 204 /** 205 @brief 206 Decrements the number of remaining spawns. 207 Sets the PickupSpawner to inactive for the duration of the respawnTime. 208 Destroys the PickupSpawner if the number of remaining spawns has reached zero. 209 */ 210 void PickupSpawner::decrementSpawnsRemaining(void) 211 { 212 if(this->spawnsRemaining_ != INF) 213 { 214 this->spawnsRemaining_--; 215 } 216 if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0) 217 { 218 //TODO: Nicer? Does this even work? 219 this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this))); 220 221 this->setActive(false); 222 this->fireEvent(); 223 } 224 else 225 { 226 COUT(3) << "PickupSpawner empty, selfdestruct initialized." << std::endl; 227 this->setActive(false); 228 this->destroy(); 229 } 162 230 } 163 231 … … 172 240 if(this->pickup_ != NULL) 173 241 { 174 COUT(1) << " addPickupable called, with this->pickup_ already set." << std::endl;242 COUT(1) << "In PickupSpawner: setPickupable called, with this->pickup_ already set." << std::endl; 175 243 return; 176 244 } 177 245 if(pickup == NULL) 178 246 { 179 COUT(1) << " Argument of addPickupable is NULL." << std::endl;247 COUT(1) << "In PickupSpawner: Argument of setPickupable is NULL." << std::endl; 180 248 return; 181 249 } … … 197 265 /** 198 266 @brief 199 Invoked when the activity has changed. Sets visibility of attached objects.200 */201 // void PickupSpawner::changedActivity()202 // {203 // SUPER(PickupSpawner, changedActivity);204 //205 // for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)206 // (*it)->setVisible(this->isActive());207 // }208 209 /**210 @brief211 Sets the maximum number of spawned items.212 @param items213 The maximum number of spawned items to be set.214 */215 void PickupSpawner::setMaxSpawnedItems(int items)216 {217 this->maxSpawnedItems_ = items;218 this->spawnsRemaining_ = items;219 }220 221 /**222 @brief223 Tick, checks if any Pawn is close enough to trigger.224 @param dt225 Time since last tick.226 */227 //TODO: Replace this with a real DistanceTrigger? Or better with collisions?228 void PickupSpawner::tick(float dt)229 {230 //! If the PickupSpawner is active.231 if (this->isActive())232 {233 //! Iterate trough all Pawns.234 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)235 {236 Vector3 distance = it->getWorldPosition() - this->getWorldPosition();237 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.238 if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))239 {240 this->trigger(*it);241 }242 }243 244 //! Animation.245 // this->yaw(Radian(rotationSpeed_s*dt));246 // this->tickSum_ += bounceSpeed_s*dt;247 // this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));248 // if (this->tickSum_ > 2*Ogre::Math::PI)249 // this->tickSum_ -= 2*Ogre::Math::PI;250 }251 }252 253 /**254 @brief255 267 Trigger the PickupSpawner. 256 257 Adds the pickup to the Pawn that triggered, 258 sets the timer to re-activate and deactives the PickupSpawner. 259 268 Adds the pickup to the Pawn that triggered, sets the timer to re-activate and deactives the PickupSpawner. 260 269 @param pawn 261 270 Pawn which triggered the PickupSpawner. 262 271 */ 272 //TODO: Make more generic -> without pawn. 263 273 void PickupSpawner::trigger(Pawn* pawn) 264 274 { 265 //TODO: If private, isActive doesn't need to be tested anymore.266 275 if (this->isActive()) //!< Checks whether PickupItem is active. 267 276 { 277 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn); 278 if(carrier == NULL) 279 { 280 COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl; 281 return; 282 } 283 284 if(!carrier->isTarget(this->pickup_)) 285 { 286 COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl; 287 return; 288 } 289 290 PickupCarrier* target = carrier->getTarget(this->pickup_); 268 291 Pickupable* pickup = this->getPickup(); 269 if (pickup != NULL) //!< If everything went ok, and pickup is not NULL. 270 { 271 //TODO: Not correct anymore. 272 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn); 273 if(carrier == NULL) 274 { 275 COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl; 276 return; 277 } 292 293 if(target != NULL || pickup != NULL) 294 { 295 if(carrier->pickup(pickup)) 296 { 297 this->decrementSpawnsRemaining(); 298 } 299 else 300 { 301 pickup->destroy(); 302 } 303 } 304 else 305 { 306 //TODO: Really that severe? 307 if(target == NULL) 308 COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl; 278 309 279 if(carrier->pickup(pickup)) 280 { 281 COUT(3) << "Pickup got picked up." << std::endl; 282 283 this->decrementSpawnsRemaining(); 310 if(pickup == NULL) 311 { 312 COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl; 284 313 } 285 314 else … … 288 317 } 289 318 } 290 }291 }292 293 /**294 @brief295 Decrements the number of remaining spawns.296 Sets the PickupSpawner to inactive for the duration of the respawnTime.297 Destroys the PickupSpawner if the number of remaining spawns has reached zero.298 299 */300 void PickupSpawner::decrementSpawnsRemaining(void)301 {302 if(this->spawnsRemaining_ != INF)303 {304 this->spawnsRemaining_--;305 }306 if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)307 {308 //TODO: Nicer? Does this even work?309 this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));310 311 this->setActive(false);312 this->fireEvent();313 }314 else315 {316 COUT(3) << "PickupSpawner empty, selfdistruct initialized." << std::endl;317 this->setActive(false);318 this->destroy(); //TODO: Implement destroy().319 319 } 320 320 } -
code/branches/pickup3/src/modules/pickup/PickupSpawner.h
r6466 r6475 23 23 * Daniel 'Huty' Haggenmueller 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ … … 38 38 39 39 #include <string> 40 #include "interfaces/Pickupable.h" 40 41 #include "tools/Timer.h" 42 41 43 #include "tools/interfaces/Tickable.h" 42 44 #include "worldentities/StaticEntity.h" 43 #include "interfaces/Pickupable.h"44 45 45 46 namespace orxonox 46 47 { 47 48 /** 48 @brief PickupSpawner. 49 @author Daniel 'Huty' Haggenmueller 49 @brief 50 The PickupSpawner class is responsible for spawning pickups of a specific type. 51 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. 52 @author 53 Daniel 'Huty' Haggenmueller 54 Damian 'Mozork' Frick 50 55 */ 51 56 class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable 52 57 { 53 58 public: 54 //TODO: Add limit of items spawned here. 55 PickupSpawner(BaseObject* creator); 56 PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); 57 virtual ~PickupSpawner(); 59 PickupSpawner(BaseObject* creator); //!< Default Constructor. 60 PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor. 61 virtual ~PickupSpawner(); //!< Destructor. 58 62 59 //virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).60 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML. 64 virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty). 61 65 virtual void tick(float dt); 62 66 63 67 /** 64 65 68 @brief Get the distance in which to trigger. 69 @return Returns the distance in which this gets triggered. 66 70 */ 67 71 inline float getTriggerDistance() const 68 72 { return this->triggerDistance_; } 69 73 /** 70 71 74 @brief Set the distance in which to trigger. 75 @param value The new distance in which to trigger. 72 76 */ 73 77 inline void setTriggerDistance(float value) … … 75 79 76 80 /** 77 78 81 @brief Get the time to respawn. 82 @returns Returns the time after which this gets re-actived. 79 83 */ 80 84 inline float getRespawnTime() const 81 85 { return this->respawnTime_; } 82 86 /** 83 84 87 @brief Set the time to respawn. 88 @param time New time after which this gets re-actived. 85 89 */ 86 90 inline void setRespawnTime(float time) … … 88 92 89 93 /** 90 91 94 @brief Get the maximum number of items that will be spawned by this PickupSpawner. 95 @return Returns the maximum number of items spawned by this PickupSpawner. 92 96 */ 93 97 inline int getMaxSpawnedItems(void) 94 98 { return this->maxSpawnedItems_; } 95 void setMaxSpawnedItems(int items); 99 void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items. 96 100 97 101 protected: 98 v irtual Pickupable* getPickup(void);102 void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns. 99 103 100 void setPickupable(Pickupable* pickup); 101 const Pickupable* getPickupable(void); 104 virtual Pickupable* getPickup(void); //!< Creates a new Pickupable. 102 105 103 void decrementSpawnsRemaining(void); 106 void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn. 107 const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner. 104 108 105 109 Pickupable* pickup_; //!< The pickup to be spawned. … … 108 112 void initialize(void); 109 113 110 void trigger(Pawn* pawn); 111 void respawnTimerCallback(); 114 void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough. 115 void respawnTimerCallback(); //!< Method called when the timer runs out. 112 116 113 int maxSpawnedItems_; 114 int spawnsRemaining_; 117 int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner. 118 int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs. 115 119 116 float triggerDistance_; 120 float triggerDistance_; //!< Distance in which this gets triggered. 117 121 118 /* Pickup animation */ 119 float tickSum_; //!< Adds up tick to use in sine movement 120 static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down 121 static const float bounceDistance_s; //!< Distance the pickup bounces up and down 122 static const float rotationSpeed_s; //!< Rotation speed of pickup 122 float respawnTime_; //!< Time after which this gets re-actived. 123 Timer respawnTimer_; //!< Timer used for re-activating. 123 124 124 float respawnTime_; //!< Time after which this gets re-actived. 125 Timer respawnTimer_; //!< Timer used for re-activating. 126 127 static const int INF = -1; //!< Constant for infinity. 125 static const int INF = -1; //!< Constant for infinity. 128 126 }; 129 127 } -
code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
r6474 r6475 33 33 34 34 #include "worldentities/pawns/Pawn.h" 35 #include "pickup/PickupIdentifier.h" 35 36 36 37 #include <sstream> … … 70 71 void HealthPickup::initializeIdentifier(void) 71 72 { 72 this->pickupIdentifier_ .addClass(this->getIdentifier());73 this->pickupIdentifier_->addClass(this->getIdentifier()); 73 74 74 75 std::stringstream stream; … … 76 77 std::string type1 = "health"; 77 78 std::string val1 = stream.str(); 78 this->pickupIdentifier_ .addParameter(type1, val1);79 this->pickupIdentifier_->addParameter(type1, val1); 79 80 80 81 //TODO: Does this work, is val valid outside the function scope? 81 82 std::string val2 = this->getHealthType(); 82 83 std::string type2 = "healthType"; 83 this->pickupIdentifier_ .addParameter(type2, val2);84 this->pickupIdentifier_->addParameter(type2, val2); 84 85 } 85 86
Note: See TracChangeset
for help on using the changeset viewer.