Changeset 6540 for code/trunk
- Timestamp:
- Mar 16, 2010, 9:35:11 PM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/DroppedPickup.cc
r6524 r6540 28 28 29 29 /** 30 @file 30 @file DroppedPickup.cc 31 31 @brief Implementation of the DroppedPickup class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "interfaces/Pickupable.h" 38 #include "interfaces/PickupCarrier.h" 38 39 #include "graphics/Model.h" 39 40 … … 65 66 The distance at which the PickupSpawner triggers. Default is 10. 66 67 */ 67 DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1)68 DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 5, 1) 68 69 { 69 70 RegisterObject(DroppedPickup); 70 71 71 this->setPosition( position);72 this->setPosition(carrier->getCarrierPosition()); 72 73 this->setActive(false); 74 75 //TODO: Do more elegantly. 73 76 this->startRespawnTimer(); 74 77 } -
code/trunk/src/modules/pickup/DroppedPickup.h
r6524 r6540 28 28 29 29 /** 30 @file 30 @file DroppedPickup.h 31 31 @brief Definition of the DroppedPickup class. 32 32 */ … … 53 53 public: 54 54 DroppedPickup(BaseObject* creator); //!< Default constructor. 55 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor.55 DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance = 10.0); //!< Constructor. 56 56 virtual ~DroppedPickup(); //!< Destructor. 57 57 -
code/trunk/src/modules/pickup/Pickup.cc
r6533 r6540 27 27 */ 28 28 29 /** 30 @file Pickup.cc 31 @brief Implementation of the Pickup class. 32 */ 33 29 34 #include "Pickup.h" 30 35 … … 41 46 /*static*/ const std::string Pickup::durationTypeOnce_s = "once"; 42 47 /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous"; 43 44 //TODO: Should this be here? Does it work without?45 CreateFactory(Pickup);46 48 47 49 Pickup::Pickup(BaseObject* creator) : BaseObject(creator) … … 224 226 Returns true if a spawner was created, false if not. 225 227 */ 226 bool Pickup::createSpawner( const Vector3& position)227 { 228 new DroppedPickup(this, this, position);228 bool Pickup::createSpawner(void) 229 { 230 new DroppedPickup(this, this, this->getCarrier()); 229 231 return true; 230 232 } -
code/trunk/src/modules/pickup/Pickup.h
r6524 r6540 25 25 * ... 26 26 * 27 */ 28 29 /** 30 @file Pickup.h 31 @brief Declaration of the Pickup class. 27 32 */ 28 33 … … 70 75 { 71 76 77 protected: 78 Pickup(BaseObject* creator); //!< Constructor. 79 72 80 public: 73 Pickup(BaseObject* creator); //!< Constructor.74 81 virtual ~Pickup(); //!< Destructor. 75 82 … … 124 131 void initializeIdentifier(void); 125 132 126 virtual bool createSpawner( const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.133 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 127 134 128 135 /** -
code/trunk/src/modules/pickup/PickupCollection.cc
r6538 r6540 158 158 159 159 PickupCollection* pickup = dynamic_cast<PickupCollection*>(item); 160 //! Clone all Pickupables this PickupCollection consist of.160 //! Clone all Pickupables this PickupCollection consist of. 161 161 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 162 162 { … … 240 240 Returns true if a spawner was created, false if not. 241 241 */ 242 bool PickupCollection::createSpawner( const Vector3& position)243 { 244 new DroppedPickup(this, this, position);242 bool PickupCollection::createSpawner(void) 243 { 244 new DroppedPickup(this, this, this->getCarrier()); 245 245 return true; 246 246 } -
code/trunk/src/modules/pickup/PickupCollection.h
r6538 r6540 77 77 void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup. 78 78 79 virtual bool createSpawner( const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.79 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 80 80 81 81 PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves. -
code/trunk/src/modules/pickup/PickupManager.cc
r6524 r6540 28 28 29 29 /** 30 @file 30 @file PickupManager.cc 31 31 @brief Implementation of the PickupManager class. 32 32 */ … … 50 50 Constructor. Registers the PickupManager and creates the default PickupRepresentation. 51 51 */ 52 PickupManager::PickupManager() 52 PickupManager::PickupManager() : defaultRepresentation_(NULL) 53 53 { 54 this->defaultRepresentation_ = NULL;55 this->pickupCarrierStructure_ = NULL;56 54 RegisterRootObject(PickupManager); 57 55 … … 68 66 if(this->defaultRepresentation_ != NULL) 69 67 this->defaultRepresentation_->destroy(); 70 71 if(this->pickupCarrierStructure_ != NULL)72 delete this->pickupCarrierStructure_;73 68 } 74 69 … … 84 79 Returns true if successful and false if not. 85 80 */ 86 //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort.87 81 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 88 82 { -
code/trunk/src/modules/pickup/PickupManager.h
r6524 r6540 28 28 29 29 /** 30 @file 30 @file PickupManager.h 31 31 @brief Definition of the PickupManager class. 32 32 */ … … 46 46 namespace orxonox 47 47 { 48 //TODO: Actually utilize this.49 struct PickupCarrierNode50 {51 Identifier* identifier;52 std::set<PickupCarrierNode*> children;53 };54 48 55 49 /** … … 74 68 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 75 69 76 //TODO: Delete or utilitze this.77 //bool registerCarrier(Identifier* parent, )78 79 70 private: 80 71 static PickupManager* singletonPtr_s; … … 82 73 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 83 74 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 84 85 //TODO: Delete or utilize this.86 PickupCarrierNode* pickupCarrierStructure_;87 75 88 76 }; -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r6524 r6540 27 27 */ 28 28 29 /** 30 @file PickupRepresentation.cc 31 @brief Implementation of the PickupRepresentation class. 32 */ 33 29 34 #include "PickupRepresentation.h" 30 35 … … 44 49 This is primarily for use of the PickupManager in creating a default PickupRepresentation. 45 50 */ 46 //TODO: Not this as creator!!! 47 PickupRepresentation::PickupRepresentation() : BaseObject(this) 51 PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL) 48 52 { 49 this->spawnerRepresentation_ = NULL;50 51 53 RegisterObject(PickupRepresentation); 52 54 … … 58 60 Default Constructor. Registers the object and initializes its member variables. 59 61 */ 60 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator) 62 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL) 61 63 { 62 this->spawnerRepresentation_ = NULL;63 64 64 RegisterObject(PickupRepresentation); 65 65 … … 151 151 Returns a pointer to the StaticEntity. 152 152 */ 153 //TODO: Think of more elegant solution.153 //TODO: Possibility to define default representation through XML. 154 154 StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner) 155 155 { -
code/trunk/src/modules/pickup/PickupRepresentation.h
r6524 r6540 25 25 * ... 26 26 * 27 */ 28 29 /** 30 @file PickupRepresentation.h 31 @brief Definition of the PickupRepresentation class. 27 32 */ 28 33 -
code/trunk/src/modules/pickup/PickupSpawner.cc
r6524 r6540 28 28 29 29 /** 30 @file 31 @brief Implementation of PickupSpawner.30 @file PickupSpawner.cc 31 @brief Implementation of the PickupSpawner class. 32 32 */ 33 33 … … 52 52 Pointer to the object which created this item. 53 53 */ 54 PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator) 55 { 54 PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator), pickup_(NULL) 55 { 56 RegisterObject(PickupSpawner); 57 56 58 this->initialize(); 57 58 RegisterObject(PickupSpawner);59 59 } 60 60 … … 73 73 The maximum number of items spawned by this PickupSpawner. 74 74 */ 75 PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator) 75 PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator), pickup_(NULL) 76 76 { 77 77 RegisterObject(PickupSpawner); … … 103 103 void PickupSpawner::initialize(void) 104 104 { 105 this->pickup_ = NULL;106 107 105 this->triggerDistance_ = 20; 108 106 this->respawnTime_ = 0; … … 170 168 Time since last tick. 171 169 */ 172 //TODO: Replace this with a real DistanceTrigger? Or better with collisions?170 //TODO: Replace with collisions. 173 171 void PickupSpawner::tick(float dt) 174 172 { 173 SUPER(PickupSpawner, tick, dt); 174 175 175 //! If the PickupSpawner is active. 176 176 if (this->isActive()) … … 215 215 if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0) 216 216 { 217 //TODO: Nicer? Does this even work?218 217 this->startRespawnTimer(); 219 218 … … 278 277 Pawn which triggered the PickupSpawner. 279 278 */ 280 //TODO: Make more generic -> without pawn.281 279 void PickupSpawner::trigger(Pawn* pawn) 282 280 { … … 314 312 else 315 313 { 316 //TODO: Really that severe?317 314 if(target == NULL) 318 315 COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl; -
code/trunk/src/modules/pickup/PickupSpawner.h
r6524 r6540 28 28 29 29 /** 30 @file 31 @brief Definition of PickupSpawner.30 @file PickupSpawner.h 31 @brief Definition of the PickupSpawner class. 32 32 */ 33 33 -
code/trunk/src/modules/pickup/items/HealthPickup.cc
r6524 r6540 26 26 * 27 27 */ 28 29 /** 30 @file HealthPickup.cc 31 @brief Implementation of the HealthPickup class. 32 */ 28 33 29 34 #include "HealthPickup.h" … … 94 99 this->pickupIdentifier_->addParameter(type1, val1); 95 100 96 //TODO: Does this work, is val valid outside the function scope?97 101 std::string val2 = this->getHealthType(); 98 102 std::string type2 = "healthType"; … … 133 137 void HealthPickup::tick(float dt) 134 138 { 139 SUPER(HealthPickup, tick, dt); 140 135 141 if(this->isContinuous() && this->isUsed()) 136 142 { -
code/trunk/src/modules/pickup/items/HealthPickup.h
r6524 r6540 26 26 * 27 27 */ 28 29 /** 30 @file HealthPickup.h 31 @brief Declaration of the HealthPickup class. 32 */ 28 33 29 34 #ifndef _HealthPickup_H__ -
code/trunk/src/modules/weapons/projectiles/Projectile.cc
r6524 r6540 123 123 } 124 124 125 float dmg = this->damage_;126 //TODO: Remove.127 // if (this->owner_)128 // dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);129 130 125 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 131 126 if (victim) 132 victim->hit(this->owner_, contactPoint, dmg);127 victim->hit(this->owner_, contactPoint, this->damage_); 133 128 } 134 129 return false; -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r6524 r6540 200 200 } 201 201 202 float dmg = this->damage_;203 //TODO: This souldn't be necessary here.204 //if (this->owner_)205 // dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);206 207 202 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 208 203 if (victim) 209 victim->hit(this->owner_, contactPoint, dmg);204 victim->hit(this->owner_, contactPoint, this->damage_); 210 205 // this->destroy(); 211 206 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r6533 r6540 28 28 29 29 /** 30 @file 30 @file PickupCarrier.h 31 31 @brief Definition of the PickupCarrier class. 32 32 */ … … 48 48 { 49 49 50 //! Pre-declarations. 50 51 class Pickup; 51 52 class HealthPickup; … … 60 61 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass 61 62 { 62 friend class Pickupable; //!< The Pickupable has full acces to itsPickupCarrier.63 //TODO: Ugly workaround.63 //! So that the different Pickupables have full access to their PickupCarrier. 64 friend class Pickupable; 64 65 friend class Pickup; 65 66 friend class HealthPickup; … … 108 109 @return Returns true if the PickupCarrier or one of its children is a target, false if not. 109 110 */ 110 //TODO: Use?111 111 bool isTarget(const Pickupable* pickup) 112 112 { … … 154 154 return NULL; 155 155 } 156 157 /** 158 @brief Get the (absolute) position of the PickupCarrier. 159 This method needs to be implemented by any direct derivative class of PickupCarrier. 160 @return Returns the position as a Vector3. 161 */ 162 virtual const Vector3& getCarrierPosition(void) = 0; 156 163 157 164 protected: … … 159 166 @brief Get all direct children of this PickupSpawner. 160 167 This method needs to be implemented by any direct derivative class of PickupCarrier. 168 The returned list will be deleted by the methods calling this function. 161 169 @return Returns a pointer to a list of all direct children. 162 170 */ 163 //TODO: Good return type? Maybe not const and destroyed in isTarget...164 171 virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0; 165 172 /** … … 169 176 */ 170 177 virtual PickupCarrier* getCarrierParent(void) = 0; 171 /**172 @brief Get the (absolute) position of the PickupCarrier.173 This method needs to be implemented by any direct derivative class of PickupCarrier.174 @return Returns the position as a Vector3.175 */176 virtual const Vector3& getCarrierPosition(void) = 0;177 178 178 179 /** -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r6538 r6540 46 46 Constructor. Registers the objects and initializes its member variables. 47 47 */ 48 Pickupable::Pickupable() 49 { 50 this->used_ = false; 51 this->pickedUp_ = false; 52 48 Pickupable::Pickupable() : used_(false), pickedUp_(false) 49 { 53 50 RegisterRootObject(Pickupable); 54 51 … … 231 228 this->setPickedUp(false); 232 229 233 bool created = this->createSpawner( this->getCarrier()->getCarrierPosition());230 bool created = this->createSpawner(); 234 231 235 232 this->setCarrier(NULL); 236 //TODO: possible problem.233 237 234 if(!created) 238 235 { … … 267 264 A reference to a pointer to the OrxonoxClass that is to be duplicated. 268 265 */ 269 //TODO: Specify how the implementation must be done in detail.270 266 void Pickupable::clone(OrxonoxClass*& item) 271 267 { -
code/trunk/src/orxonox/interfaces/Pickupable.h
r6539 r6540 51 51 Damian 'Mozork' Frick 52 52 */ 53 //TODO: Add stuff like weight/space ?54 53 class _OrxonoxExport Pickupable : virtual public OrxonoxClass 55 54 { 55 protected: 56 Pickupable(); //!< Default constructor. 56 57 57 58 public: 58 Pickupable(); //!< Default constructor.59 59 virtual ~Pickupable(); //!< Default destructor. 60 60 … … 113 113 { return this->pickupIdentifier_; } 114 114 115 //TODO: Make them work as protected.116 115 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. 117 116 bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up. … … 131 130 @return Returns true if a spawner was created, false if not. 132 131 */ 133 virtual bool createSpawner( const Vector3& position) = 0;132 virtual bool createSpawner(void) = 0; 134 133 135 //TODO: Move to private and create get method in protected.136 134 PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable. 137 135 -
code/trunk/src/orxonox/items/Engine.cc
r6524 r6540 35 35 #include "Scene.h" 36 36 #include "worldentities/pawns/SpaceShip.h" 37 //TODO: Remove.38 //#include "pickup/ModifierType.h"39 37 #include "tools/Shader.h" 40 38 … … 194 192 } 195 193 196 //TODO: Correct?197 194 this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration); 198 195 -
code/trunk/src/orxonox/pickup/PickupIdentifier.cc
r6524 r6540 26 26 * 27 27 */ 28 29 /** 30 @file PickupIdentifier.cc 31 @brief Implementation of the PickupIdentifier class. 32 */ 28 33 29 34 #include "PickupIdentifier.h" -
code/trunk/src/orxonox/pickup/PickupIdentifier.h
r6524 r6540 26 26 * 27 27 */ 28 29 /** 30 @file PickupIdentifier.h 31 @brief Definition of the PickupIdentifier class. 32 */ 28 33 29 34 #ifndef _PickupIdentifier_H__ -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r6524 r6540 71 71 this->aimPosition_ = Vector3::ZERO; 72 72 73 //TODO: Remove.74 //this->getPickups().setOwner(this);75 76 73 if (GameMode::isMaster()) 77 74 { … … 297 294 } 298 295 299 //TODO: Remove.300 // void Pawn::dropItems()301 // {302 // this->getPickups().clear();303 // }304 305 306 296 /* WeaponSystem: 307 297 * functions load Slot, Set, Pack from XML and make sure all parent-pointers are set. -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r6524 r6540 109 109 { return this->numexplosionchunks_; } 110 110 111 //TODO: Remove.112 // virtual void dropItems();113 // inline PickupCollection& getPickups()114 // { return this->pickups_; }115 // virtual void useItem()116 // { this->pickups_.useItem(); }117 118 111 virtual void startLocalHumanControl(); 119 112 … … 122 115 Vector3 getAimPosition() 123 116 { return this->aimPosition_; } 117 118 virtual const Vector3& getCarrierPosition(void) 119 { return this->getWorldPosition(); }; 124 120 125 121 protected: … … 136 132 bool bAlive_; 137 133 138 //TODO: Remove.139 //PickupCollection pickups_;140 134 virtual std::list<PickupCarrier*>* getCarrierChildren(void) 141 135 { return new std::list<PickupCarrier*>(); } 142 136 virtual PickupCarrier* getCarrierParent(void) 143 137 { return NULL; } 144 virtual const Vector3& getCarrierPosition(void)145 { return this->getWorldPosition(); };146 138 147 139 float health_;
Note: See TracChangeset
for help on using the changeset viewer.