- Timestamp:
- Apr 9, 2014, 9:50:45 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10019 r10023 88 88 if((this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 89 89 { 90 // The Entity is added to the part's entityList_ 90 91 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 92 // An entry in the partMap_ is created, assigning the part to the entity. 93 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]); 91 94 orxout() << "A matching part-entity-pair with name " << this->partList_[j]->getName() << " was found!" << endl; 92 95 this->partList_[j]->printEntities(); // FIXME: (noep) remove debug … … 94 97 } 95 98 } 99 100 orxout() << "List of all assignments:" << endl; 101 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it) 102 { 103 orxout() << "Entity: " << it->first << " Part: " << it->second << endl; 104 } 96 105 } 97 106 … … 143 152 orxout() << "UserPtr of said collisionShape: " << cs->getUserPointer() << endl; 144 153 145 // List all attached Objects 154 155 // Print all attached objects & parts 156 /* 146 157 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 147 for (int i=0; i<10; i++) 158 159 for (int i=0; i<50; i++) 148 160 { 149 161 if (this->getAttachedObject(i)==NULL) … … 157 169 { 158 170 orxout() << " " << i << ": " << this->partList_[i] << " (" << this->partList_[i]->getName() << ")" << endl; 159 } 171 }*/ 172 160 173 161 174 //int collisionShapeIndex = this->isMyCollisionShape(cs); 162 175 //orxout() << collisionShapeIndex << endl; 163 176 164 orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 177 //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 178 179 orxout() << "CP_start" << endl; 165 180 166 181 if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL) 167 182 this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator); 168 //else 169 // SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs); 183 else 184 SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs); 185 186 orxout() << "CP_end" << endl; 170 187 171 188 /* … … 208 225 OrxAssert(part != NULL, "The ShipPart cannot be NULL."); 209 226 this->partList_.push_back(part); 227 part->setParent(this); 210 228 //part->addToSpaceShip(this); //FIXME: (noep) add 211 229 this->updatePartAssignment(); … … 242 260 } 243 261 262 void ModularSpaceShip::removeShipPart(ShipPart* part) 263 { 264 // Remove the part from the partList_ 265 std::vector<ShipPart*>::iterator it = this->partList_.begin(); 266 for(unsigned int i = 0; i < this->partList_.size(); i++) 267 { 268 if(this->partList_[i] == part) 269 this->partList_.erase(it); 270 it++; 271 } 272 // Remove the part-entity assignment and detach the Entity of this ShipPart 273 for (std::map<StaticEntity*, ShipPart*>::iterator itt = this->partMap_.begin(); itt != this->partMap_.end(); ++itt) 274 { 275 if (itt->second == part) 276 { 277 this->detach(itt->first); 278 this->partMap_.erase(itt); 279 } 280 } 281 } 282 244 283 }
Note: See TracChangeset
for help on using the changeset viewer.