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,
73 ITEM_LAST = ITEM_EASTER_EGG,
126 virtual void setType(
ItemType type) { m_type = type; }
139 if (getPreviousOwner() == kart && getDeactivatedTicks() > 0)
142 Vec3 closest = line.getClosestPoint(getXYZ().toIrrVector());
143 return hitKart(closest, kart);
152 void initItem(ItemType type,
const Vec3& xyz,
const Vec3& normal);
154 void setDisappearCounter();
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.");
202 m_deactive_ticks = 0;
203 m_ticks_till_return = 0;
204 setDisappearCounter();
206 if (m_original_type != ITEM_NONE)
208 setType(m_original_type);
209 m_original_type = ITEM_NONE;
221 if (m_type == ITEM_EASTER_EGG)
return;
222 m_original_type = m_type;
235 if (m_original_type == ITEM_NONE)
237 setType(m_original_type);
238 m_original_type = ITEM_NONE;
246 return m_type == ITEM_BANANA || m_type == ITEM_BUBBLEGUM ||
247 m_type == ITEM_BUBBLEGUM_NOLOK;
269 ItemType getGrahpicalType()
const;
281 bool isUsedUp()
const {
return m_used_up_counter == 0; }
299 void setXYZ(
const Vec3& xyz) { m_xyz = xyz; }
307 return quatRotate(m_original_rotation,
Vec3(0.0f, 1.0f, 0.0f));
313 return m_original_rotation;
364 void setMesh(scene::IMesh* mesh, scene::IMesh* lowres_mesh);
369 scene::IMesh* mesh, scene::IMesh* lowres_mesh,
372 virtual void updateGraphics(
float dt) OVERRIDE;
373 virtual void reset() OVERRIDE;
407 if (getPreviousOwner() == kart && getDeactivatedTicks() > 0)
409 Vec3 lc = quatRotate(getOriginalRotation(), xyz - getXYZ());
411 lc.setY(lc.getY() / 2.0f);
412 return lc.length2() < m_distance_2;
415 bool rotating()
const {
return getType() != ITEM_BUBBLEGUM; }
426 return m_distance_from_center;
435 if(left)
return m_avoidance_points[0];
436 return m_avoidance_points[1];
439 scene::ISceneNode *getSceneNode()
441 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
const Vec3 & getXYZ() const
Returns the XYZ position of the item.
Definition: item.hpp:302
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
const btQuaternion & getOriginalRotation() const
Returns the original rotation of the item.
Definition: item.hpp:311
void setDeactivatedTicks(int ticks)
Sets the number of ticks during which the item is deactivated (i.e.
Definition: item.hpp:293
virtual void switchTo(ItemType type)
Switches an item to be of a different type.
Definition: item.hpp:218
bool isUsedUp() const
Returns true if this item is used up and can be removed.
Definition: item.hpp:281
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
unsigned int getItemId() const
Returns the index of this item in the item manager list.
Definition: item.hpp:278
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 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
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
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:340
ItemType m_graphical_type
Graphical type of the mesh.
Definition: item.hpp:331
virtual int getGraphNode() const OVERRIDE
Returns the index of the graph node this item is on.
Definition: item.hpp:420
virtual float getDistanceFromCenter() const OVERRIDE
Returns the distance from center: negative means left of center, positive means right of center.
Definition: item.hpp:424
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:390
int m_animation_start_ticks
Time ticks since the item last respawned.
Definition: item.hpp:357
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:404
std::vector< scene::ISceneNode * > m_spark_nodes
Vector containing the sparks.
Definition: item.hpp:337
int m_graph_node
The graph node this item is on.
Definition: item.hpp:349
bool m_was_available_previously
Stores if the item was available in the previously rendered frame.
Definition: item.hpp:343
scene::ISceneNode * m_appear_anime_node
The parent of m_spark_nodes and m_icon_node.
Definition: item.hpp:334
float m_distance_2
square distance at which item is collected
Definition: item.hpp:346
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:433
float m_distance_from_center
Distance from the center of the quad this item is in.
Definition: item.hpp:354
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
virtual void update(int ticks)
Updates the ai base controller each time step.
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35