Changeset 2900 for code/branches/pickups
- Timestamp:
- Apr 6, 2009, 3:53:50 PM (16 years ago)
- Location:
- code/branches/pickups
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickups
-
Property
svn:ignore
set to
build
dependencies
-
Property
svn:ignore
set to
-
code/branches/pickups/src/orxonox/objects/controllers/HumanController.cc
r2662 r2900 48 48 SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold); 49 49 SetConsoleCommand(HumanController, greet, true); 50 SetConsoleCommand(HumanController, use, true);51 50 SetConsoleCommand(HumanController, switchCamera, true); 52 51 SetConsoleCommand(HumanController, mouseLook, true); … … 55 54 SetConsoleCommand(HumanController, killBots, true).defaultValues(0); 56 55 SetConsoleCommand(HumanController, dropItems, true); 56 SetConsoleCommand(HumanController, useItem, true); 57 57 58 58 CreateUnloadableFactory(HumanController); … … 132 132 } 133 133 134 void HumanController::use()135 {136 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)137 HumanController::localController_s->controllableEntity_->use();138 }139 140 134 void HumanController::switchCamera() 141 135 { … … 160 154 } 161 155 156 void HumanController::useItem() 157 { 158 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 159 HumanController::localController_s->controllableEntity_->useItem(); 160 } 161 162 162 void HumanController::addBots(unsigned int amount) 163 163 { -
code/branches/pickups/src/orxonox/objects/controllers/HumanController.h
r2662 r2900 56 56 static void boost(); 57 57 static void greet(); 58 static void use();59 58 static void switchCamera(); 60 59 static void mouseLook(); 61 60 static void dropItems(); 61 static void useItem(); 62 62 63 63 static void suicide(); -
code/branches/pickups/src/orxonox/objects/items/Engine.cc
r2662 r2900 192 192 } 193 193 194 this->ship_->setAcceleration(this->ship_->get Orientation() * acceleration);194 this->ship_->setAcceleration(this->ship_->getPickups().processModifiers(ModifierType::Acceleration, this->ship_->getOrientation() * acceleration, false)); 195 195 196 196 if (!this->ship_->getPermanentBoost()) -
code/branches/pickups/src/orxonox/objects/pickup/BaseItem.cc
r2864 r2900 63 63 this->setOwner(pawn); 64 64 65 COUT(3) << "Adding '" << this->getPickupIdentifier() << "' item." << std::endl; 66 67 return pawn->getPickups().add(this); 65 if (pawn->getPickups().add(this)) 66 { 67 COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl; 68 return true; 69 } 70 return false; 68 71 } 69 72 /** -
code/branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt
r2864 r2900 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 BaseItem.cc 3 DroppedItem.cc 3 4 EquipmentItem.cc 5 Jump.cc 4 6 ModifierPickup.cc 5 7 PassiveItem.cc -
code/branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc
r2864 r2900 74 74 XMLPortParamTemplate(ModifierPickup, "damageAdd", setAdditiveDamage, getAdditiveDamage, element, mode, float); 75 75 XMLPortParamTemplate(ModifierPickup, "damageMulti", setMultiplicativeDamage, getMultiplicativeDamage, element, mode, float); 76 77 XMLPortParamTemplate(ModifierPickup, "accelerationAdd", setAdditiveAcceleration, getAdditiveAcceleration, element, mode, float); 78 XMLPortParamTemplate(ModifierPickup, "accelerationMulti", setMultiplicativeAcceleration, getMultiplicativeAcceleration, element, mode, float); 76 79 } 77 80 /** … … 141 144 this->timer_.stopTimer(); 142 145 146 delete this; 147 143 148 return true; 144 149 } -
code/branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h
r2864 r2900 58 58 virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method 59 59 60 virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups 61 60 62 /** 61 63 @brief Get the duration of this pickup. … … 97 99 { this->setMultiplicativeModifier(ModifierType::Damage, value); } 98 100 101 /** 102 @brief Get the amount of acceleration this pickup adds. 103 @return Returns how much acceleration this pickup adds. 104 */ 105 inline float getAdditiveAcceleration() const 106 { return this->getAdditiveModifier(ModifierType::Acceleration); } 107 /** 108 @brief Get the factor by which this pickup multiplies the acceleration. 109 @return Returns the factor by which to multiply acceleration. 110 */ 111 inline float getMultiplicativeAcceleration() const 112 { return this->getMultiplicativeModifier(ModifierType::Acceleration); } 113 114 /** 115 @brief Set the amount of acceleration this pickup adds. 116 @param value How much acceleration this pickup adds. 117 */ 118 inline void setAdditiveAcceleration(float value) 119 { this->setAdditiveModifier(ModifierType::Acceleration, value); } 120 /** 121 @brief Set the factor by which this pickup multiplies the acceleration. 122 @param value Factor by which to multiply acceleration. 123 */ 124 inline void setMultiplicativeAcceleration(float value) 125 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } 126 99 127 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 100 128 private: -
code/branches/pickups/src/orxonox/objects/pickup/ModifierType.h
r2864 r2900 45 45 { 46 46 Unknown = 0, 47 Damage 47 Damage, 48 Acceleration 48 49 }; 49 50 } -
code/branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc
r2864 r2900 94 94 for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++) 95 95 { 96 (*it).second->dropped((*it).second->getOwner()); 97 98 delete (*it).second; 96 if((*it).second && (*it).second->getOwner()) 97 (*it).second->dropped((*it).second->getOwner()); 99 98 } 100 99 this->items_.clear(); … … 125 124 return false; 126 125 } 126 } 127 //! Uses the first usable item in the collection on the owner. 128 void PickupCollection::useItem() 129 { 130 Identifier* ident = Class(UsableItem); 131 for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++) 132 { 133 if ((*it).second->isA(ident)) 134 { 135 UsableItem* asUsable = dynamic_cast<UsableItem*>((*it).second); 136 asUsable->used(this->owner_); 137 return; 138 } 139 } 140 } 141 /** 142 @brief Uses a usable item on the owner of the collection. 143 @param item Item to use. 144 */ 145 void PickupCollection::useItem(UsableItem* item) 146 { 147 if (item && this->owner_) 148 item->used(this->owner_); 127 149 } 128 150 /** -
code/branches/pickups/src/orxonox/objects/pickup/PickupCollection.h
r2864 r2900 48 48 { 49 49 class BaseItem; 50 class UsableItem; 50 51 class Pawn; 51 52 … … 67 68 68 69 void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection. 70 71 void useItem(); //!< Use the first usable item. 72 void useItem(UsableItem* item); //!< Use a usable item. 69 73 70 74 void addAdditiveModifier(ModifierType::Enum type, float value); //!< Add an additive modifier. -
code/branches/pickups/src/orxonox/objects/pickup/UsableItem.h
r2864 r2900 52 52 53 53 /** 54 @brief Method invoked if the item wasused.55 @param pawn Pawn which usedthe item.54 @brief Method invoked when the item is being used. 55 @param pawn Pawn which is using the item. 56 56 */ 57 57 virtual void used(Pawn* pawn) { } -
code/branches/pickups/src/orxonox/objects/worldentities/ControllableEntity.h
r2662 r2900 87 87 virtual void boost() {} 88 88 virtual void greet() {} 89 virtual void use () {}89 virtual void useItem() {} 90 90 virtual void dropItems() {} 91 91 virtual void switchCamera(); -
code/branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.h
r2864 r2900 110 110 inline PickupCollection& getPickups() 111 111 { return this->pickups_; } 112 virtual void useItem() 113 { this->pickups_.useItem(); } 112 114 113 115 protected:
Note: See TracChangeset
for help on using the changeset viewer.