Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 13, 2006, 3:57:44 PM (18 years ago)
Author:
patrick
Message:

added namspacing to collision reaction. now comes the harder part :D

File:
1 edited

Legend:

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

    r9869 r9889  
    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    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
    6687  }
    6788
    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 
    8589}
    86 
Note: See TracChangeset for help on using the changeset viewer.