SuperTuxKart
|
Public Member Functions | |
Item (ItemType type, const Vec3 &xyz, const Vec3 &normal, scene::IMesh *mesh, scene::IMesh *lowres_mesh, const std::string &icon, const AbstractKart *owner) | |
Constructor for an item. | |
virtual | ~Item () |
Removes an item. | |
virtual void | updateGraphics (float dt) OVERRIDE |
Updated the item - rotates it, takes care of items coming back into the game after it has been collected. | |
virtual void | reset () OVERRIDE |
Resets before a race (esp. | |
virtual void | collected (const AbstractKart *kart) OVERRIDE |
Is called when the item is hit by a kart. | |
virtual bool | switchBack () OVERRIDE |
Switch backs to the original item. | |
virtual bool | hitKart (const Vec3 &xyz, const AbstractKart *kart=NULL) const OVERRIDE |
Returns true if the Kart is close enough to hit this item, the item is not deactivated anymore, and it wasn't placed by this kart (this is e.g. | |
bool | rotating () const |
virtual int | getGraphNode () const OVERRIDE |
Returns the index of the graph node this item is on. | |
virtual float | getDistanceFromCenter () const OVERRIDE |
Returns the distance from center: negative means left of center, positive means right of center. | |
virtual const Vec3 * | getAvoidancePoint (bool left) const OVERRIDE |
Returns a point to the left or right of the item which will not trigger a collection of this item. | |
scene::ISceneNode * | getSceneNode () |
Public Member Functions inherited from ItemState | |
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. | |
Private Member Functions | |
void | initItem (ItemType type, const Vec3 &xyz, const Vec3 &normal) |
Initialises the item. | |
void | setMesh (scene::IMesh *mesh, scene::IMesh *lowres_mesh) |
void | handleNewMesh (ItemType type) |
Private Attributes | |
LODNode * | m_node |
Scene node of this item. | |
ItemType | m_graphical_type |
Graphical type of the mesh. | |
std::vector< scene::ISceneNode * > | m_spark_nodes |
Vector containing the sparks. | |
scene::ISceneNode * | m_icon_node |
Billboard that shows when the item is about to respawn. | |
bool | m_was_available_previously |
Stores if the item was available in the previously rendered frame. | |
float | m_distance_2 |
square distance at which item is collected | |
int | m_graph_node |
The graph node this item is on. | |
float | m_distance_from_center |
Distance from the center of the quad this item is in. | |
int | m_animation_start_ticks |
Time ticks since the item last respawned. | |
Vec3 * | m_avoidance_points [2] |
The closest point to the left and right of this item at which it would not be collected. | |
Additional Inherited Members | |
Public Types inherited from ItemState | |
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... | |
Protected Member Functions inherited from ItemState | |
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. | |
Item::Item | ( | ItemType | type, |
const Vec3 & | xyz, | ||
const Vec3 & | normal, | ||
scene::IMesh * | mesh, | ||
scene::IMesh * | lowres_mesh, | ||
const std::string & | icon, | ||
const AbstractKart * | owner | ||
) |
Constructor for an item.
type | Type of the item. |
xyz | Location of the item. |
normal | The normal upon which the item is placed (so that it can be aligned properly with the ground). |
mesh | The mesh to be used for this item. |
owner | 'Owner' of this item, i.e. the kart that drops it. This is used to deactivate this item for the owner, i.e. avoid that a kart 'collects' its own bubble gum. NULL means no owner, and the item can be collected immediatley by any kart. |
|
inlinevirtual |
Is called when the item is hit by a kart.
It sets the flag that the item has been collected, and the time to return to the parameter.
kart | The kart that collected the item. |
Reimplemented from ItemState.
|
inlinevirtual |
Returns a point to the left or right of the item which will not trigger a collection of this item.
left | If true, return a point to the left, else a point to the right. |
Reimplemented from ItemState.
|
inlinevirtual |
Returns the distance from center: negative means left of center, positive means right of center.
Reimplemented from ItemState.
|
inlinevirtual |
Returns the index of the graph node this item is on.
Reimplemented from ItemState.
|
inlinevirtual |
Returns true if the Kart is close enough to hit this item, the item is not deactivated anymore, and it wasn't placed by this kart (this is e.g.
used to avoid that a kart hits a bubble gum it just dropped).
kart | Kart to test. |
xyz | Location of kart (avoiding to use kart->getXYZ() so that kart.hpp does not need to be included here). |
Reimplemented from ItemState.
Initialises the item.
Note that m_distance_2 must be defined before calling this function, since it pre-computes some values based on this.
type | Type of the item. |
xyz | Position of this item. |
normal | Normal for this item. |
|
virtual |
|
inlinevirtual |
Switch backs to the original item.
Returns true if the item was not actually switched (e.g. trigger, or bubblegum dropped during switch time). The return value is not actually used, but necessary in order to overwrite ItemState::switchBack()
Reimplemented from ItemState.
|
virtual |
Updated the item - rotates it, takes care of items coming back into the game after it has been collected.
ticks | Number of physics time steps - should be 1. |
Reimplemented from ItemState.
|
private |
The closest point to the left and right of this item at which it would not be collected.
Used by the AI to avoid items.
|
private |
Distance from the center of the quad this item is in.
This value is >0 if it is to the right of the center, and undefined if this quad is not on any quad.