Split plunger drawing in race GUI to update graphics
Avoid overwriting the values by rewind
This commit is contained in:
parent
759a1d5a33
commit
97e5e63e7c
@ -261,6 +261,8 @@ public:
|
||||
/** Returns true if the kart has a plunger attached to its face. */
|
||||
virtual int getBlockedByPlungerTicks() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual float getGraphicalViewBlockedByPlunger() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
* the difficulty, see KartPorperties getPlungerInFaceTime. */
|
||||
virtual void blockViewWithPlunger() = 0;
|
||||
|
@ -185,7 +185,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_terrain_sound = NULL;
|
||||
m_last_sound_material = NULL;
|
||||
m_previous_terrain_sound = NULL;
|
||||
|
||||
m_graphical_view_blocked_by_plunger = 0.0f;
|
||||
} // Kart
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -370,6 +370,7 @@ void Kart::reset()
|
||||
m_current_lean = 0.0f;
|
||||
m_falling_time = 0.0f;
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_graphical_view_blocked_by_plunger = 0.0f;
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
m_is_jumping = false;
|
||||
m_flying = false;
|
||||
@ -590,8 +591,15 @@ void Kart::blockViewWithPlunger()
|
||||
{
|
||||
// Avoid that a plunger extends the plunger time
|
||||
if(m_view_blocked_by_plunger<=0 && !isShielded())
|
||||
{
|
||||
m_view_blocked_by_plunger =
|
||||
stk_config->time2Ticks(m_kart_properties->getPlungerInFaceTime());
|
||||
if (m_graphical_view_blocked_by_plunger == 0.0f)
|
||||
{
|
||||
m_graphical_view_blocked_by_plunger =
|
||||
m_kart_properties->getPlungerInFaceTime();
|
||||
}
|
||||
}
|
||||
if(isShielded())
|
||||
{
|
||||
decreaseShieldTime();
|
||||
@ -1434,7 +1442,10 @@ void Kart::update(int ticks)
|
||||
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= ticks;
|
||||
//unblock the view if kart just became shielded
|
||||
if(isShielded())
|
||||
{
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_graphical_view_blocked_by_plunger = 0.0f;
|
||||
}
|
||||
// Decrease remaining invulnerability time
|
||||
if(m_invulnerable_ticks>0)
|
||||
{
|
||||
@ -1674,6 +1685,7 @@ void Kart::update(int ticks)
|
||||
if (emergency)
|
||||
{
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_graphical_view_blocked_by_plunger = 0.0f;
|
||||
if (m_flying)
|
||||
{
|
||||
stopFlying();
|
||||
@ -3050,6 +3062,10 @@ void Kart::updateGraphics(float dt)
|
||||
unsetSquash();
|
||||
}
|
||||
} // if squashed
|
||||
if (m_graphical_view_blocked_by_plunger > 0.0f)
|
||||
m_graphical_view_blocked_by_plunger -= dt;
|
||||
if (m_graphical_view_blocked_by_plunger < 0.0f)
|
||||
m_graphical_view_blocked_by_plunger = 0.0f;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < EMITTER_COUNT; i++)
|
||||
|
@ -223,6 +223,9 @@ protected:
|
||||
/** When a kart has its view blocked by the plunger, this variable will be
|
||||
* > 0 the number it contains is the time left before removing plunger. */
|
||||
int16_t m_view_blocked_by_plunger;
|
||||
|
||||
float m_graphical_view_blocked_by_plunger;
|
||||
|
||||
/** The current speed (i.e. length of velocity vector) of this kart. */
|
||||
float m_speed;
|
||||
|
||||
@ -394,6 +397,9 @@ public:
|
||||
virtual int getBlockedByPlungerTicks() const OVERRIDE
|
||||
{ return m_view_blocked_by_plunger; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual float getGraphicalViewBlockedByPlunger() const OVERRIDE
|
||||
{ return m_graphical_view_blocked_by_plunger; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
* the difficulty, see KartPorperties getPlungerInFaceTime. */
|
||||
virtual void blockViewWithPlunger() OVERRIDE;
|
||||
|
@ -987,7 +987,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
|
||||
}
|
||||
|
||||
//Plunger
|
||||
if (kart->getBlockedByPlungerTicks()>0)
|
||||
if (kart->getGraphicalViewBlockedByPlunger() > 0.0f)
|
||||
{
|
||||
video::ITexture *icon_plunger =
|
||||
powerup_manager->getIcon(PowerupManager::POWERUP_PLUNGER)->getTexture();
|
||||
@ -1031,7 +1031,7 @@ void RaceGUIBase::drawPlungerInFace(const Camera *camera, float dt)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
const AbstractKart *kart = camera->getKart();
|
||||
if (kart->getBlockedByPlungerTicks()<=0)
|
||||
if (kart->getGraphicalViewBlockedByPlunger() <= 0.0f)
|
||||
{
|
||||
m_plunger_state = PLUNGER_STATE_INIT;
|
||||
return;
|
||||
@ -1056,7 +1056,7 @@ void RaceGUIBase::drawPlungerInFace(const Camera *camera, float dt)
|
||||
if(m_plunger_move_time < dt && m_plunger_state!=PLUNGER_STATE_FAST)
|
||||
{
|
||||
const float fast_time = 0.3f;
|
||||
if(kart->getBlockedByPlungerTicks()<stk_config->time2Ticks(fast_time))
|
||||
if (kart->getGraphicalViewBlockedByPlunger() < fast_time)
|
||||
{
|
||||
// First time we reach faste state: select random target point
|
||||
// at top of screen and set speed accordingly
|
||||
|
Loading…
Reference in New Issue
Block a user