Renamed EmergencyAnimation to KartAnimation, in order

to have a better name for this class that will also
support a 'canon'/teleporter animation.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11012 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-03-23 05:28:18 +00:00
parent 53b4b7d47c
commit 545e8a4892
7 changed files with 56 additions and 55 deletions

View File

@ -99,9 +99,9 @@ src/karts/controller/default_ai_controller.cpp
src/karts/controller/end_controller.cpp src/karts/controller/end_controller.cpp
src/karts/controller/new_ai_controller.cpp src/karts/controller/new_ai_controller.cpp
src/karts/controller/player_controller.cpp src/karts/controller/player_controller.cpp
src/karts/emergency_animation.cpp
src/karts/ghost_kart.cpp src/karts/ghost_kart.cpp
src/karts/kart.cpp src/karts/kart.cpp
src/karts/kart_animation.cpp
src/karts/kart_gfx.cpp src/karts/kart_gfx.cpp
src/karts/kart_model.cpp src/karts/kart_model.cpp
src/karts/kart_properties.cpp src/karts/kart_properties.cpp
@ -338,9 +338,9 @@ src/karts/controller/end_controller.hpp
src/karts/controller/kart_control.hpp src/karts/controller/kart_control.hpp
src/karts/controller/new_ai_controller.hpp src/karts/controller/new_ai_controller.hpp
src/karts/controller/player_controller.hpp src/karts/controller/player_controller.hpp
src/karts/emergency_animation.hpp
src/karts/ghost_kart.hpp src/karts/ghost_kart.hpp
src/karts/kart.hpp src/karts/kart.hpp
src/karts/kart_animation.hpp
src/karts/kart_gfx.hpp src/karts/kart_gfx.hpp
src/karts/kart_model.hpp src/karts/kart_model.hpp
src/karts/kart_properties.hpp src/karts/kart_properties.hpp

View File

@ -832,10 +832,6 @@
RelativePath="..\..\karts\abstract_kart.cpp" RelativePath="..\..\karts\abstract_kart.cpp"
> >
</File> </File>
<File
RelativePath="..\..\karts\emergency_animation.cpp"
>
</File>
<File <File
RelativePath="..\..\karts\ghost_kart.cpp" RelativePath="..\..\karts\ghost_kart.cpp"
> >
@ -844,6 +840,10 @@
RelativePath="..\..\karts\kart.cpp" RelativePath="..\..\karts\kart.cpp"
> >
</File> </File>
<File
RelativePath="..\..\karts\kart_animation.cpp"
>
</File>
<File <File
RelativePath="..\..\karts\kart_gfx.cpp" RelativePath="..\..\karts\kart_gfx.cpp"
> >
@ -1982,10 +1982,6 @@
RelativePath="..\..\karts\abstract_kart.hpp" RelativePath="..\..\karts\abstract_kart.hpp"
> >
</File> </File>
<File
RelativePath="..\..\karts\emergency_animation.hpp"
>
</File>
<File <File
RelativePath="..\..\karts\ghost_kart.hpp" RelativePath="..\..\karts\ghost_kart.hpp"
> >
@ -1994,6 +1990,10 @@
RelativePath="..\..\karts\kart.hpp" RelativePath="..\..\karts\kart.hpp"
> >
</File> </File>
<File
RelativePath="..\..\karts\kart_animation.hpp"
>
</File>
<File <File
RelativePath="..\..\karts\kart_gfx.hpp" RelativePath="..\..\karts\kart_gfx.hpp"
> >

View File

