SuperTuxKart
|
Contains the state information of an item, i.e. More...
#include <item.hpp>
Public Types | |
enum | ItemType { ITEM_FIRST , ITEM_BONUS_BOX = ITEM_FIRST , ITEM_BANANA , ITEM_NITRO_BIG , ITEM_NITRO_SMALL , ITEM_BUBBLEGUM , ITEM_BUBBLEGUM_NOLOK , ITEM_EASTER_EGG , ITEM_LAST = ITEM_EASTER_EGG , ITEM_COUNT , ITEM_NONE } |
The list of all items. More... | |
Public Member Functions | |
ItemState (ItemType type, const AbstractKart *owner=NULL, int id=-1) | |
Constructor. | |
ItemState (const BareNetworkString &buffer) | |
Constructor to restore item state at current ticks in client for live join. | |
void | initItem (ItemType type, const Vec3 &xyz, const Vec3 &normal) |
Initialises an item. | |
void | update (int ticks) |
Update the state of the item, called once per physics frame. | |
void | setDisappearCounter () |
Sets the disappear counter depending on type. | |
virtual void | collected (const AbstractKart *kart) |
Called when the item is collected. | |
virtual void | updateGraphics (float dt) |
Dummy implementation, causing an abort if it should be called to catch any errors early. | |
virtual bool | hitKart (const Vec3 &xyz, const AbstractKart *kart=NULL) const |
virtual int | getGraphNode () const |
virtual const Vec3 * | getAvoidancePoint (bool left) const |
virtual float | getDistanceFromCenter () const |
virtual void | reset () |
Resets an item to its start state. | |
virtual void | switchTo (ItemType type) |
Switches an item to be of a different type. | |
virtual bool | switchBack () |
Returns true if this item was not actually switched (e.g. | |
bool | isNegativeItem () const |
Returns if this item is negative, i.e. | |
void | setTicksTillReturn (int t) |
Sets how long an item should be disabled. | |
int | getTicksTillReturn () const |
Returns the time the item is disabled for. | |
bool | isAvailable () const |
Returns true if this item is currently collected. | |
ItemType | getType () const |
Returns the type of this item. | |
ItemType | getGrahpicalType () const |
Returns the graphical type of this item should be using (takes nolok into account). | |
ItemType | getOriginalType () const |
Returns the original type of this item. | |
void | setItemId (unsigned int n) |
Sets the index of this item in the item manager list. | |
unsigned int | getItemId () const |
Returns the index of this item in the item manager list. | |
bool | isUsedUp () const |
Returns true if this item is used up and can be removed. | |
bool | canBeUsedUp () const |
Returns true if this item can be used up, and therefore needs to be removed when the game is reset. | |
int | getDeactivatedTicks () const |
Returns the number of ticks during which the item is deactivated (i.e. | |
void | setDeactivatedTicks (int ticks) |
Sets the number of ticks during which the item is deactivated (i.e. | |
const AbstractKart * | getPreviousOwner () const |
Returns the kart that dropped this item (or NULL if the item was not dropped by a kart. | |
void | setXYZ (const Vec3 &xyz) |
const Vec3 & | getXYZ () const |
Returns the XYZ position of the item. | |
const Vec3 | getNormal () const |
Returns the normal of the ItemState. | |
const btQuaternion & | getOriginalRotation () const |
Returns the original rotation of the item. | |
void | saveCompleteState (BareNetworkString *buffer) const |
Save item state at current ticks in server for live join. | |
Protected Member Functions | |
virtual void | setType (ItemType type) |
bool | hitLine (const core::line3df &line, const AbstractKart *kart=NULL) const |
Returns true if the specified line segment would come close enough to this item so that this item would be collected. | |
Private Member Functions | |
LEAK_CHECK () | |
Private Attributes | |
ItemType | m_type |
Item type. | |
ItemType | m_original_type |
If the item is switched, this contains the original type. | |
int | m_ticks_till_return |
Time till a collected item reappears. | |
int | m_item_id |
Index in item_manager field. | |
int | m_deactive_ticks |
Optionally if item was placed by a kart, a timer can be used to temporarly deactivate collision so a kart is not hit by its own item. | |
int | m_used_up_counter |
Counts how often an item is used before it disappears. | |
Vec3 | m_xyz |
The position of this ItemState. | |
btQuaternion | m_original_rotation |
The original rotation of the item. | |
const AbstractKart * | m_previous_owner |
The 'owner' of the item, i.e. | |
Friends | |
class | ItemManager |
class | NetworkItemManager |
class | SkiddingAI |
class | TestAI |
Contains the state information of an item, i.e.
all non-visual information only, which also can change (e.g. position and AI information is constant and therefore not stored here). This class is used as a base class for item and for networking to save item states.
enum ItemState::ItemType |
ItemState::ItemState | ( | ItemType | type, |
const AbstractKart * | owner = NULL , |
||
int | id = -1 |
||
) |
Constructor.
type | Type of the item. |
owner | If not NULL it is the kart that dropped this item; NULL indicates an item that's part of the track. |
id | Index of this item in the array of all items. |
|
virtual |
Called when the item is collected.
kart | The kart that collected the item. |
Reimplemented in Item.
|
inlinevirtual |
Reimplemented in Item.
|
inline |
Returns the number of ticks during which the item is deactivated (i.e.
it was collected).
|
inlinevirtual |
Reimplemented in Item.
|
inlinevirtual |
Reimplemented in Item.
|
inlinevirtual |
Reimplemented in Item.
|
inlineprotected |
Returns true if the specified line segment would come close enough to this item so that this item would be collected.
line | The line segment which is tested if it is close enough to this item so that this item would be collected. |
Initialises an item.
type | Type for this item. |
xyz | The position for this item. |
normal | The normal for this item. |
|
inline |
Returns if this item is negative, i.e.
a banana or bubblegum.
|
inlinevirtual |
Resets an item to its start state.
Reimplemented in Item.
|
inline |
Sets the number of ticks during which the item is deactivated (i.e.
it was collected).
void ItemState::setDisappearCounter | ( | ) |
Sets the disappear counter depending on type.
|
inline |
Sets how long an item should be disabled.
While item itself sets a default, this time is too short in case that a kart that has a bomb hits a banana: by the time the explosion animation is ended and the kart is back at its original position, the banana would be back again and therefore hit the kart again. See Attachment::hitBanana for more details.
f | Time till the item can be used again. |
|
inlinevirtual |
|
inlinevirtual |
Switches an item to be of a different type.
Used for the switch powerup.
type | New type for this item. |
void ItemState::update | ( | int | ticks | ) |
Update the state of the item, called once per physics frame.
ticks | Number of ticks to simulate. While this value is 1 when called during the normal game loop, during a rewind this value can be (much) larger than 1. |
|
inlinevirtual |
Dummy implementation, causing an abort if it should be called to catch any errors early.
Reimplemented in Item.
|
private |
Index in item_manager field.
This field can also take on a negative value when used in the NetworkItemManager.
|
private |
The original rotation of the item.
While this is technically a visual only value (atm, it could be used for collision detection), it is required to make sure a client can display items with the right normal (in case that a client would get a different (or no) normal from a raycast).
|
private |
If the item is switched, this contains the original type.
It is ITEM_NONE if the item is not switched.
|
private |
The 'owner' of the item, i.e.
the kart that dropped this item. Is NULL if the item is part of the track.
|
private |
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.
|
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, i.e. it will always reappear after a while.