Changeset 7163 for code/trunk/src/orxonox/interfaces
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/interfaces/GametypeMessageListener.h
r5781 r7163 44 44 virtual void killmessage(const GametypeInfo* gtinfo, const std::string& message) {} 45 45 virtual void deathmessage(const GametypeInfo* gtinfo, const std::string& message) {} 46 virtual void staticmessage(const GametypeInfo* gtinfo, const std::string& message, const ColourValue& colour) {} 47 virtual void fadingmessage(const GametypeInfo* gtinfo, const std::string& message) {} 46 48 }; 47 49 } -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r6711 r7163 52 52 RegisterRootObject(GametypeMessageListener); 53 53 } 54 54 55 55 //---------------------------- 56 56 // PickupCarrier … … 59 59 { 60 60 RegisterRootObject(PickupCarrier); 61 62 this->setCarrierName("PickupCarrier");63 61 } 64 62 65 63 PickupCarrier::~PickupCarrier() 66 64 { 65 66 } 67 68 void PickupCarrier::preDestroy(void) 69 { 67 70 std::set<Pickupable*>::iterator it = this->pickups_.begin(); 71 std::set<Pickupable*>::iterator temp; 68 72 while(it != this->pickups_.end()) 69 73 { 70 (*(it++))->destroy(); 74 (*it)->carrierDestroyed(); 75 temp = it; 76 it = this->pickups_.begin(); 77 if(it == temp) // Infinite loop avoidance, in case the pickup wasn't removed from the carrier somewhere in the carrierDestroy() procedure. 78 { 79 COUT(2) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << (*temp) << ") didn't unregister itself as it should have." << std::endl;; 80 it++; 81 } 71 82 } 72 83 … … 84 95 this->isForPlayer_ = true; 85 96 } 86 97 87 98 //---------------------------- 88 99 // RadarListener -
code/trunk/src/orxonox/interfaces/NotificationListener.h
r5929 r7163 47 47 class Notification; 48 48 49 /** 50 @brief 51 NotificationListener interface. 52 @author 53 Fabian 'x3n' Landau 54 */ 49 55 class _OrxonoxExport NotificationListener : virtual public OrxonoxClass 50 56 { -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
- Property svn:eol-style set to native
r6711 r7163 45 45 #include "core/OrxonoxClass.h" 46 46 47 namespace orxonox // tolua_export48 { // tolua_export47 namespace orxonox 48 { 49 49 50 50 //! Forward-declarations. … … 54 54 class InvisiblePickup; 55 55 class MetaPickup; 56 class DronePickup; 56 57 class SpeedPickup; 57 58 … … 62 63 Damian 'Mozork' Frick 63 64 */ 64 class _OrxonoxExport PickupCarrier // tolua_export 65 : virtual public OrxonoxClass 66 { // tolua_export 65 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass 66 { 67 67 //! So that the different Pickupables have full access to their PickupCarrier. 68 68 friend class Pickupable; 69 69 friend class PickupManager; 70 //! Friends. 70 //! Friends. 71 71 friend class Pickup; 72 72 friend class HealthPickup; 73 73 friend class InvisiblePickup; 74 74 friend class MetaPickup; 75 friend class DronePickup; 75 76 friend class SpeedPickup; 76 77 … … 78 79 PickupCarrier(); //!< Constructor. 79 80 virtual ~PickupCarrier(); //!< Destructor. 80 81 /** 82 @brief Can be called to pick up a Pickupable. 83 @param pickup A pointer to the Pickupable. 84 @return Returns true if the Pickupable was picked up, false if not. 85 */ 86 bool pickup(Pickupable* pickup) 87 { 88 bool pickedUp = this->pickups_.insert(pickup).second; 89 if(pickedUp) 90 { 91 COUT(4) << "Picked up Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl; 92 pickup->pickedUp(this); 93 } 94 return pickedUp; 95 } 96 97 /** 98 @brief Can be called to drop a Pickupable. 99 @param pickup A pointer to the Pickupable. 100 @param drop If the Pickupable should just be removed from the PickupCarrier without further action, this can be set to false. true is default. 101 @return Returns true if the Pickupable has been dropped, false if not. 102 */ 103 bool drop(Pickupable* pickup, bool drop = true) 104 { 105 bool dropped = this->pickups_.erase(pickup) == 1; 106 if(dropped && drop) 107 { 108 COUT(4) << "Dropping Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl; 109 pickup->dropped(); 110 } 111 return dropped; 112 } 81 void preDestroy(void); 113 82 114 83 /** … … 169 138 */ 170 139 virtual const Vector3& getCarrierPosition(void) = 0; 171 172 /** 173 @brief Get the name of this PickupCarrier. 174 @return Returns the name as a string. 175 */ 176 const std::string& getCarrierName(void) { return this->carrierName_; } // tolua_export 177 178 protected: 140 141 protected: 179 142 /** 180 143 @brief Get all direct children of this PickupSpawner. … … 197 160 std::set<Pickupable*>& getPickups(void) 198 161 { return this->pickups_; } 199 200 /** 201 @brief Set the name of this PickupCarrier. 202 The name needs to be set in the constructor of every class inheriting from PickupCarrier, by calling setCarrierName(). 203 @param name The name to be set. 204 */ 205 void setCarrierName(const std::string& name) 206 { this->carrierName_ = name; } 207 162 208 163 private: 209 164 std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier. 210 std::string carrierName_; //!< The name of the PickupCarrier, as displayed in the PickupInventory. 211 165 212 166 /** 213 @brief Get the number of carrier children this PickupCarrier has. 214 @return Returns the number of carrier children. 167 @brief Adds a Pickupable to the list of pickups that are carried by this PickupCarrier. 168 @param pickup A pointer to the pickup to be added. 169 @return Returns true if successfull, false if the Pickupable was already present. 215 170 */ 216 unsigned int getNumCarrierChildren(void)171 bool addPickup(Pickupable* pickup) 217 172 { 218 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 219 unsigned int size = list->size(); 220 delete list; 221 return size; 173 COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl; 174 return this->pickups_.insert(pickup).second; 222 175 } 223 176 224 177 /** 225 @brief Get the index-th child of thisPickupCarrier.226 @param index The index of the child to return.227 @return Returns t he index-th child.178 @brief Removes a Pickupable from the list of pickups that are carried by thsi PickupCarrier. 179 @param pickup A pointer to the pickup to be removed. 180 @return Returns true if successfull, false if the Pickupable was not present in the list. 228 181 */ 229 PickupCarrier* getCarrierChild(unsigned int index)182 bool removePickup(Pickupable* pickup) 230 183 { 231 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 232 if(list->size() < index) 233 return NULL; 234 PickupCarrier* carrier = (*list)[index]; 235 delete list; 236 return carrier; 184 COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl; 185 return this->pickups_.erase(pickup) == 1; 237 186 } 238 239 /** 240 @brief Get the number of Pickupables this PickupCarrier carries. 241 @return returns the number of pickups. 242 */ 243 unsigned int getNumPickups(void) 244 { return this->pickups_.size(); } 245 246 /** 247 @brief Get the index-th Pickupable of this PickupCarrier. 248 @param index The index of the Pickupable to return. 249 @return Returns the index-th pickup. 250 */ 251 Pickupable* getPickup(unsigned int index) 252 { 253 std::set<Pickupable*>::iterator it; 254 for(it = this->pickups_.begin(); index != 0 && it != this->pickups_.end(); it++) 255 index--; 256 if(it == this->pickups_.end()) 257 return NULL; 258 return *it; 259 } 260 261 }; // tolua_export 262 } // tolua_export 187 188 }; 189 } 263 190 264 191 #endif /* _PickupCarrier_H__ */ -
code/trunk/src/orxonox/interfaces/Pickupable.cc
- Property svn:eol-style set to native
r6901 r7163 34 34 #include "Pickupable.h" 35 35 36 #include "core/LuaState.h" 37 #include "core/GUIManager.h" 36 38 #include "core/Identifier.h" 37 39 #include "core/CoreIncludes.h" 40 #include "util/Convert.h" 41 #include "infos/PlayerInfo.h" 38 42 #include "pickup/PickupIdentifier.h" 43 #include "worldentities/pawns/Pawn.h" 39 44 #include "PickupCarrier.h" 40 45 41 46 namespace orxonox 42 47 { 43 48 44 49 /** 45 50 @brief … … 47 52 */ 48 53 Pickupable::Pickupable() : pickupIdentifier_(NULL), used_(false), pickedUp_(false) 49 { 54 { 50 55 RegisterRootObject(Pickupable); 51 56 52 57 this->carrier_ = NULL; 53 58 54 59 this->pickupIdentifier_ = new PickupIdentifier(this); 55 } 56 57 /** 58 @brief 59 Destructor. 60 this->beingDestroyed_ = false; 61 this->enabled_ = true; 62 } 63 64 /** 65 @brief 66 Destructor. 60 67 */ 61 68 Pickupable::~Pickupable() 62 69 { 63 if(this->isUsed()) 64 this->setUsed(false); 65 66 if(this->isPickedUp() && this->getCarrier() != NULL) 67 { 68 this->getCarrier()->drop(this, false); 69 this->setCarrier(NULL); 70 } 71 70 COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl; 72 71 if(this->pickupIdentifier_ != NULL) 73 72 this->pickupIdentifier_->destroy(); 74 73 } 75 74 75 /** 76 @brief 77 A method that is called by OrxonoxClass::destroy() before the object is actually destroyed. 78 */ 79 void Pickupable::preDestroy(void) 80 { 81 this->beingDestroyed_ = true; 82 83 if(this->isPickedUp()) 84 this->drop(false); // Drops the pickup without creating a PickupSpawner. 85 } 86 87 /** 88 @brief 89 Is called internally within the pickup module to destroy pickups. 90 */ 91 void Pickupable::destroy(void) 92 { 93 this->destroyPickup(); 94 } 95 96 /** 97 @brief 98 Destroys a Pickupable. 99 If the Pickupable is already in the process of being destroyed a warning is displayed and this method is skipped. 100 */ 101 void Pickupable::destroyPickup(void) 102 { 103 if(!this->beingDestroyed_) 104 this->OrxonoxClass::destroy(); 105 else 106 COUT(2) << this->getIdentifier()->getName() << " may be unsafe. " << std::endl; 107 } 108 76 109 /** 77 110 @brief … … 84 117 bool Pickupable::setUsed(bool used) 85 118 { 86 if(this->used_ == used) 87 return false; 88 119 if(this->used_ == used || !this->isPickedUp()) // If either the used status of the Pickupable doesn't change or it isn't picked up. 120 return false; 121 122 if((!this->isUsable() && used) || (!this->isUnusable() && !used)) // If either the Pickupable is requested to be used but it is not usable or the Pickupable is requested to be unused, while it is not unusable. 123 return false; 124 89 125 COUT(4) << "Pickupable (&" << this << ") set to used " << used << "." << std::endl; 90 126 91 127 this->used_ = used; 92 128 this->changedUsed(); 93 return true; 94 } 95 129 130 GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()"); 131 return true; 132 } 133 96 134 /** 97 135 @brief … … 106 144 if(carrier == NULL) 107 145 return false; 146 108 147 return this->isTarget(carrier->getIdentifier()); 109 148 } 110 149 111 150 /** 112 151 @brief … … 125 164 return true; 126 165 } 166 127 167 return false; 128 168 } 129 169 130 170 /** 131 171 @brief … … 140 180 return this->addTarget(target->getIdentifier()); 141 181 } 142 182 143 183 /** 144 184 @brief … … 153 193 if(this->isTarget(target)) //!< If the input target is already present in the list of targets. 154 194 return false; 155 195 156 196 COUT(4) << "Target " << target->getName() << " added to Pickupable (&" << this << ")." << std::endl; 157 197 this->targets_.push_back(target); 158 198 return true; 159 199 } 160 161 /** 162 @brief 163 Sets the Pickupable to picked up. 164 This method will be called by the PickupCarrier picking the Pickupable up. 200 201 /** 202 @brief 203 Can be called to pick up a Pickupable. 165 204 @param carrier 166 The PickupCarrier that picked the Pickupable up. 167 @return 168 Returns false if, for some reason, the pickup could not be picked up, e.g. it was picked up already. 169 */ 170 bool Pickupable::pickedUp(PickupCarrier* carrier) 171 { 172 if(this->isPickedUp()) //!< If the Pickupable is already picked up. 173 return false; 205 A pointer to the PickupCarrier that picks up the Pickupable. 206 @return 207 Returns true if the Pickupable was picked up, false if not. 208 */ 209 bool Pickupable::pickup(PickupCarrier* carrier) 210 { 211 if(carrier == NULL || this->isPickedUp()) //!< If carrier is NULL or the Pickupable is already picked up. 212 return false; 213 214 if(!this->setCarrier(carrier)) 215 { 216 COUT(3) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << std::endl; 217 return false; 218 } 174 219 220 this->setPickedUp(true); 175 221 COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl; 176 this->setCarrier(carrier); 177 this->setPickedUp(true); 178 return true; 179 } 180 222 return true; 223 } 224 225 /** 226 @brief 227 Can be called to drop a Pickupable. 228 @param createSpawner 229 If true a spawner is to be created for the dropped Pickupable. True is default. 230 @return 231 Returns true if the Pickupable has been dropped, false if not. 232 */ 233 bool Pickupable::drop(bool createSpawner) 234 { 235 if(!this->isPickedUp()) // If the Pickupable is not picked up. 236 return false; 237 238 assert(this->getCarrier()); // The Carrier cannot be NULL at this point. 239 if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later? 240 COUT(2) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << std::endl; 241 242 COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl; 243 this->setUsed(false); 244 this->setPickedUp(false); 245 246 bool created = false; 247 if(createSpawner) 248 created = this->createSpawner(); 249 250 this->setCarrier(NULL); 251 252 if(!created && createSpawner) // If a PickupSpawner should have been created but wasn't. 253 this->destroy(); 254 255 return true; 256 } 257 181 258 /** 182 259 @brief … … 189 266 bool Pickupable::setPickedUp(bool pickedUp) 190 267 { 191 if(this->pickedUp_ == pickedUp) 192 return false; 193 268 if(this->pickedUp_ == pickedUp) // If the picked up status has not changed. 269 return false; 270 194 271 COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl; 195 272 196 273 this->pickedUp_ = pickedUp; 274 if(!pickedUp) // if the Pickupable has been dropped it unregisters itself with its PickupCarrier. 275 this->getCarrier()->removePickup(this); 197 276 this->changedPickedUp(); 198 return true; 199 } 200 277 GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()"); 278 return true; 279 } 280 201 281 /** 202 282 @brief … … 204 284 @param carrier 205 285 Sets the input PickupCarrier as the carrier of the pickup. 206 */ 207 inline bool Pickupable::setCarrier(PickupCarrier* carrier) 208 { 209 if(this->carrier_ == carrier) 210 return false; 211 286 @param tell 287 If true (default) the pickup is added to the list of pickups in the PickupCarrier. 288 @return 289 Returns true if successful, false if not. 290 */ 291 bool Pickupable::setCarrier(orxonox::PickupCarrier* carrier, bool tell) 292 { 293 if(this->carrier_ == carrier) // If the PickupCarrier doesn't change. 294 return false; 295 212 296 COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl; 297 298 if(carrier != NULL && tell) 299 { 300 if(!carrier->addPickup(this)) 301 return false; 302 } 213 303 214 304 this->carrier_ = carrier; … … 216 306 return true; 217 307 } 218 219 /** 220 @brief 221 Sets the Pickupable to not picked up or dropped. 222 This method will be called by the PickupCarrier dropping the Pickupable. 223 @return 224 Returns false if the pickup could not be dropped. 225 */ 226 bool Pickupable::dropped(void) 227 { 228 if(!this->isPickedUp()) //!< If the Pickupable is not picked up. 229 return false; 230 231 COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl; 232 this->setUsed(false); 233 this->setPickedUp(false); 234 235 bool created = this->createSpawner(); 236 237 this->setCarrier(NULL); 238 239 if(!created) 240 { 241 this->destroy(); 242 } 243 244 return true; 245 } 246 308 309 /** 310 @brief 311 Is called by the PickupCarrier when it is being destroyed. 312 */ 313 void Pickupable::carrierDestroyed(void) 314 { 315 this->destroy(); 316 } 317 247 318 /** 248 319 @brief … … 255 326 OrxonoxClass* item = NULL; 256 327 this->clone(item); 257 328 258 329 Pickupable* pickup = dynamic_cast<Pickupable*>(item); 259 330 260 331 COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl; 261 332 return pickup; 262 333 } 263 334 264 335 /** 265 336 @brief … … 273 344 SUPER(Pickupable, clone, item); 274 345 } 275 346 347 /** 348 @brief 349 Method to transcribe a Pickupable as a Rewardable to the player. 350 @param player 351 A pointer to the PlayerInfo, do whatever you want with it. 352 @return 353 Return true if successful. 354 */ 355 bool Pickupable::reward(PlayerInfo* player) 356 { 357 ControllableEntity* entity = player->getControllableEntity(); 358 Pawn* pawn = static_cast<Pawn*>(entity); 359 PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn); 360 return this->pickup(carrier); 361 } 362 276 363 } -
code/trunk/src/orxonox/interfaces/Pickupable.h
- Property svn:eol-style set to native
r6901 r7163 41 41 42 42 #include "core/OrxonoxClass.h" 43 #include "Rewardable.h" 43 44 44 namespace orxonox 45 { 46 45 namespace orxonox // tolua_export 46 { // tolua_export 47 47 48 /** 48 49 @brief … … 51 52 Damian 'Mozork' Frick 52 53 */ 53 class _OrxonoxExport Pickupable : virtual public OrxonoxClass 54 { 54 class _OrxonoxExport Pickupable // tolua_export 55 : virtual public OrxonoxClass, public Rewardable 56 { // tolua_export 55 57 protected: 56 58 Pickupable(); //!< Default constructor. 57 59 58 60 public: 59 61 virtual ~Pickupable(); //!< Default destructor. 60 62 61 63 /** 62 64 @brief Get whether the pickup is currently in use or not. 63 65 @return Returns true if the pickup is currently in use. 64 66 */ 65 inline bool isUsed(void) 66 { return this->used_; } 67 inline bool isUsed(void) { return this->used_; } // tolua_export 67 68 /** 68 69 @brief Should be called when the pickup has transited from used to unused or the other way around. … … 70 71 */ 71 72 virtual void changedUsed(void) {} 72 73 73 74 /** 74 75 @brief Get the carrier of the pickup. … … 82 83 */ 83 84 virtual void changedCarrier(void) {} 84 85 85 86 /** 86 87 @brief Returns whether the Pickupable is currently picked up. 87 88 @return Returns true if the Pickupable is currently picked up, false if not. 88 89 */ 89 inline bool isPickedUp(void) 90 { return this->pickedUp_; } 90 inline bool isPickedUp(void) { return this->pickedUp_; } // tolua_export 91 91 /** 92 92 @brief Should be called when the pickup has transited from picked up to dropped or the other way around. … … 94 94 */ 95 95 virtual void changedPickedUp(void) {} 96 97 /** 98 @brief Returns whether the Pickupable can be used. 99 @return Returns true if it can be used. 100 */ 101 inline bool isUsable(void) { return this->enabled_; } // tolua_export 96 102 97 bool pickedUp(PickupCarrier* carrier); //!< Sets the Pickupable to picked up. 98 bool dropped(void); //!< Sets the Pickupable to not picked up or dropped. 99 103 /** 104 @brief Returns whether the Pickupable can be unused. 105 @return Returns true if it can be unused. 106 */ 107 inline bool isUnusable(void) { return this->enabled_; } // tolua_export 108 109 /** 110 @brief Returns whether the Pickupable is enabled. 111 Once a Pickupable is disabled it cannot be enabled again. A Pickupable that is disabled can neither be used nor unused. 112 @return Returns true if the Pickupable is enabled. 113 */ 114 inline bool isEnabled(void) 115 { return this->enabled_; } 116 117 bool pickup(PickupCarrier* carrier); //!< Can be called to pick up a Pickupable. 118 bool drop(bool createSpawner = true); //!< Can be called to drop a Pickupable. 119 100 120 virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup. 101 121 bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable. 102 122 bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup. 103 123 bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup. 104 124 105 125 Pickupable* clone(void); //!< Creates a duplicate of the Pickupable. 106 126 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 107 127 108 128 /** 109 129 @brief Get the PickupIdentifier of this Pickupable. … … 112 132 virtual const PickupIdentifier* getPickupIdentifier(void) 113 133 { return this->pickupIdentifier_; } 114 134 115 135 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. 116 136 bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up. 117 bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup. 118 137 //TODO: private? 138 bool setCarrier(PickupCarrier* carrier, bool tell = true); //!< Sets the carrier of the pickup. 139 140 //TODO: private? 141 virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed. 142 143 void destroy(void); //!< Is called internally within the pickup module to destroy pickups. 144 119 145 protected: 120 146 /** … … 122 148 */ 123 149 void initializeIdentifier(void) {} 124 150 151 virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed. 152 virtual void destroyPickup(void); //!< Destroys a Pickupable. 153 154 /** 155 @brief Sets the Pickuapble to disabled. 156 */ 157 inline void setDisabled(void) 158 { this->enabled_ = false; } 159 125 160 /** 126 161 @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. … … 131 166 */ 132 167 virtual bool createSpawner(void) = 0; 133 168 134 169 PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable. 135 170 136 171 private: 137 138 bool used_; //!< Whether the pickup is currently in use or not.139 bool pickedUp_; //!< Whether the pickup is currently picked up or not.140 141 PickupCarrier* carrier_; //!< The carrier of the pickup.142 std::list<Identifier*> targets_; //!< The possible targets of this pickup.143 172 144 }; 145 173 bool used_; //!< Whether the Pickupable is currently in use or not. 174 bool pickedUp_; //!< Whether the Pickupable is currently picked up or not. 175 176 bool enabled_; //!< Whether the Pickupable is enabled or not. 177 178 PickupCarrier* carrier_; //!< The PickupCarrier of the Pickupable. 179 std::list<Identifier*> targets_; //!< The possible targets of this Pickupable. 180 181 bool beingDestroyed_; //!< Is true if the Pickupable is in the process of being destroyed. 182 183 // For implementing the Rewardable interface: 184 public: 185 virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player. 186 187 }; // tolua_export 188 146 189 SUPER_FUNCTION(10, Pickupable, changedUsed, false); 147 190 SUPER_FUNCTION(12, Pickupable, changedCarrier, false); 148 191 SUPER_FUNCTION(13, Pickupable, changedPickedUp, false); 149 } 192 } // tolua_export 150 193 151 194 #endif /* _Pickupable_H__ */ -
code/trunk/src/orxonox/interfaces/RadarListener.h
r5781 r7163 41 41 virtual ~RadarListener() { } 42 42 43 virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0; 43 virtual void addObject(RadarViewable* viewable) = 0; 44 virtual void removeObject(RadarViewable* viewable) = 0; 45 virtual void objectChanged(RadarViewable* viewable) = 0; 44 46 virtual float getRadarSensitivity() const = 0; 45 47 virtual void radarTick(float dt) = 0; -
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r6417 r7163 29 29 #include "RadarViewable.h" 30 30 31 #include <OgreSceneManager.h>32 #include <OgreSceneNode.h>33 #include <OgreEntity.h>34 35 31 #include "util/StringUtils.h" 36 32 #include "core/CoreIncludes.h" 37 #include " tools/DynamicLines.h"33 #include "core/GameMode.h" 38 34 #include "worldentities/WorldEntity.h" 39 35 #include "Radar.h" 40 36 #include "Scene.h" 41 #include "overlays/Map.h"42 37 43 38 namespace orxonox … … 46 41 @brief Constructor. 47 42 */ 48 RadarViewable::RadarViewable() 49 : MapNode_(NULL) 50 , MapEntity_(NULL) 51 , line_(NULL) 52 , LineNode_(NULL) 53 , isHumanShip_(false) 43 RadarViewable::RadarViewable(BaseObject* creator, const WorldEntity* wePtr) 44 : isHumanShip_(false) 54 45 , bVisibility_(true) 46 , bInitialized_(false) 47 , creator_(creator) 48 , wePtr_(wePtr) 55 49 , radarObjectCamouflage_(0.0f) 56 50 , radarObjectShape_(Dot) … … 60 54 61 55 this->uniqueId_=getUniqueNumberString(); 62 /* 63 if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr()) 56 if( GameMode::showsGraphics() ) 64 57 { 65 this->addEntity(); 58 this->radar_ = this->creator_->getScene()->getRadar(); 59 this->radar_->addRadarObject(this); 66 60 } 67 68 */ 61 this->bInitialized_ = true; 69 62 } 70 63 … … 72 65 RadarViewable::~RadarViewable() 73 66 { 74 if (this->isHumanShip_ && MapNode_)75 MapNode_->removeAllChildren();76 67 77 if (MapNode_) 78 delete MapNode_; 79 80 if (MapEntity_) 81 delete MapEntity_; 82 83 if (line_) 84 delete line_; 85 86 if (LineNode_) 87 delete LineNode_; 88 } 89 90 void RadarViewable::addMapEntity() 91 { //TODO Check shape and add accordantly 92 if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() ) 68 if( this->bInitialized_ ) 93 69 { 94 COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n"; 95 this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh"); 96 /*this->line_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l"); 97 this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP); 98 //line_->position(0, -it->getRVWorldPosition().y, 0); 99 //this->line_->position(0, -20, 0); 100 this->line_->position(0, 0, -10); //Front Arrow 101 this->line_->position(0, 0, 0); 102 103 this->line_->end(); */ 104 this->line_ = new Ogre::DynamicLines(Ogre::RenderOperation::OT_LINE_LIST); 105 this->line_->addPoint( Vector3(0,0,0) ); 106 this->line_->addPoint( Vector3(0,0,0) ); 107 108 this->MapNode_->attachObject( this->MapEntity_ ); 109 110 this->LineNode_ = this->MapNode_->createChildSceneNode(); 111 this->LineNode_->attachObject( this->line_ ); 112 } 113 else 114 { 115 COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n"; 70 if( GameMode::showsGraphics() ) 71 { 72 this->radar_->removeRadarObject(this); 73 } 116 74 } 117 75 } 118 76 119 void RadarViewable::updateMapPosition() 120 { 121 if( this->MapNode_ ) 122 { 123 this->MapNode_->setPosition( this->getRVWorldPosition() ); 124 this->MapNode_->translate( this->getRVOrientedVelocity(), static_cast<Ogre::Node::TransformSpace>(3) ); 125 this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() ); 126 //Vector3 v = this->getRVWorldPosition(); 127 //this->line_->setPoint(1, Vector3(0,v.y,0) ); 128 this->line_->setPoint(1, Vector3( 0, static_cast<float>(static_cast<int>( -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ) ) ,0 )); 129 this->line_->update(); 130 if( Map::getSingletonPtr()->playerShipNode_ ) 131 this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y); 132 } 133 } 134 135 void RadarViewable::setRadarObjectDescription(const std::string& str) 136 { 137 Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 138 if (radar) 139 this->radarObjectShape_ = radar->addObjectDescription(str); 140 else 141 { 142 CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl; 143 } 144 this->radarObjectDescription_ = str; 145 } 77 // void RadarViewable::setRadarObjectDescription(const std::string& str) 78 // { 79 // Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 80 // if (radar) 81 // this->radarObjectShape_ = radar->addObjectDescription(str); 82 // else 83 // { 84 // CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl; 85 // } 86 // this->radarObjectDescription_ = str; 87 // } 146 88 147 89 const Vector3& RadarViewable::getRVWorldPosition() const … … 167 109 } 168 110 } 111 112 void RadarViewable::settingsChanged() 113 { 114 if( GameMode::showsGraphics() ) 115 { 116 this->radar_->radarObjectChanged(this); 117 } 118 } 169 119 } -
code/trunk/src/orxonox/interfaces/RadarViewable.h
r5781 r7163 36 36 37 37 #include "util/Math.h" 38 #include "util/OgreForwardRefs.h"39 38 #include "core/OrxonoxClass.h" 39 #include "core/SmartPtr.h" 40 40 41 41 namespace orxonox 42 42 { 43 class BaseObject; 44 43 45 /** 44 46 @brief Interface for receiving window events. … … 56 58 57 59 public: 58 RadarViewable( );60 RadarViewable(BaseObject* creator, const WorldEntity* wePtr); 59 61 virtual ~RadarViewable(); 60 62 61 63 inline void setRadarObjectCamouflage(float camouflage) 62 { this->radarObjectCamouflage_ = camouflage; } 64 { 65 if( this->radarObjectCamouflage_ != camouflage ) 66 { 67 this->radarObjectCamouflage_ = camouflage; 68 this->settingsChanged(); 69 } 70 } 63 71 inline float getRadarObjectCamouflage() const 64 72 { return this->radarObjectCamouflage_; } 65 73 66 74 inline void setRadarObjectColour(const ColourValue& colour) 67 { this->radarObjectColour_ = colour; } 75 { 76 if(this->radarObjectColour_ != colour) 77 { 78 this->radarObjectColour_ = colour; 79 this->settingsChanged(); 80 } 81 } 68 82 inline const ColourValue& getRadarObjectColour() const 69 83 { return this->radarObjectColour_; } 70 84 71 void setRadarObjectDescription(const std::string& str);72 inline const std::string& getRadarObjectDescription() const73 { return this->radarObjectDescription_; }85 // void setRadarObjectDescription(const std::string& str); 86 // inline const std::string& getRadarObjectDescription() const 87 // { return this->radarObjectDescription_; } 74 88 75 89 inline void setRadarVisibility(bool b) 76 { this->bVisibility_ = b; } 90 { 91 if(b!=this->bVisibility_) 92 { 93 this->bVisibility_ = b; 94 this->settingsChanged(); 95 } 96 } 77 97 inline bool getRadarVisibility() const 78 98 { return this->bVisibility_; } 79 99 80 virtual const WorldEntity* getWorldEntity() const = 0;100 virtual const WorldEntity* getWorldEntity() const{ return this->wePtr_; } 81 101 82 102 const Vector3& getRVWorldPosition() const; … … 84 104 85 105 inline void setRadarObjectShape(Shape shape) 86 { this->radarObjectShape_ = shape; } 106 { 107 if( this->radarObjectShape_ != shape ) 108 { 109 this->radarObjectShape_ = shape; 110 this->settingsChanged(); 111 } 112 } 87 113 inline Shape getRadarObjectShape() const 88 114 { return this->radarObjectShape_; } 115 void settingsChanged(); 89 116 90 /* 91 inline void setMapNode(Ogre::SceneNode * node) 92 { this->MapNode_ = node; } 93 inline Ogre::SceneNode * getMapNode() const 94 { return this->MapNode_; } 95 inline void setMapEntity(Ogre::Entity * ent) 96 { this->MapEntity_ = ent; } 97 inline Ogre::Entity * getMapEntity() const 98 { return this->MapEntity_; } 99 */ 100 //Used for Map 101 Ogre::SceneNode * MapNode_; 102 Ogre::Entity * MapEntity_; 103 Ogre::DynamicLines* line_; 104 Ogre::SceneNode * LineNode_; 105 void addMapEntity(); 106 void updateMapPosition(); 117 107 118 bool isHumanShip_; 108 119 inline const std::string& getUniqueId() … … 115 126 void validate(const WorldEntity* object) const; 116 127 bool bVisibility_; 128 bool bInitialized_; 117 129 //Map 118 130 std::string uniqueId_; 131 BaseObject* creator_; 119 132 120 133 121 134 //Radar 135 const WorldEntity* wePtr_; 136 SmartPtr<Radar> radar_; 122 137 float radarObjectCamouflage_; 123 138 Shape radarObjectShape_; -
code/trunk/src/orxonox/interfaces/Rewardable.h
r6417 r7163 48 48 Damian 'Mozork' Frick 49 49 */ 50 class _OrxonoxExport Rewardable : public OrxonoxClass50 class _OrxonoxExport Rewardable : virtual public OrxonoxClass 51 51 { 52 52 public: … … 59 59 Must be implemented by every class inheriting from Rewardable. 60 60 @param player 61 A pointer to the ControllableEntity, do whatever you want with it.61 A pointer to the PlayerInfo, do whatever you want with it. 62 62 @return 63 63 Return true if successful.
Note: See TracChangeset
for help on using the changeset viewer.