@ -45,6 +45,7 @@
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "karts/controller/end_controller.hpp" #include "karts/controller/end_controller.hpp"
#include "karts/kart_animation.hpp"
#include "karts/kart_model.hpp" #include "karts/kart_model.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "karts/max_speed.hpp" #include "karts/max_speed.hpp"
@ -81,7 +82,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
# pragma warning(1:4355) # pragma warning(1:4355)
#endif #endif
{ {
m_emergency_animation = new EmergencyAnimation(this); m_kart_animation = new KartAnimation(this);
m_max_speed = new MaxSpeed(this); m_max_speed = new MaxSpeed(this);
m_terrain_info = new TerrainInfo(); m_terrain_info = new TerrainInfo();
m_powerup = new Powerup(this); m_powerup = new Powerup(this);
@ -241,7 +242,7 @@ Kart::~Kart()
} }
delete m_skidding; delete m_skidding;
delete m_max_speed; delete m_max_speed;
delete m_emergency_animation; delete m_kart_animation;
delete m_terrain_info; delete m_terrain_info;
delete m_powerup; delete m_powerup;
@ -264,7 +265,7 @@ void Kart::reset()
stopFlying(); stopFlying();
} }
m_emergency_animation->reset(); m_kart_animation->reset();
m_max_speed->reset(); m_max_speed->reset();
m_powerup->reset(); m_powerup->reset();
@ -394,27 +395,27 @@ float Kart::getSpeedIncreaseTimeLeft(unsigned int category) const
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool Kart::playingRescueAnimation() const bool Kart::playingRescueAnimation() const
{ {
return m_emergency_animation->playingRescueAnimation(); return m_kart_animation->playingRescueAnimation();
} // playingRescueAnimation } // playingRescueAnimation
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool Kart::playingExplosionAnimation() const bool Kart::playingExplosionAnimation() const
{ {
return m_emergency_animation->playingExplosionAnimation(); return m_kart_animation->playingExplosionAnimation();
} // playingExplosionAnimation } // playingExplosionAnimation
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/** Returns the timer for the currently played animation. */ /** Returns the timer for the currently played animation. */
float Kart::getAnimationTimer() const float Kart::getAnimationTimer() const
{ {
return m_emergency_animation->getAnimationTimer(); return m_kart_animation->getAnimationTimer();
} // getAnimationTimer } // getAnimationTimer
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/** Returns true if an emergency animation is being played. */ /** Returns true if an emergency animation is being played. */
bool Kart::playingEmergencyAnimation() const bool Kart::playingEmergencyAnimation() const
{ {
return m_emergency_animation->playingEmergencyAnimation(); return m_kart_animation->playingAnimation();
} // playingEmergencyAnimation } // playingEmergencyAnimation
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -902,12 +903,12 @@ bool Kart::isNearGround() const
*/ */
bool Kart::isEliminated() const bool Kart::isEliminated() const
{ {
return m_emergency_animation->isEliminated(); return m_kart_animation->isEliminated();
} // isEliminated } // isEliminated
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void Kart::eliminate(bool remove) void Kart::eliminate(bool remove)
{ {
m_emergency_animation->eliminate(remove); m_kart_animation->eliminate(remove);
} // eliminate } // eliminate
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -917,7 +918,7 @@ void Kart::eliminate(bool remove)
*/ */
void Kart::handleExplosion(const Vec3& pos, bool direct_hit) void Kart::handleExplosion(const Vec3& pos, bool direct_hit)
{ {
m_emergency_animation->handleExplosion(pos, direct_hit); m_kart_animation->handleExplosion(pos, direct_hit);
} // handleExplosion } // handleExplosion
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -927,7 +928,7 @@ void Kart::handleExplosion(const Vec3& pos, bool direct_hit)
*/ */
void Kart::forceRescue(bool is_auto_rescue) void Kart::forceRescue(bool is_auto_rescue)
{ {
m_emergency_animation->forceRescue(is_auto_rescue); m_kart_animation->forceRescue(is_auto_rescue);
} // forceRescue } // forceRescue
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -937,9 +938,9 @@ void Kart::forceRescue(bool is_auto_rescue)
*/ */
void Kart::update(float dt) void Kart::update(float dt)
{ {
if (m_emergency_animation->isEliminated()) if (m_kart_animation->isEliminated())
{ {
m_emergency_animation->update(dt); m_kart_animation->update(dt);
return; return;
} }
@ -1034,7 +1035,7 @@ void Kart::update(float dt)
m_wheel_rotation += m_speed*dt / m_kart_properties->getWheelRadius(); m_wheel_rotation += m_speed*dt / m_kart_properties->getWheelRadius();
m_wheel_rotation=fmodf(m_wheel_rotation, 2*M_PI); m_wheel_rotation=fmodf(m_wheel_rotation, 2*M_PI);
m_emergency_animation->update(dt); m_kart_animation->update(dt);
m_attachment->update(dt); m_attachment->update(dt);
@ -1286,7 +1287,7 @@ void Kart::handleMaterialGFX()
// something with the wheels, and the material has not the // something with the wheels, and the material has not the
// below surface property set. // below surface property set.
if (material && isOnGround() && !material->isBelowSurface() && if (material && isOnGround() && !material->isBelowSurface() &&
!m_emergency_animation->playingRescueAnimation()&& !m_kart_animation->playingRescueAnimation()&&
UserConfigParams::m_graphical_effects) UserConfigParams::m_graphical_effects)
{ {
@ -1343,7 +1344,7 @@ void Kart::handleMaterialGFX()
const ParticleKind *pk = const ParticleKind *pk =
surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE); surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE);
if(!pk || m_flying || m_emergency_animation->playingRescueAnimation()) if(!pk || m_flying || m_kart_animation->playingRescueAnimation())
return; return;
// Now the kart is under a surface, and there is a surface effect // Now the kart is under a surface, and there is a surface effect
@ -1361,7 +1362,7 @@ void Kart::handleMaterialGFX()
// Play special sound effects for this terrain // Play special sound effects for this terrain
// ------------------------------------------- // -------------------------------------------
const std::string s = surface_material->getSFXName(); const std::string s = surface_material->getSFXName();
if (s != "" && !m_emergency_animation->playingRescueAnimation()&& if (s != "" && !m_kart_animation->playingRescueAnimation()&&
(m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED)) (m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED))
{ {
if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound); if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);

View File

@ -30,7 +30,6 @@
#include "items/powerup.hpp" #include "items/powerup.hpp"
#include "karts/abstract_kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/emergency_animation.hpp"
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "tracks/terrain_info.hpp" #include "tracks/terrain_info.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
@ -41,8 +40,8 @@ class btUprightConstraint;
class Attachment; class Attachment;
class Camera; class Camera;
class Controller; class Controller;
class EmergencyAnimation;
class Item; class Item;
class KartAnimation;
class KartGFX; class KartGFX;
class MaxSpeed; class MaxSpeed;
class ParticleEmitter; class ParticleEmitter;
@ -67,8 +66,8 @@ class Kart : public AbstractKart
{ {
friend class Skidding; friend class Skidding;
protected: protected:
/** Handles all emergency animations: rescue and explosion. */ /** Handles all kart animations, such as rescue and explosion. */
EmergencyAnimation *m_emergency_animation; KartAnimation *m_kart_animation;
private: private:
/** Handles speed increase and capping due to powerup, terrain, ... */ /** Handles speed increase and capping due to powerup, terrain, ... */

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "karts/emergency_animation.hpp" #include "karts/kart_animation.hpp"
#include "graphics/camera.hpp" #include "graphics/camera.hpp"
#include "graphics/referee.hpp" #include "graphics/referee.hpp"
@ -33,7 +33,7 @@
* and initialised the timer. * and initialised the timer.
* \param kart Pointer to the kart which is animated. * \param kart Pointer to the kart which is animated.
*/ */
EmergencyAnimation::EmergencyAnimation(Kart *kart) KartAnimation::KartAnimation(Kart *kart)
{ {
m_stars_effect = NULL; m_stars_effect = NULL;
m_referee = NULL; m_referee = NULL;
@ -45,19 +45,19 @@ EmergencyAnimation::EmergencyAnimation(Kart *kart)
// rescue is not set. // rescue is not set.
m_kart_mode = EA_NONE; m_kart_mode = EA_NONE;
m_eliminated = false; m_eliminated = false;
}; // EmergencyAnimation }; // KartAnimation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
EmergencyAnimation::~EmergencyAnimation() KartAnimation::~KartAnimation()
{ {
if(m_stars_effect) if(m_stars_effect)
delete m_stars_effect; delete m_stars_effect;
} // ~EmergencyAnimation } // ~KartAnimation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Resets all data at the beginning of a race. /** Resets all data at the beginning of a race.
*/ */
void EmergencyAnimation::reset() void KartAnimation::reset()
{ {
// Create the stars effect in the first reset // Create the stars effect in the first reset
@ -74,7 +74,7 @@ void EmergencyAnimation::reset()
// If the kart was eliminated or rescued, the body was removed from the // If the kart was eliminated or rescued, the body was removed from the
// physics world. Add it again. // physics world. Add it again.
if(m_eliminated || playingEmergencyAnimation()) if(m_eliminated || playingAnimation())
{ {
World::getWorld()->getPhysics()->addKart(m_kart); World::getWorld()->getPhysics()->addKart(m_kart);
} }
@ -92,9 +92,9 @@ void EmergencyAnimation::reset()
/** Eliminates a kart from the race. It removes the kart from the physics /** Eliminates a kart from the race. It removes the kart from the physics
* world, and makes the scene node invisible. * world, and makes the scene node invisible.
*/ */
void EmergencyAnimation::eliminate(bool remove) void KartAnimation::eliminate(bool remove)
{ {
if (!playingEmergencyAnimation() && remove) if (!playingAnimation() && remove)
{ {
World::getWorld()->getPhysics()->removeKart(m_kart); World::getWorld()->getPhysics()->removeKart(m_kart);
} }
@ -119,9 +119,9 @@ void EmergencyAnimation::eliminate(bool remove)
* and saves the current pitch and roll (for the rescue animation). It * and saves the current pitch and roll (for the rescue animation). It
* also removes the kart from the physics world. * also removes the kart from the physics world.
*/ */
void EmergencyAnimation::forceRescue(bool is_auto_rescue) void KartAnimation::forceRescue(bool is_auto_rescue)
{ {
if(playingEmergencyAnimation()) return; if(playingAnimation()) return;
assert(!m_referee); assert(!m_referee);
m_referee = new Referee(*m_kart); m_referee = new Referee(*m_kart);
@ -155,10 +155,10 @@ void EmergencyAnimation::forceRescue(bool is_auto_rescue)
* \param pos The coordinates of the explosion. * \param pos The coordinates of the explosion.
* \param direct_hig True if the kart was hit directly --> maximal impact. * \param direct_hig True if the kart was hit directly --> maximal impact.
*/ */
void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit) void KartAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
{ {
// Avoid doing another explosion while a kart is thrown around in the air. // Avoid doing another explosion while a kart is thrown around in the air.
if(playingEmergencyAnimation()) if(playingAnimation())
return; return;
if(m_kart->isInvulnerable()) if(m_kart->isInvulnerable())
@ -214,7 +214,7 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
* \param dt Time step size. * \param dt Time step size.
* \return True if the explosion is still shown, false if it has finished. * \return True if the explosion is still shown, false if it has finished.
*/ */
void EmergencyAnimation::update(float dt) void KartAnimation::update(float dt)
{ {
if ( UserConfigParams::m_graphical_effects ) if ( UserConfigParams::m_graphical_effects )
{ {
@ -222,7 +222,7 @@ void EmergencyAnimation::update(float dt)
m_stars_effect->update(dt); m_stars_effect->update(dt);
} }
if(!playingEmergencyAnimation()) return; if(!playingAnimation()) return;
// See if the timer expires, if so return the kart to normal game play // See if the timer expires, if so return the kart to normal game play
m_timer -= dt; m_timer -= dt;

View File

@ -38,7 +38,7 @@ class Stars;
* explosion happens. * explosion happens.
* \ingroup karts * \ingroup karts
*/ */
class EmergencyAnimation: public NoCopy class KartAnimation: public NoCopy
{ {
protected: protected:
/** The coordinates where the kart was hit originally. */ /** The coordinates where the kart was hit originally. */
@ -79,16 +79,16 @@ protected:
enum {EA_NONE, EA_RESCUE, EA_EXPLOSION} enum {EA_NONE, EA_RESCUE, EA_EXPLOSION}
m_kart_mode; m_kart_mode;
public: public:
EmergencyAnimation(Kart *kart); KartAnimation(Kart *kart);
virtual ~EmergencyAnimation(); virtual ~KartAnimation();
void reset(); void reset();
virtual void handleExplosion(const Vec3& pos, bool direct_hit); virtual void handleExplosion(const Vec3& pos, bool direct_hit);
virtual void forceRescue(bool is_auto_rescue=false); virtual void forceRescue(bool is_auto_rescue=false);
void update(float dt); void update(float dt);
void eliminate (bool remove); void eliminate (bool remove);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if an emergency animation is being played. */ /** Returns true if an animation is being played. */
bool playingEmergencyAnimation() const {return m_kart_mode!=EA_NONE; } bool playingAnimation() const {return m_kart_mode!=EA_NONE; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns if a rescue animation is being shown. */ /** Returns if a rescue animation is being shown. */
bool playingRescueAnimation() const {return m_kart_mode==EA_RESCUE; } bool playingRescueAnimation() const {return m_kart_mode==EA_RESCUE; }
@ -105,5 +105,5 @@ public:
/** Returns a pointer to the stars effect. */ /** Returns a pointer to the stars effect. */
const Stars *getStarEffect () const {return m_stars_effect; } const Stars *getStarEffect () const {return m_stars_effect; }
}; // EmergencyAnimation }; // KartAnimation
#endif #endif

View File

@ -18,6 +18,7 @@
#include "karts/kart_with_stats.hpp" #include "karts/kart_with_stats.hpp"
#include "karts/kart_animation.hpp"
#include "items/item.hpp" #include "items/item.hpp"
KartWithStats::KartWithStats(const std::string& ident, KartWithStats::KartWithStats(const std::string& ident,
@ -75,10 +76,10 @@ void KartWithStats::handleExplosion(const Vec3& pos, bool direct_hit)
Kart::handleExplosion(pos, direct_hit); Kart::handleExplosion(pos, direct_hit);
// If a kart is too far away from an explosion to be affected, its timer // If a kart is too far away from an explosion to be affected, its timer
// will be 0, and this should then not be counted as an explosion. // will be 0, and this should then not be counted as an explosion.
if(is_new_explosion && m_emergency_animation->getAnimationTimer()>0) if(is_new_explosion && m_kart_animation->getAnimationTimer()>0)
{ {
m_explosion_count ++; m_explosion_count ++;
m_explosion_time += m_emergency_animation->getAnimationTimer(); m_explosion_time += m_kart_animation->getAnimationTimer();
} }
} // handleExplosion } // handleExplosion
@ -97,7 +98,7 @@ void KartWithStats::forceRescue(bool is_auto_rescue)
if(is_new_rescue) if(is_new_rescue)
{ {
m_rescue_count++; m_rescue_count++;
m_rescue_time += m_emergency_animation->getAnimationTimer(); m_rescue_time += m_kart_animation->getAnimationTimer();
} }
} // forceRescue } // forceRescue