Split slipstream instant speed update for better rewind
This commit is contained in:
parent
2a4c5ad557
commit
d3db5d8808
@ -44,6 +44,7 @@
|
|||||||
*/
|
*/
|
||||||
SlipStream::SlipStream(AbstractKart* kart)
|
SlipStream::SlipStream(AbstractKart* kart)
|
||||||
{
|
{
|
||||||
|
m_speed_increase_ticks = m_speed_increase_duration = -1;
|
||||||
m_kart = kart;
|
m_kart = kart;
|
||||||
m_moving = NULL;
|
m_moving = NULL;
|
||||||
m_moving_fast = NULL;
|
m_moving_fast = NULL;
|
||||||
@ -215,7 +216,7 @@ void SlipStream::reset()
|
|||||||
m_slipstream_mode = SS_NONE;
|
m_slipstream_mode = SS_NONE;
|
||||||
m_slipstream_time = 0;
|
m_slipstream_time = 0;
|
||||||
m_bonus_time = 0;
|
m_bonus_time = 0;
|
||||||
|
m_speed_increase_ticks = m_speed_increase_duration = -1;
|
||||||
// Reset a potential max speed increase
|
// Reset a potential max speed increase
|
||||||
m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, 0, 0, 0, 0);
|
m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, 0, 0, 0, 0);
|
||||||
} // reset
|
} // reset
|
||||||
@ -827,28 +828,8 @@ void SlipStream::update(int ticks)
|
|||||||
|
|
||||||
m_slipstream_time = 0.0f;
|
m_slipstream_time = 0.0f;
|
||||||
m_bonus_active = true;
|
m_bonus_active = true;
|
||||||
float speed_increase = kp->getSlipstreamMaxSpeedIncrease();
|
m_speed_increase_duration = stk_config->time2Ticks(m_bonus_time);
|
||||||
float add_power = kp->getSlipstreamAddPower();
|
m_speed_increase_ticks = World::getWorld()->getTicksSinceStart();
|
||||||
int duration = stk_config->time2Ticks(m_bonus_time);
|
|
||||||
int fade_out = kp->getSlipstreamFadeOutTicks();
|
|
||||||
m_kart->instantSpeedIncrease(
|
|
||||||
MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase,
|
|
||||||
speed_increase, add_power, duration, fade_out);
|
|
||||||
|
|
||||||
if (RewindManager::get()->useLocalEvent())
|
|
||||||
{
|
|
||||||
AbstractKart* kart = m_kart;
|
|
||||||
RewindManager::get()->addRewindInfoEventFunction(new
|
|
||||||
RewindInfoEventFunction(
|
|
||||||
World::getWorld()->getTicksSinceStart(),
|
|
||||||
[](){},
|
|
||||||
[kart, speed_increase, add_power, duration, fade_out]()
|
|
||||||
{
|
|
||||||
kart->instantSpeedIncrease(
|
|
||||||
MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase,
|
|
||||||
speed_increase, add_power, duration, fade_out);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_sstreaming)
|
if(!is_sstreaming)
|
||||||
@ -913,3 +894,18 @@ void SlipStream::update(int ticks)
|
|||||||
#endif
|
#endif
|
||||||
m_slipstream_mode = SS_COLLECT;
|
m_slipstream_mode = SS_COLLECT;
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void SlipStream::updateSpeedIncrease()
|
||||||
|
{
|
||||||
|
if (m_speed_increase_ticks == World::getWorld()->getTicksSinceStart())
|
||||||
|
{
|
||||||
|
const KartProperties* kp = m_kart->getKartProperties();
|
||||||
|
float speed_increase = kp->getSlipstreamMaxSpeedIncrease();
|
||||||
|
float add_power = kp->getSlipstreamAddPower();
|
||||||
|
int fade_out = kp->getSlipstreamFadeOutTicks();
|
||||||
|
m_kart->instantSpeedIncrease(
|
||||||
|
MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase,
|
||||||
|
speed_increase, add_power, m_speed_increase_duration, fade_out);
|
||||||
|
}
|
||||||
|
} // updateSpeedIncrease
|
||||||
|
@ -94,7 +94,8 @@ private:
|
|||||||
|
|
||||||
int m_current_target_id;
|
int m_current_target_id;
|
||||||
int m_previous_target_id;
|
int m_previous_target_id;
|
||||||
|
int m_speed_increase_ticks;
|
||||||
|
int m_speed_increase_duration;
|
||||||
|
|
||||||
/** Slipstream mode: either nothing happening, or the kart is collecting
|
/** Slipstream mode: either nothing happening, or the kart is collecting
|
||||||
* 'slipstream credits'. Credits can be accumulated while the bonus is used */
|
* 'slipstream credits'. Credits can be accumulated while the bonus is used */
|
||||||
@ -121,11 +122,11 @@ private:
|
|||||||
void updateBonusTexture();
|
void updateBonusTexture();
|
||||||
public:
|
public:
|
||||||
SlipStream (AbstractKart* kart);
|
SlipStream (AbstractKart* kart);
|
||||||
virtual ~SlipStream ();
|
~SlipStream ();
|
||||||
void reset();
|
void reset();
|
||||||
virtual void update(int ticks);
|
void update(int ticks);
|
||||||
bool isSlipstreamReady() const;
|
bool isSlipstreamReady() const;
|
||||||
|
void updateSpeedIncrease();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the quad in which slipstreaming is effective for
|
/** Returns the quad in which slipstreaming is effective for
|
||||||
* this kart. */
|
* this kart. */
|
||||||
|
@ -1463,6 +1463,7 @@ void Kart::update(int ticks)
|
|||||||
|
|
||||||
if (!RewindManager::get()->isRewinding())
|
if (!RewindManager::get()->isRewinding())
|
||||||
m_slipstream->update(ticks);
|
m_slipstream->update(ticks);
|
||||||
|
m_slipstream->updateSpeedIncrease();
|
||||||
|
|
||||||
// TODO: hiker said this probably will be moved to btKart or so when updating bullet engine.
|
// TODO: hiker said this probably will be moved to btKart or so when updating bullet engine.
|
||||||
// Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less
|
// Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less
|
||||||
|
Loading…
Reference in New Issue
Block a user