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);
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;
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;
361 void setMesh(scene::IMesh* mesh, scene::IMesh* lowres_mesh);
366 scene::IMesh* mesh, scene::IMesh* lowres_mesh,
369 virtual void updateGraphics(
float dt) OVERRIDE;
370 virtual void reset() OVERRIDE;
404 if (getPreviousOwner() == kart && getDeactivatedTicks() > 0)
406 Vec3 lc = quatRotate(getOriginalRotation(), xyz - getXYZ());
408 lc.setY(lc.getY() / 2.0f);
409 return lc.length2() < m_distance_2;
412 bool rotating()
const {
return getType() != ITEM_BUBBLEGUM; }
423 return m_distance_from_center;
432 if(left)
return m_avoidance_points[0];
433 return m_avoidance_points[1];
436 scene::ISceneNode *getSceneNode()
438 return (scene::ISceneNode *) m_node;
ItemType getType() const
Returns the type of this item.
Definition: item.hpp:267
void setItemId(unsigned int n)
Sets the index of this item in the item manager list.
Definition: item.hpp:275
int m_item_id
Index in item_manager field.
Definition: item.hpp:93
int getDeactivatedTicks() const
Returns the number of ticks during which the item is deactivated (i.e.
Definition: item.hpp:289
std::vector< scene::ISceneNode * > m_spark_nodes
Vector containing the sparks.
Definition: item.hpp:334
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
virtual void reset()
Resets an item to its start state.
Definition: item.hpp:200
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
const Vec3 & getXYZ() const
Returns the XYZ position of the item.
Definition: item.hpp:302
bool m_was_available_previously
Stores if the item was available in the previously rendered frame.
Definition: item.hpp:340
virtual float getDistanceFromCenter() const OVERRIDE
Returns the distance from center: negative means left of center, positive means right of center...
Definition: item.hpp:421
int m_graph_node
The graph node this item is on.
Definition: item.hpp:346
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
Definition: three_d_animation.hpp:32
ItemType
The list of all items.
Definition: item.hpp:61
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
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
virtual void update(int ticks)
Updates the ai base controller each time step.
scene::ISceneNode * m_icon_node
Billboard that shows when the item is about to respawn.
Definition: item.hpp:337
int getTicksTillReturn() const
Returns the time the item is disabled for.
Definition: item.hpp:261
virtual void updateGraphics(float dt)
Dummy implementation, causing an abort if it should be called to catch any errors early...
Definition: item.hpp:162
float m_distance_2
square distance at which item is collected
Definition: item.hpp:343
LODNode * m_node
Scene node of this item.
Definition: item.hpp:328
void setDeactivatedTicks(int ticks)
Sets the number of ticks during which the item is deactivated (i.e.
Definition: item.hpp:293
unsigned int getItemId() const
Returns the index of this item in the item manager list.
Definition: item.hpp:278
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:74
void setTicksTillReturn(int t)
Sets how long an item should be disabled.
Definition: item.hpp:258
ItemType m_graphical_type
Graphical type of the mesh.
Definition: item.hpp:331
Vec3 m_xyz
The position of this ItemState.
Definition: item.hpp:107
manages level-of-detail
Definition: lod_node.hpp:48
int m_animation_start_ticks
Time ticks since the item last respawned.
Definition: item.hpp:354
const btQuaternion & getOriginalRotation() const
Returns the original rotation of the item.
Definition: item.hpp:311
bool isNegativeItem() const
Returns if this item is negative, i.e.
Definition: item.hpp:244
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
int m_used_up_counter
Counts how often an item is used before it disappears.
Definition: item.hpp:104
virtual int getGraphNode() const OVERRIDE
Returns the index of the graph node this item is on.
Definition: item.hpp:417
const Vec3 getNormal() const
Returns the normal of the ItemState.
Definition: item.hpp:305
int m_ticks_till_return
Time till a collected item reappears.
Definition: item.hpp:89
btQuaternion m_original_rotation
The original rotation of the item.
Definition: item.hpp:115
bool isUsedUp() const
Returns true if this item is used up and can be removed.
Definition: item.hpp:281
virtual void collected(const AbstractKart *kart)
Called when the item is collected.
Definition: item.cpp:135
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
ItemType m_type
Item type.
Definition: item.hpp:80
virtual void switchTo(ItemType type)
Switches an item to be of a different type.
Definition: item.hpp:218
Definition: item_manager.hpp:46
float m_distance_from_center
Distance from the center of the quad this item is in.
Definition: item.hpp:351
For easter egg mode only.
Definition: item.hpp:72
virtual bool switchBack() OVERRIDE
Switch backs to the original item.
Definition: item.hpp:387
bool isAvailable() const
Returns true if this item is currently collected.
Definition: item.hpp:264
ItemType m_original_type
If the item is switched, this contains the original type.
Definition: item.hpp:84
virtual bool switchBack()
Returns true if this item was not actually switched (e.g.
Definition: item.hpp:230
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
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
const AbstractKart * m_previous_owner
The 'owner' of the item, i.e.
Definition: item.hpp:119
Contains the state information of an item, i.e.
Definition: item.hpp:52
ItemType getOriginalType() const
Returns the original type of this item.
Definition: item.hpp:272
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
The network item manager is responsible for handling all network related item manager tasks - synchro...
Definition: network_item_manager.hpp:44
This is the actual racing AI.
Definition: skidding_ai.hpp:116