Changeset 5947 for code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
- Timestamp:
- Oct 14, 2009, 1:44:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
r5929 r5947 41 41 CreateFactory(DroppedItem); 42 42 43 /** 44 @brief 45 Constructor. Registers object and sets default values. 46 */ 43 47 DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator) 44 48 { … … 47 51 this->triggerDistance_ = 20.0f; 48 52 this->timeToLive_ = 0; 49 this->item_ = 0;53 this->item_ = NULL; 50 54 } 55 56 /** 57 @brief 58 Default destructor. 59 */ 60 //TODO: Destroy something? 51 61 DroppedItem::~DroppedItem() 52 62 { 63 53 64 } 65 66 /** 67 @brief 68 Checks whether any pawn is in triggerDistance of the Item and calls this->trigger if so. 69 @param dt 70 The duration of the last time interval. 71 */ 72 //TODO: Replace this with a DistanceTrigger! 54 73 void DroppedItem::tick(float dt) 55 74 { 56 75 if (this->item_) 57 76 { 58 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 77 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) //!< Iterate through all Pawns. 59 78 { 60 79 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 64 83 } 65 84 } 85 86 /** 87 @brief 88 Called when the DroppedItem is triggered. Adds the item to the triggering pawn. 89 */ 66 90 void DroppedItem::trigger(Pawn* pawn) 67 91 { 68 if (this->item_->pickedUp(pawn)) 92 if (this->item_->pickedUp(pawn)) //If pickup was successful. 69 93 { 70 94 COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl; … … 72 96 } 73 97 } 98 99 /** 100 @brief 101 Creates a timer to call this->timerCallback() at expiration of timeToLive. 102 */ 103 //TODO: Better Comments. 74 104 void DroppedItem::createTimer() 75 105 { … … 79 109 } 80 110 } 111 112 /** 113 @brief 114 Destroys the item. Called by the set timer upon its expiration. 115 */ 116 //TODO: Choose better function name if this doesn't create dependency inconsistencies. e.g. this->destroy() or this->timeOut() 117 //Make certain that only one pawn has the same item, because if not, deliting the item would lead to a possible segfault. 118 //If the item is destroyed here, shouldn't it be destroyed in the destructor as well? 81 119 void DroppedItem::timerCallback() 82 120 { … … 90 128 } 91 129 92 DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive) 130 /** 131 @brief 132 133 */ 134 //TODO: Comment. 135 //This is for pawns dropping items they have... 136 //Probably better to create a spawner with only 1 item in it. 137 //Various different thigs are done here, which in my opinion should eighter be done in XML or some where else, preferably in XML. 138 //Each pickup should have a XML template where the Model and Billboard, and so on, is specified. 139 //The position, item and timetoLive should be specified by this Classes XMLPort function. 140 //These adjustments above, will very likely create inkonsistencies in the level files, possibly templates. 141 /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive) 93 142 { 94 143 DroppedItem* drop = new DroppedItem(item); … … 116 165 return drop; 117 166 } 167 168 /** 169 @brief 170 171 */ 172 //TODO: See one function above. 118 173 DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive) 119 174 {
Note: See TracChangeset
for help on using the changeset viewer.