Remove kart animation when goal phase

This will make sure all karts will be back to own goal at the same
time without animation playing
This commit is contained in:
Benau 2019-03-25 16:19:29 +08:00
parent 16507510a3
commit 3a90e828a4
13 changed files with 51 additions and 21 deletions

@ -110,7 +110,7 @@ void ArenaAI::update(int ticks)
m_kart->isOnGround() )
{
m_ticks_since_off_road = 0;
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
AIBaseController::update(ticks);
return;
}

@ -246,7 +246,7 @@ void EndController::handleRescue(const float DELTA)
m_time_since_stuck += DELTA;
if(m_time_since_stuck > 2.0f)
{
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
m_time_since_stuck=0.0f;
} // m_time_since_stuck > 2.0f
}

@ -359,7 +359,7 @@ void PlayerController::update(int ticks)
// starting any other animation).
if ( m_controls->getRescue() && !m_kart->getKartAnimation() )
{
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
m_controls->setRescue(false);
}
} // update

@ -299,7 +299,7 @@ void SkiddingAI::update(int ticks)
if (m_enabled_network_ai)
m_controls->setRescue(true);
else
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
AIBaseLapController::update(ticks);
return;
}
@ -2158,7 +2158,7 @@ void SkiddingAI::handleRescue(const float dt)
if (m_enabled_network_ai)
m_controls->setRescue(true);
else
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
m_time_since_stuck=0.0f;
} // m_time_since_stuck > 2.0f
}

@ -299,7 +299,7 @@ void SkiddingAI::update(int ticks)
// If the kart needs to be rescued, do it now (and nothing else)
if(isStuck() && !m_kart->getKartAnimation())
{
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
AIBaseLapController::update(ticks);
return;
}
@ -1582,7 +1582,7 @@ void SkiddingAI::handleRescue(const float dt)
m_time_since_stuck += dt;
if(m_time_since_stuck > 2.0f)
{
new RescueAnimation(m_kart);
RescueAnimation::create(m_kart);
m_time_since_stuck=0.0f;
} // m_time_since_stuck > 2.0f
}

@ -42,7 +42,10 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart,
const Vec3 &pos,
bool direct_hit)
{
if(kart->isInvulnerable()) return NULL;
// When goal phase is happening karts is made stationary, so no animation
// will be created
if (kart->isInvulnerable() || World::getWorld()->isGoalPhase())
return NULL;
float r = kart->getKartProperties()->getExplosionRadius();
@ -72,8 +75,9 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart,
* Otherwise, NULL is returned. */
ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart)
{
if(kart->isInvulnerable()) return NULL;
else if(kart->isShielded())
if (kart->isInvulnerable() || World::getWorld()->isGoalPhase())
return NULL;
else if (kart->isShielded())
{
kart->decreaseShieldTime();
return NULL;

@ -70,10 +70,9 @@ friend class KartRewinder;
const btTransform& reset_trans);
// ------------------------------------------------------------------------
ExplosionAnimation(AbstractKart* kart, BareNetworkString* buffer);
public:
// ------------------------------------------------------------------------
ExplosionAnimation(AbstractKart* kart, bool direct_hit);
public:
// ------------------------------------------------------------------------
static ExplosionAnimation *create(AbstractKart* kart, const Vec3 &pos,
bool direct_hit);

@ -1626,7 +1626,7 @@ void Kart::update(int ticks)
!has_animation_before && fabs(roll) > 60 * DEGREE_TO_RAD &&
fabs(getSpeed()) < 3.0f)
{
new RescueAnimation(this, /*is_auto_rescue*/true);
RescueAnimation::create(this, /*is_auto_rescue*/true);
m_last_factor_engine_sound = 0.0f;
}
}
@ -1727,7 +1727,7 @@ void Kart::update(int ticks)
if((min->getY() - getXYZ().getY() > 17 || dist_to_sector > 25) && !m_flying &&
!has_animation_before)
{
new RescueAnimation(this);
RescueAnimation::create(this);
m_last_factor_engine_sound = 0.0f;
}
}
@ -1735,7 +1735,7 @@ void Kart::update(int ticks)
{
if (!has_animation_before && material->isDriveReset() && isOnGround())
{
new RescueAnimation(this);
RescueAnimation::create(this);
m_last_factor_engine_sound = 0.0f;
}
else if(material->isZipper() && isOnGround())
@ -2452,7 +2452,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
#endif
if (m->getCollisionReaction() == Material::RESCUE)
{
new RescueAnimation(this);
RescueAnimation::create(this);
m_last_factor_engine_sound = 0.0f;
}
else if (m->getCollisionReaction() == Material::PUSH_BACK)

@ -33,6 +33,17 @@
#include <algorithm>
#include <cmath>
RescueAnimation* RescueAnimation::create(AbstractKart* kart,
bool is_auto_rescue)
{
// When goal phase is happening karts is made stationary, so no animation
// will be created
if (World::getWorld()->isGoalPhase())
return NULL;
return new RescueAnimation(kart, is_auto_rescue);
} // create
//-----------------------------------------------------------------------------
/** The constructor stores a pointer to the kart this object is animating,
* and initialised the timer.
* \param kart Pointer to the kart which is animated.

@ -51,13 +51,17 @@ friend class KartRewinder;
// ------------------------------------------------------------------------
RescueAnimation(AbstractKart* kart, BareNetworkString* b);
// ------------------------------------------------------------------------
RescueAnimation(AbstractKart* kart, bool is_auto_rescue);
// ------------------------------------------------------------------------
void restoreData(BareNetworkString* b);
// ------------------------------------------------------------------------
void init(const btTransform& rescue_transform, float velocity);
public:
RescueAnimation(AbstractKart* kart,
bool is_auto_rescue = false);
virtual ~RescueAnimation();
// ------------------------------------------------------------------------
static RescueAnimation* create(AbstractKart* kart,
bool is_auto_rescue = false);
// ------------------------------------------------------------------------
virtual ~RescueAnimation();
// ------------------------------------------------------------------------
virtual void update(int ticks);
// ------------------------------------------------------------------------

@ -23,6 +23,7 @@
#include "config/user_config.hpp"
#include "io/file_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "karts/abstract_kart_animation.hpp"
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
#include "karts/controller/local_player_controller.hpp"
@ -222,6 +223,12 @@ void SoccerWorld::update(int ticks)
auto& kart = m_karts[i];
if (kart->isEliminated())
continue;
if (kart->getKartAnimation())
{
AbstractKartAnimation* ka = kart->getKartAnimation();
kart->setKartAnimation(NULL);
delete ka;
}
kart->getBody()->setLinearVelocity(Vec3(0.0f));
kart->getBody()->setAngularVelocity(Vec3(0.0f));
kart->getBody()->proceedToTransform(m_goal_transforms[i]);

@ -234,7 +234,7 @@ void Physics::update(int ticks)
}
if (obj->isCrashReset())
{
new RescueAnimation(kart);
RescueAnimation::create(kart);
}
else if (obj->isExplodeKartObject())
{
@ -271,7 +271,7 @@ void Physics::update(int ticks)
if(anim->isCrashReset())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
new RescueAnimation(kart);
RescueAnimation::create(kart);
}
else if (anim->isExplodeKartObject())
{

@ -130,6 +130,11 @@ void CheckCannon::changeDebugColor(bool is_active)
void CheckCannon::update(float dt)
{
World* world = World::getWorld();
// When goal phase is happening karts is made stationary, so no animation
// will be created
if (world->isGoalPhase())
return;
for (unsigned int i = 0; i < world->getNumKarts(); i++)
{
AbstractKart* kart = world->getKart(i);