Changeset 6711 for code/trunk/src/modules
- Timestamp:
- Apr 13, 2010, 10:16:10 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/pickup4 (added) merged: 6632,6669,6675,6679,6700-6701,6707
- Property svn:mergeinfo changed
-
code/trunk/src/modules/pickup/CMakeLists.txt
r6524 r6711 15 15 FIND_HEADER_FILES 16 16 TOLUA_FILES 17 PickupManager.h 18 PickupRepresentation.h 17 19 DEFINE_SYMBOL 18 20 "PICKUP_SHARED_BUILD" -
code/trunk/src/modules/pickup/PickupManager.cc
r6540 r6711 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/LuaState.h" 38 #include "core/GUIManager.h" 37 39 #include "core/ScopedSingletonManager.h" 38 40 #include "core/Identifier.h" 39 41 #include "interfaces/PickupCarrier.h" 42 #include "infos/PlayerInfo.h" 40 43 #include "worldentities/pawns/Pawn.h" 41 44 #include "PickupRepresentation.h" 42 45 46 #include "ToluaBindPickup.h" 47 43 48 namespace orxonox 44 49 { 45 50 // Register tolua_open function when loading the library 51 DeclareToluaInterface(Pickup); 52 46 53 ManageScopedSingleton(PickupManager, ScopeID::Root, false); 54 55 /*static*/ const std::string PickupManager::guiName_s = "PickupInventory"; 47 56 48 57 /** … … 110 119 } 111 120 121 PickupCarrier* PickupManager::getPawn(void) 122 { 123 Pawn* pawn = dynamic_cast<Pawn*>(GUIManager::getInstancePtr()->getPlayer(PickupManager::guiName_s)->getControllableEntity()); 124 if(pawn == NULL) 125 return NULL; 126 return dynamic_cast<PickupCarrier*>(pawn); 127 } 128 129 int PickupManager::getNumCarrierChildren(PickupCarrier* carrier) 130 { 131 if(carrier == NULL) 132 return 0; 133 return carrier->getNumCarrierChildren(); 134 } 135 136 PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier) 137 { 138 if(carrier == NULL) 139 return NULL; 140 return carrier->getCarrierChild(index); 141 } 142 143 const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier) 144 { 145 if(carrier == NULL) 146 return BLANKSTRING; 147 return carrier->getCarrierName(); 148 } 149 150 PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier) 151 { 152 Pickupable* pickup = carrier->getPickup(index); 153 if(pickup == NULL) 154 return NULL; 155 156 return this->getRepresentation(pickup->getPickupIdentifier()); 157 } 158 159 int PickupManager::getNumPickups(PickupCarrier* carrier) 160 { 161 if(carrier == NULL) 162 return 0; 163 return carrier->getNumPickups(); 164 } 165 166 void PickupManager::dropPickup(int index, PickupCarrier* carrier) 167 { 168 Pickupable* pickup = carrier->getPickup(index); 169 carrier->drop(pickup); 170 } 171 172 void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use) 173 { 174 Pickupable* pickup = carrier->getPickup(index); 175 pickup->setUsed(use); 176 } 177 112 178 } -
code/trunk/src/modules/pickup/PickupManager.h
r6540 r6711 44 44 #include "core/OrxonoxClass.h" 45 45 46 namespace orxonox 47 { 46 namespace orxonox // tolua_export 47 { // tolua_export 48 48 49 49 /** 50 50 @brief 51 51 Manages Pickupables. 52 In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the Pickup GUI.52 In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory. 53 53 //TODO: Manage Pickup GUI. 54 54 @author 55 55 Damian 'Mozork' Frick 56 56 */ 57 class _PickupExport PickupManager : public Singleton<PickupManager>, public OrxonoxClass 58 { 57 class _PickupExport PickupManager // tolua_export 58 : public Singleton<PickupManager>, public OrxonoxClass 59 { // tolua_export 59 60 friend class Singleton<PickupManager>; 60 61 … … 63 64 virtual ~PickupManager(); 64 65 65 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } 66 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export 66 67 67 68 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 68 69 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 69 70 71 // tolua_begin 72 orxonox::PickupCarrier* getPawn(void); 73 74 int getNumCarrierChildren(orxonox::PickupCarrier* carrier); 75 orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier); 76 77 const std::string& getCarrierName(orxonox::PickupCarrier* carrier); 78 79 int getNumPickups(orxonox::PickupCarrier* carrier); 80 PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier); 81 void dropPickup(int index, orxonox::PickupCarrier* carrier); 82 void usePickup(int index, orxonox::PickupCarrier* carrier, bool use); 83 // tolua_end 84 70 85 private: 71 86 static PickupManager* singletonPtr_s; 87 static const std::string guiName_s; 72 88 73 89 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 74 90 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 75 91 76 }; 92 }; // tolua_export 77 93 78 } 94 } // tolua_export 79 95 80 96 #endif // _PickupManager_H__ -
code/trunk/src/modules/pickup/PickupPrereqs.h
r6710 r6711 65 65 namespace orxonox 66 66 { 67 67 68 68 class DroppedPickup; 69 69 class Pickup; -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r6676 r6711 86 86 this->name_ = "Pickup"; 87 87 this->spawnerTemplate_ = ""; 88 this->inventoryRepresentation_ = "Default"; 88 89 this->pickup_ = NULL; 89 90 } … … 97 98 SUPER(PickupRepresentation, XMLPort, xmlelement, mode); 98 99 99 XMLPortParam(PickupRepresentation, " name", setName, getName, xmlelement, mode);100 XMLPortParam(PickupRepresentation, " description", setDescription, getDescription, xmlelement, mode);100 XMLPortParam(PickupRepresentation, "pickupName", setPickupName, getPickupName, xmlelement, mode); 101 XMLPortParam(PickupRepresentation, "pickupDescription", setPickupDescription, getPickupDescription, xmlelement, mode); 101 102 XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode); 103 XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode); 102 104 XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode); 103 105 XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode); -
code/trunk/src/modules/pickup/PickupRepresentation.h
r6540 r6711 45 45 #include "core/BaseObject.h" 46 46 47 namespace orxonox 48 { 47 namespace orxonox // tolua_export 48 { // tolua_export 49 49 50 50 /** … … 53 53 They are created through XML and are registered with the PickupManager. 54 54 */ 55 class _PickupExport PickupRepresentation : public BaseObject 56 { 55 class _PickupExport PickupRepresentation // tolua_export 56 : public BaseObject 57 { // tolua_export 57 58 58 59 public: … … 67 68 @param name The name. 68 69 */ 69 inline void set Name(const std::string& name)70 inline void setPickupName(const std::string& name) 70 71 { this->name_ = name; } 71 72 /** … … 73 74 @param description The Description. 74 75 */ 75 inline void set Description(const std::string& description)76 inline void setPickupDescription(const std::string& description) 76 77 { this->description_ = description; } 77 78 /** … … 90 91 { this->spawnerRepresentation_ = representation; } 91 92 /** 93 @brief Set the image representing the pickup in the PickupInventory. 94 @param image A string with the name of the image representing the pickup. 95 */ 96 inline void setInventoryRepresentation(const std::string& image) 97 { this->inventoryRepresentation_ = image; } 98 /** 92 99 @brief Set the Pickupable that is represented by this PickupRepresentation. 93 100 @param pickup A pointer to the Pickupable. … … 100 107 @return Returns the name. 101 108 */ 102 inline const std::string& getName(void) 103 { return this->name_; } 109 inline const std::string& getPickupName(void) { return this->name_; } // tolua_export 104 110 /** 105 111 @brief Get the description of the Pickupable represented by this PickupRepresentation. 106 112 @return Returns the description. 107 113 */ 108 inline const std::string& getDescription(void) 109 { return this->description_; } 114 inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export 110 115 /** 111 116 @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. … … 121 126 inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) 122 127 { if(index == 0) return this->spawnerRepresentation_; return NULL; } 128 /** 129 @brief Get the name of the image representing the pickup in the PickupInventory. 130 @return Returns the name of the image as a string. 131 */ 132 inline const std::string& getInventoryRepresentation(void) { return this->inventoryRepresentation_; } // tolua_export 123 133 /** 124 134 @brief Get the Pickupable represented by this PickupRepresentation. … … 139 149 std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. 140 150 StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. 151 std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image? 141 152 142 153 Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. 143 154 144 }; 155 }; // tolua_export 145 156 146 } 157 } // tolua_export 147 158 148 159 #endif // _PickupRepresentation_H__ -
code/trunk/src/modules/pickup/PickupSpawner.cc
r6563 r6711 180 180 { 181 181 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 182 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 182 183 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance. 183 if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))184 if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_)) 184 185 { 185 186 this->trigger(*it);
Note: See TracChangeset
for help on using the changeset viewer.