- Timestamp:
- Apr 3, 2014, 3:45:50 PM (11 years ago)
- Location:
- code/branches/modularships
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
r10011 r10019 51 51 52 52 <parts> 53 <ShipPart name=" part0" />54 <ShipPart name=" part1" />53 <ShipPart name="frontL" /> 54 <ShipPart name="frontR" /> 55 55 </parts> 56 56 -
code/branches/modularships/src/orxonox/CMakeLists.txt
r10011 r10019 32 32 PlayerManager.cc 33 33 Radar.cc 34 ShipPart.cc35 34 # Test.cc 36 35 -
code/branches/modularships/src/orxonox/items/CMakeLists.txt
r5781 r10019 3 3 Engine.cc 4 4 MultiStateEngine.cc 5 ShipPart.cc 5 6 ) -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10011 r10019 38 38 #include "gametypes/Gametype.h" 39 39 40 #include "ShipPart.h" 40 #include "items/ShipPart.h" 41 #include "worldentities/StaticEntity.h" 42 #include <BulletCollision/CollisionShapes/btCollisionShape.h> 41 43 42 44 … … 75 77 void ModularSpaceShip::updatePartAssignment() 76 78 { 77 79 // iterate through all attached objects 80 for (unsigned int i=0; i < 100; i++) 81 { 82 if (this->getAttachedObject(i) == NULL) 83 break; 84 // iterate through all attached parts 85 for(unsigned int j = 0; j < this->partList_.size(); j++) 86 { 87 // if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done). 88 if((this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 89 { 90 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 91 orxout() << "A matching part-entity-pair with name " << this->partList_[j]->getName() << " was found!" << endl; 92 this->partList_[j]->printEntities(); // FIXME: (noep) remove debug 93 } 94 } 95 } 96 } 97 98 void ModularSpaceShip::attach(WorldEntity* object) 99 { 100 SpaceShip::attach(object); 101 this->updatePartAssignment(); 102 } 103 104 void ModularSpaceShip::addPartEntityAssignment(StaticEntity* entity, ShipPart* part) 105 { 106 if (!entity || !part) 107 return; 108 109 if (this->partMap_.find(entity) != this->partMap_.end()) 110 { 111 orxout(internal_warning) << "Assigning an Entity to multiple parts is not yet supported." << endl; 112 return; 113 } 114 115 this->partMap_[entity] = part; 116 orxout() << "New entity-part assignment created!" << endl; 117 } 118 119 /** 120 @brief 121 Get the ShipPart an attached entity belongs to. 122 @param entity 123 The entity to be searched. 124 @return 125 Returns a pointer to the ShipPart the entity belongs to. 126 */ 127 ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const 128 { 129 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it) 130 { 131 if (it->first == entity) 132 return it->second; 133 } 134 return NULL; 78 135 } 79 136 … … 84 141 { 85 142 orxout() << "Mdamage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl; 86 orxout() << "Attached parts:" << endl; 143 orxout() << "UserPtr of said collisionShape: " << cs->getUserPointer() << endl; 144 145 // List all attached Objects 146 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 147 for (int i=0; i<10; i++) 148 { 149 if (this->getAttachedObject(i)==NULL) 150 break; 151 orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")"; 152 orxout() << endl; 153 } 154 155 orxout() << " Attached ShipParts:" << endl; 87 156 for(unsigned int i=0; i < this->partList_.size(); i++) 88 157 { … … 90 159 } 91 160 92 int collisionShapeIndex = this->isMyCollisionShape(cs); 93 orxout() << collisionShapeIndex << endl; 94 161 //int collisionShapeIndex = this->isMyCollisionShape(cs); 162 //orxout() << collisionShapeIndex << endl; 163 164 orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 165 166 if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL) 167 this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator); 168 //else 169 // SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs); 170 171 /* 95 172 // Applies multiplier given by the DamageBoost Pickup. 96 173 if (originator) … … 118 195 119 196 this->lastHitOriginator_ = originator; 120 } 197 }*/ 121 198 } 122 199 -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10011 r10019 40 40 41 41 #include "SpaceShip.h" 42 #include "ShipPart.h" 42 #include "items/ShipPart.h" 43 #include <map> 43 44 44 45 namespace orxonox … … 94 95 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 95 96 97 void attach(WorldEntity* object); 98 99 void addPartEntityAssignment(StaticEntity* entity, ShipPart* part); 100 ShipPart* getPartOfEntity(StaticEntity* entity) const; 101 96 102 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 97 103 … … 108 114 void registerVariables(); 109 115 std::vector<ShipPart*> partList_; // The list of all Parts mounted on this ModularSpaceShip. 116 std::map<StaticEntity*, ShipPart*> partMap_; 110 117 111 118 }; -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
r10011 r10019 230 230 231 231 virtual int isMyCollisionShape(const btCollisionShape* cs); 232 void printBtChildShapes(btCompoundShape* cs, int indent, int subshape); 233 void printSpaces(int num); 232 void printBtChildShapes(btCompoundShape* cs, int indent, int subshape); // FIXME: (noep) remove debug 233 void printSpaces(int num); // FIXME: (noep) remove debug 234 234 int entityOfCollisionShape(const btCollisionShape* cs); 235 235
Note: See TracChangeset
for help on using the changeset viewer.