Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2014, 8:38:07 PM (10 years ago)
Author:
noep
Message:

Cleaned up the process passing the collisionshape which was hit to the Pawn. Started implementation of ModularSpaceShip and ShipPart.

Location:
code/branches/modularships/src/modules/weapons/projectiles
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.cc

    r9995 r10011  
    7878    @see Pawn.h
    7979    */
    80     bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     80    bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
    8181    {
    8282        if (!this->bDestroy_ && GameMode::isMaster())
     
    9696            if (victim)
    9797            {
    98                 victim->hit(this->getShooter(), contactPoint, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
     98                victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
    9999                victim->startReloadCountdown();
    100100            }
     
    141141    }
    142142
    143     bool BasicProjectile::customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
    144         {
    145             if (!this->bDestroy_ && GameMode::isMaster())
    146             {
    147                 if (otherObject == this->getShooter()) // Prevents you from shooting yourself
    148                     return false;
    149 
    150                 this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.
    151                                         // The projectile is destroyed by its tick()-function (in the following tick).
    152 
    153                 Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is NULL
    154 
    155                 WorldEntity* entity = orxonox_cast<WorldEntity*>(this);
    156                 assert(entity); // The projectile must not be a WorldEntity.
    157 
    158                 // If visual effects after destruction cause problems, put this block below the effects code block
    159                 if (victim)
    160                 {
    161                     victim->customHit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
    162                     victim->startReloadCountdown();
    163                 }
    164 
    165                 // Visual effects for being hit, depending on whether the shield is hit or not
    166                 if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed.
    167                 {
    168                     // Damping and explosion effect is only played if the victim is no Pawn (see cast above)
    169                     // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health
    170                     if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f)))
    171                     {
    172                         {
    173                             ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    174                             effect->setPosition(entity->getPosition());
    175                             effect->setOrientation(entity->getOrientation());
    176                             effect->setDestroyAfterLife(true);
    177                             effect->setSource("Orxonox/explosion3");
    178                             effect->setLifetime(2.0f);
    179                         }
    180                         // Second effect with same condition
    181                         {
    182                             ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    183                             effect->setPosition(entity->getPosition());
    184                             effect->setOrientation(entity->getOrientation());
    185                             effect->setDestroyAfterLife(true);
    186                             effect->setSource("Orxonox/smoke4");
    187                             effect->setLifetime(3.0f);
    188                         }
    189                     }
    190 
    191                     // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead
    192                     if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f)
    193                     {
    194                         ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    195                         effect->setDestroyAfterLife(true);
    196                         effect->setSource("Orxonox/Shield");
    197                         effect->setLifetime(0.5f);
    198                         victim->attach(effect);
    199                     }
    200                 }
    201                 return true;
    202             }
    203             return false;
    204         }
    205143
    206144    /**
  • code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.h

    r9995 r10011  
    119119
    120120        protected:
    121             bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    122             bool customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
     121            bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
    123122            void destroyCheck(void);
    124123
  • code/branches/modularships/src/modules/weapons/projectiles/Projectile.cc

    r9995 r10011  
    8888    }
    8989
    90     bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     90    bool Projectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    9191    {
    92         return this->processCollision(otherObject, contactPoint);
    93     }
    94 
    95     bool Projectile::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    96     {
    97         return this->customProcessCollision(otherObject, contactPoint, cs);
     92        return this->processCollision(otherObject, contactPoint, cs);
    9893    }
    9994
  • code/branches/modularships/src/modules/weapons/projectiles/Projectile.h

    r9995 r10011  
    6464
    6565            virtual void tick(float dt);
    66             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    67             virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     66            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
    6867
    6968        private:
  • code/branches/modularships/src/modules/weapons/projectiles/Rocket.cc

    r9995 r10011  
    191191    }
    192192
    193     bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    194     {
    195         return this->processCollision(otherObject, contactPoint);
    196     }
    197 
    198     bool Rocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    199     {
    200         return this->customProcessCollision(otherObject, contactPoint, cs);
     193    bool Rocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
     194    {
     195        return this->processCollision(otherObject, contactPoint, cs);
    201196    }
    202197
  • code/branches/modularships/src/modules/weapons/projectiles/Rocket.h

    r9995 r10011  
    6464            virtual void tick(float dt); //!< Defines which actions the Rocket has to take in each tick.
    6565
    66             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    67             virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     66            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
    6867            virtual void destroyObject(void);
    6968            void destructionEffect();
  • code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.cc

    r9995 r10011  
    172172    }
    173173
    174     bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    175     {
    176         return this->processCollision(otherObject, contactPoint);
    177     }
    178 
    179     bool SimpleRocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    180     {
    181         return this->customProcessCollision(otherObject, contactPoint, cs);
     174    bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
     175    {
     176        return this->processCollision(otherObject, contactPoint, cs);
    182177    }
    183178
  • code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.h

    r9995 r10011  
    6464            virtual void tick(float dt);
    6565
    66             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    67             virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     66            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
    6867
    6968            void disableFire(); //!< Method to disable the fire and stop all acceleration
Note: See TracChangeset for help on using the changeset viewer.