Changeset 11353 for code/trunk/src/modules/pickup
- Timestamp:
- Mar 9, 2017, 2:46:20 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/HUD_HS16 (added) merged: 11212,11222-11223,11240-11241,11252-11253,11262-11264,11277,11293,11295,11305,11314,11323,11325,11336
- Property svn:mergeinfo changed
-
code/trunk/src/modules/pickup/CMakeLists.txt
r9348 r11353 19 19 PickupPrecompiledHeaders.h 20 20 LINK_LIBRARIES 21 overlays 21 22 orxonox 22 23 SOURCE_FILES ${PICKUP_SRC_FILES} -
code/trunk/src/modules/pickup/PickupManager.cc
r11099 r11353 41 41 #include "network/Host.h" 42 42 #include "network/NetworkFunctionIncludes.h" 43 #include "core/input/KeyBinderManager.h" //for keybinding 44 #include "core/input/KeyBinder.h" //for keybinding 45 #include "core/command/ConsoleCommandIncludes.h" 43 46 44 47 #include "infos/PlayerInfo.h" … … 48 51 #include "CollectiblePickup.h" 49 52 #include "PickupRepresentation.h" 53 #include "overlays/hud/HUDPickupSystem.h" 50 54 51 55 namespace orxonox … … 63 67 64 68 RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>(); 69 70 SetConsoleCommand("useUnusePickup", &PickupManager::useUnusePickup).addShortcut().setActive(true); 65 71 66 72 /** … … 260 266 assert(pickup); 261 267 268 for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>()) 269 pickupSystem = hud; 270 262 271 if(!GameMode::isMaster()) // If this is neither standalone nor the server. 263 272 return; … … 283 292 if(pickedUp) // If the Pickupable has changed to picked up, it is added to the required lists. 284 293 { 285 index = this->getPickupIndex(); // Ge a new identifier (index) for the Pickupable.294 index = this->getPickupIndex(); // Get a new identifier (index) for the Pickupable. 286 295 // Add the Pickupable to the indexes_ and pickups_ lists. 287 296 this->indexes_[pickup] = index; 288 297 this->pickups_[index] = pickup; 298 299 this->picks.push_back(pickup); 300 301 if(pickupSystem) 302 pickupSystem->updatePickupList(picks, indexes_); 303 289 304 } 290 305 else // If it was dropped, it is removed from the required lists. … … 294 309 index = it->second; 295 310 296 // Remove the Pickupable from the indexes_ and pickups_ list. 297 this->indexes_.erase(it); 298 this->pickups_.erase(index); 311 this->indexes_.erase(pickup); 312 this->pickups_.erase(index); //set to null, so that can be identified as free slot by getPickupIndex() 313 314 315 this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector 316 317 if(pickupSystem) 318 pickupSystem->removePickup(pickup); 299 319 } 300 320 … … 323 343 324 344 } 345 346 //This function is called by the command line or by the key binding 347 //it uses or unuses the pickup, depending on its current state 348 //or drops it (depends what you comment/uncomment) 349 void PickupManager::useUnusePickup(uint32_t index) 350 { 351 PickupManager& manager = PickupManager::getInstance(); 352 353 if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything 354 355 Pickupable* pickup=manager.pickups_.find(index)->second; 356 if(pickup==nullptr) 357 { 358 return; //pickup does not exist 359 } 360 361 //if the pickup should be dropped upon key press 362 manager.dropPickup(index); 363 364 //if the pickup should be used/unused upon key press 365 366 // if(pickup->isUsed()) 367 // manager.usePickup(index, false); 368 // else 369 // manager.usePickup(index, true); 370 } 371 325 372 326 373 /** … … 402 449 Pickupable* pickupable = this->pickups_.find(pickup)->second; 403 450 if(pickupable != nullptr) 451 { 404 452 pickupable->drop(); 453 454 } 405 455 } 406 456 // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server. … … 495 545 /** 496 546 @brief 497 Get a new index for a Pickupable.498 This will work as long as the number of Pickupables that are picked up is sufficiently small and as long as they don't exist forever.547 Get a new index between 0 and 9 for a Pickupable. 548 If all slots are occupied, the Pickupable in the first slot will be dropped. 499 549 @return 500 550 Returns the new index. … … 502 552 uint32_t PickupManager::getPickupIndex(void) 503 553 { 504 if(this->pickupHighestIndex_ == uint32_t(~0x0)-1) // If we've reached the highest possible number, we wrap around. 505 this->pickupHighestIndex_ = 0; 506 return this->pickupHighestIndex_++; 554 //check if there are free slots available 555 556 for(uint32_t i=0; i<10; i++) 557 { 558 if(!pickups_.count(i)) return i; 559 } 560 //all slots are full and we have to drop sth 561 orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl; 562 this->dropPickup(0); 563 return 0; 507 564 } 508 565 -
code/trunk/src/modules/pickup/PickupManager.h
r11071 r11353 42 42 43 43 #include "PickupRepresentation.h" 44 44 #include "interfaces/Pickupable.h" 45 45 #include "util/Singleton.h" 46 46 #include "interfaces/PickupListener.h" 47 #include "overlays/hud/HUDPickupSystem.h" 47 48 48 49 namespace orxonox // tolua_export … … 135 136 136 137 void dropPickup(uint32_t pickup); //!< Drop the input Pickupable. 138 static void useUnusePickup(uint32_t index); //tolua_export 137 139 void usePickup(uint32_t pickup, bool use); //!< Use (or unuse) the input Pickupable. 138 140 /** … … 147 149 static void dropPickupNetworked(uint32_t pickup); //!< Helper method to drop the input pickup on the server. 148 150 static void usePickupNetworked(uint32_t pickup, bool use); //!< Helper method to use (or unuse) the input Pickupable on the server. 151 void setPickupSystem(HUDPickupSystem* system); 149 152 150 153 private: 154 HUDPickupSystem* pickupSystem; 155 std::vector<Pickupable*> picks; 156 151 157 static PickupManager* singletonPtr_s; 152 158 static const std::string guiName_s; //!< The name of the PickupInventory … … 166 172 void updateGUI(void); //!< Updates the PickupInventory GUI. 167 173 uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable. 168 174 169 175 }; // tolua_export 170 176 -
code/trunk/src/modules/pickup/items/SpeedPickup.h
r9667 r11353 48 48 A Pickup which can manipulate the Speed of a Pawn. 49 49 50 There are 5 parameters that can be c osen:50 There are 5 parameters that can be chosen: 51 51 - The @b speedMultiply, specifies a factor by which the Spaceships speed is multiplied. The default is 1. 52 52 - The @b speedAdd, specifies a value that is added to the speed of the Spaceship. The default is 0.
Note: See TracChangeset
for help on using the changeset viewer.