SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Item Class Reference
Inheritance diagram for Item:
Inheritance graph
[legend]

Public Member Functions

 Item (ItemType type, const Vec3 &xyz, const Vec3 &normal, scene::IMesh *mesh, scene::IMesh *lowres_mesh, const AbstractKart *owner)
 Constructor for an item. More...
 
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. More...
 
virtual void reset () OVERRIDE
 Resets before a race (esp. More...
 
virtual void collected (const AbstractKart *kart) OVERRIDE
 Is called when the item is hit by a kart. More...
 
virtual bool switchBack () OVERRIDE
 Switch backs to the original item. More...
 
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. More...
 
bool rotating () const
 
virtual int getGraphNode () const OVERRIDE
 Returns the index of the graph node this item is on. More...
 
virtual float getDistanceFromCenter () const OVERRIDE
 Returns the distance from center: negative means left of center, positive means right of center. More...
 
virtual const Vec3getAvoidancePoint (bool left) const OVERRIDE
 Returns a point to the left or right of the item which will not trigger a collection of this item. More...
 
scene::ISceneNode * getSceneNode ()
 
- Public Member Functions inherited from ItemState
 ItemState (ItemType type, const AbstractKart *owner=NULL, int id=-1)
 Constructor. More...
 
 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. More...
 
void update (int ticks)
 Update the state of the item, called once per physics frame. More...
 
void setDisappearCounter ()
 Sets the disappear counter depending on type. More...
 
virtual void switchTo (ItemType type)
 Switches an item to be of a different type. More...
 
bool isNegativeItem () const
 Returns if this item is negative, i.e. More...
 
void setTicksTillReturn (int t)
 Sets how long an item should be disabled. More...
 
int getTicksTillReturn () const
 Returns the time the item is disabled for. More...
 
bool isAvailable () const
 Returns true if this item is currently collected. More...
 
ItemType getType () const
 Returns the type of this item. More...
 
ItemType getGrahpicalType () const
 Returns the graphical type of this item should be using (takes nolok into account). More...
 
ItemType getOriginalType () const
 Returns the original type of this item. More...
 
void setItemId (unsigned int n)
 Sets the index of this item in the item manager list. More...
 
unsigned int getItemId () const
 Returns the index of this item in the item manager list. More...
 
bool isUsedUp () const
 Returns true if this item is used up and can be removed. More...
 
bool canBeUsedUp () const
 Returns true if this item can be used up, and therefore needs to be removed when the game is reset. More...
 
int getDeactivatedTicks () const
 Returns the number of ticks during which the item is deactivated (i.e. More...
 
void setDeactivatedTicks (int ticks)
 Sets the number of ticks during which the item is deactivated (i.e. More...
 
const AbstractKartgetPreviousOwner () const
 Returns the kart that dropped this item (or NULL if the item was not dropped by a kart. More...
 
void setXYZ (const Vec3 &xyz)
 
const Vec3getXYZ () const
 Returns the XYZ position of the item. More...
 
const Vec3 getNormal () const
 Returns the normal of the ItemState. More...
 
const btQuaternion & getOriginalRotation () const
 Returns the original rotation of the item. More...
 
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. More...
 
void setMesh (scene::IMesh *mesh, scene::IMesh *lowres_mesh)
 
void handleNewMesh (ItemType type)
 

Private Attributes

LODNodem_node
 Scene node of this item. More...
 
ItemType m_graphical_type
 Graphical type of the mesh. More...
 
bool m_was_available_previously
 Stores if the item was available in the previously rendered frame. More...
 
float m_distance_2
 square distance at which item is collected
 
int m_graph_node
 The graph node this item is on. More...
 
float m_distance_from_center
 Distance from the center of the quad this item is in. More...
 
Vec3m_avoidance_points [2]
 The closest point to the left and right of this item at which it would not be collected. More...
 

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. More...
 

Constructor & Destructor Documentation

◆ Item()

Item::Item ( ItemType  type,
const Vec3 xyz,
const Vec3 normal,
scene::IMesh *  mesh,
scene::IMesh *  lowres_mesh,
const AbstractKart owner 
)

Constructor for an item.

Parameters
typeType of the item.
xyzLocation of the item.
normalThe normal upon which the item is placed (so that it can be aligned properly with the ground).
meshThe 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.

Member Function Documentation

◆ collected()

virtual void Item::collected ( const AbstractKart 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.

Parameters
kartThe kart that collected the item.

Reimplemented from ItemState.

◆ getAvoidancePoint()

virtual const Vec3* Item::getAvoidancePoint ( bool  left) const
inlinevirtual

Returns a point to the left or right of the item which will not trigger a collection of this item.

Parameters
leftIf true, return a point to the left, else a point to the right.

Reimplemented from ItemState.

◆ getDistanceFromCenter()

virtual float Item::getDistanceFromCenter ( ) const
inlinevirtual

Returns the distance from center: negative means left of center, positive means right of center.

Reimplemented from ItemState.

◆ getGraphNode()

virtual int Item::getGraphNode ( ) const
inlinevirtual

Returns the index of the graph node this item is on.

Reimplemented from ItemState.

◆ hitKart()

virtual bool Item::hitKart ( const Vec3 xyz,
const AbstractKart kart = NULL 
) const
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).

Parameters
kartKart to test.
xyzLocation of kart (avoiding to use kart->getXYZ() so that kart.hpp does not need to be included here).

Reimplemented from ItemState.

◆ initItem()

void Item::initItem ( ItemType  type,
const Vec3 xyz,
const Vec3 normal 
)
private

Initialises the item.

Note that m_distance_2 must be defined before calling this function, since it pre-computes some values based on this.

Parameters
typeType of the item.
xyzPosition of this item.
normalNormal for this item.

◆ reset()

void Item::reset ( )
virtual

Resets before a race (esp.

if a race is restarted).

Reimplemented from ItemState.

◆ switchBack()

virtual bool Item::switchBack ( )
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.

◆ updateGraphics()

void Item::updateGraphics ( float  dt)
virtual

Updated the item - rotates it, takes care of items coming back into the game after it has been collected.

Parameters
ticksNumber of physics time steps - should be 1.

Reimplemented from ItemState.

Member Data Documentation

◆ m_avoidance_points

Vec3* Item::m_avoidance_points[2]
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.

◆ m_distance_from_center

float Item::m_distance_from_center
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.

◆ m_graph_node

int Item::m_graph_node
private

The graph node this item is on.

◆ m_graphical_type

ItemType Item::m_graphical_type
private

Graphical type of the mesh.

◆ m_node

LODNode* Item::m_node
private

Scene node of this item.

◆ m_was_available_previously

bool Item::m_was_available_previously
private

Stores if the item was available in the previously rendered frame.


The documentation for this class was generated from the following files: