Changeset 11708 for code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
- Timestamp:
- Jan 6, 2018, 6:07:53 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
r11705 r11708 34 34 #include <OgrePanelOverlayElement.h> 35 35 36 #include "HUDPickupSystem.h" 37 36 38 #include "core/CoreIncludes.h" 37 39 #include "core/class/Super.h" 38 40 #include "util/Convert.h" 39 #include "HUDPickupSystem.h"40 41 #include "pickup/PickupManager.h" 42 #include "worldentities/pawns/Pawn.h" 41 43 42 44 namespace orxonox … … 78 80 79 81 } 80 82 83 void HUDPickupSystem::changedOwner() 84 { 85 SUPER(HUDPickupSystem, changedOwner); 86 87 this->owner_ = orxonox_cast<Pawn*>(this->getOwner()); 88 } 89 81 90 void HUDPickupSystem::tick(float dt) 82 91 { 83 92 SUPER(HUDPickupSystem, tick, dt); 84 93 85 int numPickups = PickupManager::getInstance().getNumPickups(); 94 std::vector<const PickupInventoryContainer*> containers = this->getPickupsForOwner(); 95 86 96 for (size_t index = 0; index < this->items_.size(); ++index) 87 97 { 88 98 Ogre::OverlayElement* item = this->items_[index]; 89 99 90 if ( static_cast<int>(index) < numPickups)100 if (index < containers.size()) 91 101 { 92 const PickupInventoryContainer* container = PickupManager::getInstance().popPickup(); 93 item->setMaterialName(this->getIcon(container->representationName)); 102 item->setMaterialName(this->getIcon(containers[index]->representationName)); 94 103 if (!item->getParent()) 95 104 this->background_->addChild(item); … … 103 112 } 104 113 105 std::string HUDPickupSystem::getIcon(std::string repName) 114 std::vector<const PickupInventoryContainer*> HUDPickupSystem::getPickupsForOwner() const 115 { 116 std::vector<const PickupInventoryContainer*> containers; 117 118 int numPickups = PickupManager::getInstance().getNumPickups(); 119 for (int i = 0; i < numPickups; ++i) 120 { 121 const PickupInventoryContainer* container = PickupManager::getInstance().popPickup(); 122 if (this->owner_ && this->owner_->getObjectID() == container->carrierPawnId) 123 containers.push_back(container); 124 } 125 126 return containers; 127 } 128 129 std::string HUDPickupSystem::getIcon(const std::string& repName) const 106 130 { 107 131 if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
Note: See TracChangeset
for help on using the changeset viewer.