Changeset 9889 in orxonox.OLD for branches/coll_rect/src/lib/collision_reaction/cr_object_damage.cc
- Timestamp:
- Oct 13, 2006, 3:57:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_reaction/cr_object_damage.cc
r9869 r9889 26 26 #include "debug.h" 27 27 28 namespace CoRe 29 { 30 31 ObjectListDefinition(CRObjectDamage); 32 /** 33 * standard constructor 34 */ 35 CRObjectDamage::CRObjectDamage () 36 : CollisionReaction() 37 { 38 this->registerObject(this, CRObjectDamage::_objectList); 39 } 28 40 29 41 30 ObjectListDefinition(CRObjectDamage); 31 /** 32 * standard constructor 33 */ 34 CRObjectDamage::CRObjectDamage () 35 : CollisionReaction() 36 { 37 this->registerObject(this, CRObjectDamage::_objectList); 38 } 42 /** 43 * standard deconstructor 44 */ 45 CRObjectDamage::~CRObjectDamage () 46 {} 39 47 40 48 41 /** 42 * standard deconstructor 43 */ 44 CRObjectDamage::~CRObjectDamage () 45 { 46 } 49 /** 50 * caluculates and applys the reaction to a specific collision 51 * @param collision the collision 52 */ 53 void CRObjectDamage::reactToCollision(Collision* collision) 54 { 55 float damage = 0.0f; 47 56 57 PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n", 58 collision->getEntityA()->getClassCName(), 59 collision->getEntityB()->getClassCName()); 48 60 49 /** 50 * caluculates and applys the reaction to a specific collision51 * @param collision the collision52 */53 void CRObjectDamage::reactToCollision(Collision* collision) 54 { 55 float damage = 0.0f;61 // the collision damage been dealed by the entity 62 if( collision->isEntityACollide()) 63 { 64 damage = collision->getEntityB()->getDamage(); 65 collision->getEntityA()->hit(damage, collision->getEntityB()); 66 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassCName()); 67 } 56 68 57 PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n", 58 collision->getEntityA()->getClassCName(), 59 collision->getEntityB()->getClassCName()); 69 if( collision->isEntityBCollide()) 70 { 71 damage = collision->getEntityA()->getDamage(); 72 collision->getEntityB()->hit(damage, collision->getEntityA()); 73 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassCName()); 74 } 60 75 61 // the collision damage been dealed by the entity 62 if( collision->isEntityACollide()) { 63 damage = collision->getEntityB()->getDamage(); 64 collision->getEntityA()->hit(damage, collision->getEntityB()); 65 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassCName()); 76 collision->flushCollisionEvents(); 77 collision->dispatched(); 78 79 // const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents()); 80 // std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin(); 81 // for(; it != collisionEvents->end(); it++) 82 // { 83 // // go through the collisions and try to estimate the damage 84 // mass = (*it)->getEntityA()->getMass(); 85 // } 86 66 87 } 67 88 68 if( collision->isEntityBCollide()) {69 damage = collision->getEntityA()->getDamage();70 collision->getEntityB()->hit(damage, collision->getEntityA());71 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassCName());72 }73 74 collision->flushCollisionEvents();75 collision->dispatched();76 77 // const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());78 // std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin();79 // for(; it != collisionEvents->end(); it++)80 // {81 // // go through the collisions and try to estimate the damage82 // mass = (*it)->getEntityA()->getMass();83 // }84 85 89 } 86
Note: See TracChangeset
for help on using the changeset viewer.