20#ifndef HEADER_ITEM_HPP
21#define HEADER_ITEM_HPP
27#include "utils/cpp2011.hpp"
28#include "utils/leak_check.hpp"
29#include "utils/log.hpp"
30#include "utils/no_copy.hpp"
31#include "utils/vec3.hpp"
41 namespace scene {
class IMesh;
class ISceneNode; }
64 ITEM_BONUS_BOX = ITEM_FIRST,
142 Vec3 closest = line.getClosestPoint(
getXYZ().toIrrVector());
143 return hitKart(closest, kart);
164 Log::fatal(
"ItemState",
"updateGraphics() called for ItemState.");
168 virtual bool hitKart(
const Vec3 &xyz,
171 Log::fatal(
"ItemState",
"hitKart() called for ItemState.");
176 virtual int getGraphNode()
const
178 Log::fatal(
"ItemState",
"getGraphNode() called for ItemState.");
183 virtual const Vec3 *getAvoidancePoint(
bool left)
const
185 Log::fatal(
"ItemState",
"getAvoidancePoint() called for ItemState.");
191 virtual float getDistanceFromCenter()
const
193 Log::fatal(
"itemState",
194 "getDistanceFromCentre() called for ItemState.");
246 return m_type == ITEM_BANANA ||
m_type == ITEM_BUBBLEGUM ||
247 m_type == ITEM_BUBBLEGUM_NOLOK;
299 void setXYZ(
const Vec3& xyz) {
m_xyz = xyz; }
361 void setMesh(scene::IMesh* mesh, scene::IMesh* lowres_mesh);
366 scene::IMesh* mesh, scene::IMesh* lowres_mesh,
370 virtual void reset() OVERRIDE;
408 lc.setY(lc.getY() / 2.0f);
412 bool rotating()
const {
return getType() != ITEM_BUBBLEGUM; }
436 scene::ISceneNode *getSceneNode()
438 return (scene::ISceneNode *)
m_node;
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: item_manager.hpp:47
Contains the state information of an item, i.e.
Definition: item.hpp:53
virtual void reset()
Resets an item to its start state.
Definition: item.hpp:200
void setItemId(unsigned int n)
Sets the index of this item in the item manager list.
Definition: item.hpp:275
virtual void collected(const AbstractKart *kart)
Called when the item is collected.
Definition: item.cpp:136
int getTicksTillReturn() const
Returns the time the item is disabled for.
Definition: item.hpp:261
bool canBeUsedUp() const
Returns true if this item can be used up, and therefore needs to be removed when the game is reset.
Definition: item.hpp:285
Vec3 m_xyz
The position of this ItemState.
Definition: item.hpp:107
int m_deactive_ticks
Optionally if item was placed by a kart, a timer can be used to temporarly deactivate collision so a ...
Definition: item.hpp:97
const Vec3 getNormal() const
Returns the normal of the ItemState.
Definition: item.hpp:305
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 wou...
Definition: item.hpp:136
int m_used_up_counter
Counts how often an item is used before it disappears.
Definition: item.hpp:104
void setDeactivatedTicks(int ticks)
Sets the number of ticks during which the item is deactivated (i.e.
Definition: item.hpp:293
void saveCompleteState(BareNetworkString *buffer) const
Save item state at current ticks in server for live join.
Definition: item.cpp:197
virtual void switchTo(ItemType type)
Switches an item to be of a different type.
Definition: item.hpp:218
const AbstractKart * getPreviousOwner() const
Returns the kart that dropped this item (or NULL if the item was not dropped by a kart.
Definition: item.hpp:297
bool isUsedUp() const
Returns true if this item is used up and can be removed.
Definition: item.hpp:281
const Vec3 & getXYZ() const
Returns the XYZ position of the item.
Definition: item.hpp:302
ItemType getOriginalType() const
Returns the original type of this item.
Definition: item.hpp:272
virtual void updateGraphics(float dt)
Dummy implementation, causing an abort if it should be called to catch any errors early.
Definition: item.hpp:162
virtual bool switchBack()
Returns true if this item was not actually switched (e.g.
Definition: item.hpp:230
void update(int ticks)
Update the state of the item, called once per physics frame.
Definition: item.cpp:122
unsigned int getItemId() const
Returns the index of this item in the item manager list.
Definition: item.hpp:278
const btQuaternion & getOriginalRotation() const
Returns the original rotation of the item.
Definition: item.hpp:311
ItemType getGrahpicalType() const
Returns the graphical type of this item should be using (takes nolok into account).
Definition: item.cpp:187
ItemType getType() const
Returns the type of this item.
Definition: item.hpp:267
ItemType m_type
Item type.
Definition: item.hpp:80
ItemType
The list of all items.
Definition: item.hpp:62
@ ITEM_EASTER_EGG
For easter egg mode only.
Definition: item.hpp:72
const AbstractKart * m_previous_owner
The 'owner' of the item, i.e.
Definition: item.hpp:119
btQuaternion m_original_rotation
The original rotation of the item.
Definition: item.hpp:115
int m_ticks_till_return
Time till a collected item reappears.
Definition: item.hpp:89
int m_item_id
Index in item_manager field.
Definition: item.hpp:93
bool isAvailable() const
Returns true if this item is currently collected.
Definition: item.hpp:264
void initItem(ItemType type, const Vec3 &xyz, const Vec3 &normal)
Initialises an item.
Definition: item.cpp:107
void setTicksTillReturn(int t)
Sets how long an item should be disabled.
Definition: item.hpp:258
int getDeactivatedTicks() const
Returns the number of ticks during which the item is deactivated (i.e.
Definition: item.hpp:289
void setDisappearCounter()
Sets the disappear counter depending on type.
Definition: item.cpp:88
ItemType m_original_type
If the item is switched, this contains the original type.
Definition: item.hpp:84
bool isNegativeItem() const
Returns if this item is negative, i.e.
Definition: item.hpp:244
scene::ISceneNode * m_icon_node
Billboard that shows when the item is about to respawn.
Definition: item.hpp:337
ItemType m_graphical_type
Graphical type of the mesh.
Definition: item.hpp:331
virtual ~Item()
Removes an item.
Definition: item.cpp:358
virtual int getGraphNode() const OVERRIDE
Returns the index of the graph node this item is on.
Definition: item.hpp:417
virtual void reset() OVERRIDE
Resets before a race (esp.
Definition: item.cpp:379
virtual float getDistanceFromCenter() const OVERRIDE
Returns the distance from center: negative means left of center, positive means right of center.
Definition: item.hpp:421
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.
Definition: item.hpp:430
void initItem(ItemType type, const Vec3 &xyz, const Vec3 &normal)
Initialises the item.
Definition: item.cpp:293
LODNode * m_node
Scene node of this item.
Definition: item.hpp:328
virtual bool switchBack() OVERRIDE
Switch backs to the original item.
Definition: item.hpp:387
virtual void collected(const AbstractKart *kart) OVERRIDE
Is called when the item is hit by a kart.
Definition: item.hpp:377
int m_animation_start_ticks
Time ticks since the item last respawned.
Definition: item.hpp:354
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,...
Definition: item.hpp:401
std::vector< scene::ISceneNode * > m_spark_nodes
Vector containing the sparks.
Definition: item.hpp:334
int m_graph_node
The graph node this item is on.
Definition: item.hpp:346
bool m_was_available_previously
Stores if the item was available in the previously rendered frame.
Definition: item.hpp:340
float m_distance_2
square distance at which item is collected
Definition: item.hpp:343
Vec3 * m_avoidance_points[2]
The closest point to the left and right of this item at which it would not be collected.
Definition: item.hpp:358
virtual void updateGraphics(float dt) OVERRIDE
Updated the item - rotates it, takes care of items coming back into the game after it has been collec...
Definition: item.cpp:434
float m_distance_from_center
Distance from the center of the quad this item is in.
Definition: item.hpp:351
manages level-of-detail
Definition: lod_node.hpp:50
The network item manager is responsible for handling all network related item manager tasks - synchro...
Definition: network_item_manager.hpp:45
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
This is the actual racing AI.
Definition: skidding_ai.hpp:117
This is a test version of the AI, which can be used to create new AIs, and compare them with the curr...
Definition: test_ai.hpp:75
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35