Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2006, 4:39:45 PM (17 years ago)
Author:
patrick
Message:

merged the temp branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/coll_rect.merge/src/lib/collision_reaction/cr_object_damage.cc

    r9869 r10010  
    2626#include "debug.h"
    2727
     28namespace CoRe
     29{
     30
     31  ObjectListDefinition(CRObjectDamage);
     32  /**
     33   *  standard constructor
     34   */
     35  CRObjectDamage::CRObjectDamage ()
     36      : CollisionReaction()
     37  {
     38    this->registerObject(this, CRObjectDamage::_objectList);
     39  }
    2840
    2941
    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  {}
    3947
    4048
    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;
    4756
     57    PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n",
     58              collision->getEntityA()->getClassCName(),
     59              collision->getEntityB()->getClassCName());
    4860
    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;
     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    }
    5668
    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    }
    6075
    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    //   const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());
     77    //   std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin();
     78    //   for(; it != collisionEvents->end(); it++)
     79    //   {
     80    //     // go through the collisions and try to estimate the damage
     81    //     mass = (*it)->getEntityA()->getMass();
     82    //   }
     83
    6684  }
    6785
    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 damage
    82 //     mass = (*it)->getEntityA()->getMass();
    83 //   }
    84 
    8586}
    86 
Note: See TracChangeset for help on using the changeset viewer.