Move skidding particles to updateGraphics to avoid rewinding issue
This commit is contained in:
parent
b7856d4991
commit
8507a08c5c
@ -281,6 +281,15 @@ int MaxSpeed::getSpeedIncreaseTicksLeft(unsigned int category)
|
|||||||
return m_speed_increase[category].getTimeLeft();
|
return m_speed_increase[category].getTimeLeft();
|
||||||
} // getSpeedIncreaseTimeLeft
|
} // getSpeedIncreaseTimeLeft
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Returns if increased speed is active in the given category.
|
||||||
|
* \param category Which category to report on.
|
||||||
|
*/
|
||||||
|
int MaxSpeed::isSpeedIncreaseActive(unsigned int category)
|
||||||
|
{
|
||||||
|
return m_speed_increase[category].isActive();
|
||||||
|
} // isSpeedIncreaseActive
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Returns if decreased speed is active in the given category.
|
/** Returns if decreased speed is active in the given category.
|
||||||
* \param category Which category to report on.
|
* \param category Which category to report on.
|
||||||
|
@ -192,6 +192,7 @@ public:
|
|||||||
void setSlowdown(unsigned int category, float max_speed_fraction,
|
void setSlowdown(unsigned int category, float max_speed_fraction,
|
||||||
int fade_in_time, int duration=-1);
|
int fade_in_time, int duration=-1);
|
||||||
int getSpeedIncreaseTicksLeft(unsigned int category);
|
int getSpeedIncreaseTicksLeft(unsigned int category);
|
||||||
|
int isSpeedIncreaseActive(unsigned int category);
|
||||||
int isSpeedDecreaseActive(unsigned int category);
|
int isSpeedDecreaseActive(unsigned int category);
|
||||||
void update(int ticks);
|
void update(int ticks);
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -82,6 +82,7 @@ void Skidding::reset()
|
|||||||
m_graphical_remaining_jump_time = 0.0f;
|
m_graphical_remaining_jump_time = 0.0f;
|
||||||
m_smoothing_time = 0.0f;
|
m_smoothing_time = 0.0f;
|
||||||
m_smoothing_dt = -1.0f;
|
m_smoothing_dt = -1.0f;
|
||||||
|
m_skid_bonus_end_ticks = -1;
|
||||||
|
|
||||||
btVector3 rot(0, 0, 0);
|
btVector3 rot(0, 0, 0);
|
||||||
// Only access the vehicle if the kart is not a ghost
|
// Only access the vehicle if the kart is not a ghost
|
||||||
@ -255,6 +256,54 @@ float Skidding::getSteeringWhenSkidding(float steering) const
|
|||||||
*/
|
*/
|
||||||
float Skidding::updateGraphics(float dt)
|
float Skidding::updateGraphics(float dt)
|
||||||
{
|
{
|
||||||
|
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
||||||
|
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
||||||
|
m_kart->getKartGFX()->updateSkidLight(0);
|
||||||
|
|
||||||
|
float bonus_time, bonus_speed, bonus_force;
|
||||||
|
unsigned int level = getSkidBonus(&bonus_time, &bonus_speed, &bonus_force);
|
||||||
|
if (m_kart->m_max_speed
|
||||||
|
->isSpeedIncreaseActive(MaxSpeed::MS_INCREASE_SKIDDING) &&
|
||||||
|
m_skid_bonus_end_ticks > World::getWorld()->getTicksSinceStart())
|
||||||
|
{
|
||||||
|
level = 1;
|
||||||
|
}
|
||||||
|
else if (m_kart->m_max_speed
|
||||||
|
->isSpeedIncreaseActive(MaxSpeed::MS_INCREASE_RED_SKIDDING) &&
|
||||||
|
m_skid_bonus_end_ticks > World::getWorld()->getTicksSinceStart())
|
||||||
|
{
|
||||||
|
level = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level == 0 && m_graphical_remaining_jump_time <= 0.0f &&
|
||||||
|
m_skid_state != SKID_NONE)
|
||||||
|
{
|
||||||
|
// Show tiny sparks if bonus not yet reached
|
||||||
|
m_kart->getKartGFX()->setSkidLevel(level);
|
||||||
|
}
|
||||||
|
else if (level >= 1)
|
||||||
|
{
|
||||||
|
// If at least level 1 bonus is reached, show appropriate gfx
|
||||||
|
m_kart->getKartGFX()->setSkidLevel(level);
|
||||||
|
m_kart->getKartGFX()->updateSkidLight(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bonus_time > 0 || level == 1 || level == 2)
|
||||||
|
{
|
||||||
|
m_kart->getKartGFX()->setCreationRateRelative(KartGFX::KGFX_SKIDL,
|
||||||
|
1.0f);
|
||||||
|
m_kart->getKartGFX()->setCreationRateRelative(KartGFX::KGFX_SKIDR,
|
||||||
|
1.0f);
|
||||||
|
}
|
||||||
|
else if (m_skid_state == SKID_BREAK || m_skid_state == SKID_SHOW_GFX_LEFT
|
||||||
|
|| m_skid_state == SKID_SHOW_GFX_RIGHT)
|
||||||
|
{
|
||||||
|
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDL,
|
||||||
|
0.0f);
|
||||||
|
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDR,
|
||||||
|
0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_smoothing_dt >= 0.0f)
|
if (m_smoothing_dt >= 0.0f)
|
||||||
{
|
{
|
||||||
m_smoothing_dt += dt / m_smoothing_time;
|
m_smoothing_dt += dt / m_smoothing_time;
|
||||||
@ -321,8 +370,6 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK)
|
m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK)
|
||||||
{
|
{
|
||||||
m_skid_state = SKID_BREAK;
|
m_skid_state = SKID_BREAK;
|
||||||
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
|
||||||
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_skid_bonus_ready = false;
|
m_skid_bonus_ready = false;
|
||||||
@ -473,15 +520,9 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
unsigned int level = getSkidBonus(&bonus_time, &bonus_speed,
|
unsigned int level = getSkidBonus(&bonus_time, &bonus_speed,
|
||||||
&bonus_force);
|
&bonus_force);
|
||||||
|
|
||||||
// Show tiny sparks if bonus not yet reached
|
if (level >= 1 && !(level == 0 && m_remaining_jump_time <= 0.0f))
|
||||||
if (level == 0 && m_remaining_jump_time <= 0.0f)
|
|
||||||
m_kart->getKartGFX()->setSkidLevel(level);
|
|
||||||
// If at least level 1 bonus is reached, show appropriate gfx
|
|
||||||
else if (level>=1)
|
|
||||||
{
|
{
|
||||||
m_skid_bonus_ready = true;
|
m_skid_bonus_ready = true;
|
||||||
m_kart->getKartGFX()->setSkidLevel(level);
|
|
||||||
m_kart->getKartGFX()->updateSkidLight(level);
|
|
||||||
}
|
}
|
||||||
// If player stops skidding, trigger bonus, and change state to
|
// If player stops skidding, trigger bonus, and change state to
|
||||||
// SKID_SHOW_GFX_*
|
// SKID_SHOW_GFX_*
|
||||||
@ -500,10 +541,6 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
m_skid_time = stk_config->time2Ticks(t);
|
m_skid_time = stk_config->time2Ticks(t);
|
||||||
if(bonus_time>0)
|
if(bonus_time>0)
|
||||||
{
|
{
|
||||||
m_kart->getKartGFX()
|
|
||||||
->setCreationRateRelative(KartGFX::KGFX_SKIDL, 1.0f);
|
|
||||||
m_kart->getKartGFX()
|
|
||||||
->setCreationRateRelative(KartGFX::KGFX_SKIDR, 1.0f);
|
|
||||||
unsigned int bonus_cat = (level == 1) ? MaxSpeed::MS_INCREASE_SKIDDING :
|
unsigned int bonus_cat = (level == 1) ? MaxSpeed::MS_INCREASE_SKIDDING :
|
||||||
MaxSpeed::MS_INCREASE_RED_SKIDDING;
|
MaxSpeed::MS_INCREASE_RED_SKIDDING;
|
||||||
m_kart->m_max_speed->
|
m_kart->m_max_speed->
|
||||||
@ -513,6 +550,9 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
stk_config->time2Ticks(bonus_time),
|
stk_config->time2Ticks(bonus_time),
|
||||||
/*fade-out-time*/ stk_config->time2Ticks(1.0f));
|
/*fade-out-time*/ stk_config->time2Ticks(1.0f));
|
||||||
|
|
||||||
|
m_skid_bonus_end_ticks = World::getWorld()->getTicksSinceStart() +
|
||||||
|
stk_config->time2Ticks(1.0f);
|
||||||
|
|
||||||
if (m_kart->getController()->canGetAchievements())
|
if (m_kart->getController()->canGetAchievements())
|
||||||
{
|
{
|
||||||
PlayerManager::increaseAchievement(
|
PlayerManager::increaseAchievement(
|
||||||
@ -523,11 +563,9 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
AchievementsStatus::SKIDDING, 1);
|
AchievementsStatus::SKIDDING, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
m_kart->getKartGFX()
|
{
|
||||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
m_skid_bonus_end_ticks = -1;
|
||||||
m_kart->getKartGFX()
|
|
||||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -538,11 +576,6 @@ void Skidding::update(int ticks, bool is_on_ground,
|
|||||||
m_skid_time -= ticks;
|
m_skid_time -= ticks;
|
||||||
if (m_skid_time == 0)
|
if (m_skid_time == 0)
|
||||||
{
|
{
|
||||||
m_kart->getKartGFX()
|
|
||||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
|
||||||
m_kart->getKartGFX()
|
|
||||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
|
||||||
m_kart->getKartGFX()->updateSkidLight(0);
|
|
||||||
m_skid_state = SKID_NONE;
|
m_skid_state = SKID_NONE;
|
||||||
}
|
}
|
||||||
} // switch
|
} // switch
|
||||||
|
@ -75,6 +75,8 @@ private:
|
|||||||
|
|
||||||
float m_smoothing_dt;
|
float m_smoothing_dt;
|
||||||
|
|
||||||
|
int m_skid_bonus_end_ticks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** SKID_NONE: Kart is currently not skidding.
|
/** SKID_NONE: Kart is currently not skidding.
|
||||||
* SKID_ACCUMULATE_LEFT: Kart is skidding to the left and accumulating
|
* SKID_ACCUMULATE_LEFT: Kart is skidding to the left and accumulating
|
||||||
|
Loading…
Reference in New Issue
Block a user