Removed m_confirmed, renamed m_disappear_counter to m_used_up_counter.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
#include "tracks/drive_node.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
@@ -47,11 +46,11 @@ void ItemState::setDisappearCounter()
|
||||
switch (m_type)
|
||||
{
|
||||
case ITEM_BUBBLEGUM:
|
||||
m_disappear_counter = stk_config->m_bubblegum_counter; break;
|
||||
m_used_up_counter = stk_config->m_bubblegum_counter; break;
|
||||
case ITEM_EASTER_EGG:
|
||||
m_disappear_counter = -1; break;
|
||||
m_used_up_counter = -1; break;
|
||||
default:
|
||||
m_disappear_counter = -1;
|
||||
m_used_up_counter = -1;
|
||||
} // switch
|
||||
} // setDisappearCounter
|
||||
|
||||
@@ -62,18 +61,18 @@ void ItemState::setDisappearCounter()
|
||||
void ItemState::update(int ticks)
|
||||
{
|
||||
if (m_deactive_ticks > 0) m_deactive_ticks -= ticks;
|
||||
if (m_collected)
|
||||
if (m_ticks_till_return>0)
|
||||
{
|
||||
m_ticks_till_return -= ticks;
|
||||
if (m_ticks_till_return<=0) m_collected = false;
|
||||
} // if collected
|
||||
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called when the item is collected.
|
||||
*/
|
||||
void ItemState::collected(float t, const AbstractKart *kart)
|
||||
{
|
||||
m_collected = true;
|
||||
if (m_type == ITEM_EASTER_EGG)
|
||||
{
|
||||
m_ticks_till_return = stk_config->time2Ticks(99999);
|
||||
@@ -81,9 +80,9 @@ void ItemState::collected(float t, const AbstractKart *kart)
|
||||
assert(world);
|
||||
world->collectedEasterEgg(kart);
|
||||
}
|
||||
else if (m_type == ITEM_BUBBLEGUM && m_disappear_counter > 0)
|
||||
else if (m_used_up_counter > 0)
|
||||
{
|
||||
m_disappear_counter--;
|
||||
m_used_up_counter--;
|
||||
// Deactivates the item for a certain amount of time. It is used to
|
||||
// prevent bubble gum from hitting a kart over and over again (in each
|
||||
// frame) by giving it time to drive away.
|
||||
@@ -94,8 +93,6 @@ void ItemState::collected(float t, const AbstractKart *kart)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Note if the time is negative, in update the m_collected flag will
|
||||
// be automatically set to false again.
|
||||
m_ticks_till_return = stk_config->time2Ticks(t);
|
||||
}
|
||||
|
||||
@@ -353,8 +350,7 @@ void Item::update(int ticks)
|
||||
m_node->setScale(core::vector3df(1, 1, 1)*(1 - t));
|
||||
}
|
||||
if(isAvailable())
|
||||
{ // not m_collected
|
||||
|
||||
{
|
||||
if(!m_rotate || m_node == NULL) return;
|
||||
// have it rotate
|
||||
if (!RewindManager::get()->isRewinding())
|
||||
@@ -373,7 +369,7 @@ void Item::update(int ticks)
|
||||
hpr.setHPR(r);
|
||||
m_node->setRotation(hpr.toIrrHPR());
|
||||
return;
|
||||
} // not m_collected
|
||||
} // if item is available
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -99,10 +99,9 @@ private:
|
||||
* It is ITEM_NONE if the item is not switched. */
|
||||
ItemType m_original_type;
|
||||
|
||||
/** True if item was collected & is not displayed. */
|
||||
bool m_collected;
|
||||
|
||||
/** Time till a collected item reappears. */
|
||||
/** Time till a collected item reappears. When this value is <=0 this
|
||||
* means that the item is availabe to be collected. When the value is
|
||||
* > 0 it means that the item is not available. */
|
||||
int m_ticks_till_return;
|
||||
|
||||
/** Index in item_manager field. */
|
||||
@@ -115,8 +114,9 @@ private:
|
||||
/** Counts how often an item is used before it disappears. Used for
|
||||
* bubble gum to make them disappear after a while. A value >0
|
||||
* indicates that the item still exists, =0 that the item can be
|
||||
* deleted, and <0 that the item will never be deleted. */
|
||||
int m_disappear_counter;
|
||||
* deleted, and <0 that the item will never be deleted, i.e. it
|
||||
* will always reappear after a while. */
|
||||
int m_used_up_counter;
|
||||
|
||||
public:
|
||||
/** Constructor. */
|
||||
@@ -134,7 +134,6 @@ public:
|
||||
{
|
||||
m_deactive_ticks = 0;
|
||||
m_ticks_till_return = 0;
|
||||
m_collected = false;
|
||||
setDisappearCounter();
|
||||
// If the item was switched:
|
||||
if (m_original_type != ITEM_NONE)
|
||||
@@ -155,7 +154,6 @@ public:
|
||||
m_deactive_ticks = 0;
|
||||
m_ticks_till_return = 0;
|
||||
m_item_id = -1;
|
||||
m_collected = false;
|
||||
setDisappearCounter();
|
||||
} // initItem
|
||||
|
||||
@@ -212,9 +210,6 @@ public:
|
||||
/** Returns true if this item is currently collected. */
|
||||
bool isAvailable() const { return m_ticks_till_return <= 0; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Useless function ;) But it makes some conditionals easier to read. */
|
||||
bool isUnavailable() const { return m_collected; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the type of this item. */
|
||||
ItemType getType() const { return m_type; }
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -227,11 +222,11 @@ public:
|
||||
unsigned int getItemId() const { return m_item_id; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this item is used up and can be removed. */
|
||||
bool isUsedUp() const { return m_disappear_counter == 0; }
|
||||
bool isUsedUp() const { return m_used_up_counter == 0; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this item can be used up, and therefore needs to
|
||||
* be removed when the game is reset. */
|
||||
bool canBeUsedUp() const { return m_disappear_counter>-1; }
|
||||
bool canBeUsedUp() const { return m_used_up_counter>-1; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of ticks during which the item is deactivated (i.e.
|
||||
* it was collected). */
|
||||
|
||||
Reference in New Issue
Block a user