Changeset 7547 for code/trunk/src/orxonox
- Timestamp:
- Oct 16, 2010, 12:37:09 PM (14 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/interfaces/PickupCarrier.cc
r7494 r7547 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/Identifier.h" 38 38 39 #include "Pickupable.h" 39 40 … … 89 90 Returns true if the PickupCarrier or one of its children is a target, false if not. 90 91 */ 91 bool PickupCarrier::isTarget(const Pickupable* pickup) 92 bool PickupCarrier::isTarget(const Pickupable* pickup) const 92 93 { 93 94 if(pickup->isTarget(this)) // If the PickupCarrier itself is a target. -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r7494 r7547 64 64 Different PickupCarriers are structured hierarchically, a pickup can be picked up by a PickupCarrier that can't really carry that particular pickup but one of its children (or one of their children) can, and thus it gets "handed down" until it is at the right place. 65 65 But this structure has to be established first. 66 - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxon x::Engine "Engine".66 - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxonox::Engine "Engine". 67 67 - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or NULL if the PickupCarrier is a root node in this hierarchy. 68 68 69 69 @author 70 70 Damian 'Mozork' Frick 71 72 @ingroup Pickup 71 73 */ 72 74 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass … … 88 90 void preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed. 89 91 90 bool isTarget(const Pickupable* pickup) ; //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.92 bool isTarget(const Pickupable* pickup) const; //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable. 91 93 PickupCarrier* getTarget(const Pickupable* pickup); //!< Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable. 92 94 … … 96 98 @return Returns the position as a Vector3. 97 99 */ 98 virtual const Vector3& getCarrierPosition(void) = 0;100 virtual const Vector3& getCarrierPosition(void) const = 0; 99 101 100 102 protected: … … 105 107 @return Returns a pointer to a list of all direct children. 106 108 */ 107 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) = 0;109 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const = 0; 108 110 /** 109 111 @brief Get the parent of this PickupSpawner. … … 111 113 @return Returns a pointer to the parent. 112 114 */ 113 virtual PickupCarrier* getCarrierParent(void) = 0;115 virtual PickupCarrier* getCarrierParent(void) const = 0; 114 116 115 117 /** -
code/trunk/src/orxonox/interfaces/PickupListener.h
r7504 r7547 48 48 The PickupListener class facilitates the flow of information regarding the picking up, dropping, using and unusing of @ref orxonox::Pickupable "Pickupables" to interested parties (such as the @ref orxonox::PickupManager "PickupManager"). 49 49 50 All you need to to do be notified is to inherit from PickupListener and implement the two methods pickupChangedUsed() and pickupChangedPickedUp(). 50 All you need to to do be notified is to inherit from PickupListener and implement the two methods <code>pickupChangedUsed()</code> and <code>pickupChangedPickedUp()</code>. 51 51 52 @author 52 53 Damian 'Mozork' Frick 54 55 @ingroup Pickup 53 56 */ 54 57 class _OrxonoxExport PickupListener : virtual public OrxonoxClass -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r7504 r7547 147 147 Returns true if the given PickupCarrier is a target. 148 148 */ 149 bool Pickupable::isTarget( PickupCarrier* carrier) const149 bool Pickupable::isTarget(const PickupCarrier* carrier) const 150 150 { 151 151 if(carrier == NULL) … … 165 165 bool Pickupable::isTarget(const Identifier* identifier) const 166 166 { 167 // !Iterate through all targets of this Pickupable.167 // Iterate through all targets of this Pickupable. 168 168 for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) 169 169 { … … 198 198 bool Pickupable::addTarget(Identifier* target) 199 199 { 200 if(this->isTarget(target)) // !<If the input target is already present in the list of targets.200 if(this->isTarget(target)) // If the input target is already present in the list of targets. 201 201 return false; 202 202 … … 216 216 bool Pickupable::pickup(PickupCarrier* carrier) 217 217 { 218 if(carrier == NULL || this->isPickedUp()) // !<If carrier is NULL or the Pickupable is already picked up.218 if(carrier == NULL || this->isPickedUp()) // If carrier is NULL or the Pickupable is already picked up. 219 219 return false; 220 220 -
code/trunk/src/orxonox/interfaces/Pickupable.h
r7504 r7547 51 51 An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pickups. 52 52 53 Pickups (@ref orxonox: Pickupable "Pickupables") are objects that (quite unsurprisingly) can be picked up. Additionally they can be used and unused (transition from used to not used), and also dropped.53 Pickups (@ref orxonox::Pickupable "Pickupables") are objects that (quite unsurprisingly) can be picked up. Additionally they can be used and unused (transition from used to not used), and also dropped. 54 54 55 55 A class of Pickups can incorporate many different types of pickups (see @ref orxonox::PickupIdentifier "PickupIdentifier"), each type is uniquely defined by a @ref orxonox::PickupIdentifier "PickupIdentifier". Each pickup has such an identifier identiying its type. This means that two pickups of the same type have identifiers which are equal. … … 57 57 @author 58 58 Damian 'Mozork' Frick 59 60 @ingroup Pickup 59 61 */ 60 62 class _OrxonoxExport Pickupable : virtual public OrxonoxClass, public Rewardable … … 70 72 @return Returns true if the Pickupable is currently in use. 71 73 */ 72 inline bool isUsed(void) 74 inline bool isUsed(void) const 73 75 { return this->used_; } 74 76 /** … … 94 96 @return Returns true if the Pickupable is currently picked up, false if not. 95 97 */ 96 inline bool isPickedUp(void) 98 inline bool isPickedUp(void) const 97 99 { return this->pickedUp_; } 98 100 /** … … 106 108 @return Returns true if it can be used. 107 109 */ 108 inline bool isUsable(void) 110 inline bool isUsable(void) const 109 111 { return this->enabled_; } 110 112 … … 113 115 @return Returns true if it can be unused. 114 116 */ 115 inline bool isUnusable(void) 117 inline bool isUnusable(void) const 116 118 { return this->enabled_; } 117 119 … … 121 123 @return Returns true if the Pickupable is enabled. 122 124 */ 123 inline bool isEnabled(void) 125 inline bool isEnabled(void) const 124 126 { return this->enabled_; } 125 127 … … 127 129 bool drop(bool createSpawner = true); //!< Can be called to drop a Pickupable. 128 130 129 virtual bool isTarget( PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this Pickupable.131 virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this Pickupable. 130 132 bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable. 131 133 bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this Pickupable. … … 139 141 @return Returns a pointer to the PickupIdentifier of this Pickupable. 140 142 */ 141 virtual const PickupIdentifier* getPickupIdentifier(void) 143 virtual const PickupIdentifier* getPickupIdentifier(void) const 142 144 { return this->pickupIdentifier_; } 143 145 -
code/trunk/src/orxonox/items/Engine.cc
r7163 r7547 248 248 } 249 249 250 PickupCarrier* Engine::getCarrierParent(void) 250 PickupCarrier* Engine::getCarrierParent(void) const 251 251 { 252 252 return this->ship_; 253 253 } 254 254 255 const Vector3& Engine::getCarrierPosition(void) 255 const Vector3& Engine::getCarrierPosition(void) const 256 256 { 257 257 return this->ship_->getWorldPosition(); -
code/trunk/src/orxonox/items/Engine.h
r7163 r7547 112 112 virtual const Vector3& getDirection() const; 113 113 114 virtual const Vector3& getCarrierPosition(void) ;114 virtual const Vector3& getCarrierPosition(void) const; 115 115 116 116 //TODO: Move to protected or private. How? … … 121 121 122 122 protected: 123 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) 123 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const 124 124 { return new std::vector<PickupCarrier*>(); } 125 virtual PickupCarrier* getCarrierParent(void) ;125 virtual PickupCarrier* getCarrierParent(void) const; 126 126 127 127 private: -
code/trunk/src/orxonox/pickup/PickupIdentifier.h
r7494 r7547 57 57 58 58 Lastly a struct (@ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare") is provided that can be used in stl containers to establish a strictly lesser ordering between @ref orxonox::PickupIdentifier "PickupIdentifiers" (and thus @ref orxonox::Pickupable "Pickupables"). 59 59 60 @author 60 61 Damian 'Mozork' Frick 62 63 @ingroup Pickup 61 64 */ 62 65 class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r7163 r7547 128 128 { return this->aimPosition_; } 129 129 130 virtual const Vector3& getCarrierPosition(void) 130 virtual const Vector3& getCarrierPosition(void) const 131 131 { return this->getWorldPosition(); }; 132 132 … … 144 144 bool bAlive_; 145 145 146 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) 146 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const 147 147 { return new std::vector<PickupCarrier*>(); } 148 virtual PickupCarrier* getCarrierParent(void) 148 virtual PickupCarrier* getCarrierParent(void) const 149 149 { return NULL; } 150 150 -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r6711 r7547 221 221 } 222 222 223 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) 223 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) const 224 224 { 225 225 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>(); -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
r7163 r7547 85 85 86 86 protected: 87 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) ;87 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const; 88 88 bool bInvertYAxis_; 89 89
Note: See TracChangeset
for help on using the changeset viewer.