1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2004-2015 Steve Baker <>
4 // Copyright (C) 2006-2015 SuperTuxKart-Team, Joerg Henrichs, Steve Baker
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 3
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_KART_HPP
21 #define HEADER_KART_HPP
29 #include "LinearMath/btTransform.h"
31 #include "items/powerup_manager.hpp" // For PowerupType
32 #include "karts/abstract_kart.hpp"
33 #include "utils/cpp2011.hpp"
34 #include "utils/no_copy.hpp"
36 #include <SColor.h>
39 class Attachment;
40 class btKart;
41 class btUprightConstraint;
42 class Controller;
43 class HitEffect;
44 class Item;
45 class ItemState;
46 class KartGFX;
47 class KartRewinder;
48 class MaxSpeed;
49 class ParticleEmitter;
50 class ParticleKind;
51 class SFXBase;
52 class Shadow;
53 class Skidding;
54 class SkidMarks;
55 class SlipStream;
56 class Stars;
57 class TerrainInfo;
68 class Kart : public AbstractKart
69 {
70  friend class Skidding;
71 private:
72  int m_network_finish_check_ticks;
73  int m_network_confirmed_finish_ticks;
74 protected:
82  /* Determines the time covered by the history size, in seconds */
83  const float XYZ_HISTORY_TIME = 0.25f;
85  /* Determines the number of previous XYZ positions of the kart to remember
86  Initialized in the constructor and unchanged from then on */
87  int m_xyz_history_size;
90  std::vector<Vec3> m_previous_xyz;
94  std::vector<float> m_previous_xyz_times;
96  float m_time_previous_counter;
108 protected:
118  std::unique_ptr<btVehicleRaycaster> m_vehicle_raycaster;
120  std::unique_ptr<btKart> m_vehicle;
123  std::unique_ptr<Skidding> m_skidding;
126  std::unique_ptr<Stars> m_stars_effect;
128  // Graphical effects
129  // -----------------
131 #ifndef SERVER_ONLY
133  std::unique_ptr<Shadow> m_shadow;
136  std::unique_ptr<SkidMarks> m_skidmarks;
137 #endif
140  std::unique_ptr<KartGFX> m_kart_gfx;
143  std::unique_ptr<SlipStream> m_slipstream;
145  // Bullet physics parameters
146  // -------------------------
148  {
149  void operator()(btCompoundShape* p) const
150  {
151  for(int i = 0; i< p->getNumChildShapes(); i++)
152  delete p->getChildShape(i);
153  delete p;
154  }
155  };
156  std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis;
172  PowerupManager::PowerupType m_last_used_powerup;
175  bool m_flying;
221  bool m_finished_race;
223  float m_finish_time;
229  float m_consumption_per_tick;
231  float m_energy_to_min_ratio;
233  float m_startup_boost;
235  float m_falling_time;
237  float m_weight;
240  float m_speed;
249  btTransform m_reset_transform;
251  std::vector<SFXBase*> m_custom_sounds;
252  int m_emitter_id = 0;
253  static const int EMITTER_COUNT = 3;
254  SFXBase *m_emitters[EMITTER_COUNT];
255  SFXBase *m_engine_sound;
262  SFXBase *m_nitro_sound;
266  SFXBase *m_skid_sound;
267  SFXBuffer *m_horn_sound;
268  static const int CRASH_SOUND_COUNT = 3;
269  SFXBuffer *m_crash_sounds[CRASH_SOUND_COUNT];
270  SFXBuffer *m_goo_sound;
271  SFXBuffer *m_boing_sound;
272  /* Used to avoid re-play the sound during rewinding, if it's happening at
273  * the same ticks. */
274  int m_ticks_last_crash;
275  int m_ticks_last_zipper;
276  RaceManager::KartType m_type;
278  void updatePhysics(int ticks);
279  void handleMaterialSFX();
280  void handleMaterialGFX(float dt);
281  void updateFlying();
282  void updateSliding();
283  void updateEnginePowerAndBrakes(int ticks);
284  void updateEngineSFX(float dt);
285  void updateSpeed();
286  void updateNitro(int ticks);
287  float applyAirFriction (float engine_power);
288  float getActualWheelForce();
289  void playCrashSFX(const Material* m, AbstractKart *k);
290  void loadData(RaceManager::KartType type, bool animatedModel);
291  void updateWeight();
292 public:
293  Kart(const std::string& ident, unsigned int world_kart_id,
294  int position, const btTransform& init_transform,
295  HandicapLevel handicap,
296  std::shared_ptr<RenderInfo> ri);
297  virtual ~Kart();
298  virtual void init(RaceManager::KartType type) OVERRIDE;
299  virtual void kartIsInRestNow() OVERRIDE;
300  virtual void updateGraphics(float dt) OVERRIDE;
301  virtual void createPhysics ();
302  virtual bool isInRest () const OVERRIDE;
303  virtual void applyEngineForce (float force);
305  virtual void flyUp() OVERRIDE;
306  virtual void flyDown() OVERRIDE;
308  virtual void startEngineSFX () OVERRIDE;
309  virtual void collectedItem(ItemState *item) OVERRIDE;
310  virtual float getStartupBoostFromStartTicks(int ticks) const OVERRIDE;
311  virtual float getStartupBoost() const OVERRIDE { return m_startup_boost; }
312  virtual void setStartupBoost(float val) OVERRIDE { m_startup_boost = val; }
313  virtual const Material *getMaterial() const OVERRIDE;
314  virtual const Material *getLastMaterial() const OVERRIDE;
316  virtual float getTerrainPitch(float heading) const OVERRIDE;
318  virtual void reset () OVERRIDE;
319  virtual void handleZipper (const Material *m=NULL,
320  bool play_sound=false) OVERRIDE;
321  virtual bool setSquash (float time, float slowdown) OVERRIDE;
322  void setSquashGraphics();
323  virtual void unsetSquash () OVERRIDE;
325  virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;
326  virtual void crashed (const Material *m, const Vec3 &normal) OVERRIDE;
327  virtual float getHoT () const OVERRIDE;
328  virtual void update (int ticks) OVERRIDE;
329  virtual void finishedRace (float time, bool from_server=false) OVERRIDE;
330  virtual void setPosition (int p) OVERRIDE;
331  virtual void beep () OVERRIDE;
332  virtual void showZipperFire () OVERRIDE;
335  virtual bool playCustomSFX (unsigned int type) OVERRIDE;
336  virtual void setController(Controller *controller) OVERRIDE;
337  virtual void setXYZ(const Vec3& a) OVERRIDE;
338  virtual void changeKart(const std::string& new_ident,
339  HandicapLevel handicap,
340  std::shared_ptr<RenderInfo> ri) OVERRIDE;
342  // ========================================================================================
343  // SPEED and speed-boost related functions
344  // ----------------------------------------------------------------------------------------
345  virtual void adjustSpeed (float f) OVERRIDE;
346  // ----------------------------------------------------------------------------------------
347  virtual void increaseMaxSpeed(unsigned int category, float add_speed,
348  float engine_force, int duration,
349  int fade_out_time) OVERRIDE;
350  // ----------------------------------------------------------------------------------------
351  virtual void instantSpeedIncrease(unsigned int category, float add_max_speed,
352  float speed_boost, float engine_force,
353  int duration, int fade_out_time) OVERRIDE;
354  // ----------------------------------------------------------------------------------------
355  virtual void setSlowdown(unsigned int category, float max_speed_fraction,
356  int fade_in_time) OVERRIDE;
357  // ----------------------------------------------------------------------------------------
358  virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE;
359  // ----------------------------------------------------------------------------------------
360  virtual float getSpeed() const OVERRIDE { return m_speed; }
361  // ----------------------------------------------------------------------------------------
362  virtual float getCurrentMaxSpeed() const OVERRIDE;
363  // ----------------------------------------------------------------------------------------
366  virtual void setSpeed(float s) OVERRIDE { m_speed = s; }
368  // ========================================================================================
369  // STEERING and skidding related functions
370  // ----------------------------------------------------------------------------------------
373  virtual float getMaxSteerAngle () const OVERRIDE
374  { return getMaxSteerAngle(getSpeed()); }
375  // ----------------------------------------------------------------------------------------
379  virtual float getTimeFullSteer(float steer) const OVERRIDE;
380  // ----------------------------------------------------------------------------------------
381  virtual float getSpeedForTurnRadius(float radius) const OVERRIDE;
382  // ----------------------------------------------------------------------------------------
383  virtual float getMaxSteerAngle(float speed) const;
384  // ----------------------------------------------------------------------------------------
387  virtual const Skidding *getSkidding() const OVERRIDE { return m_skidding.get(); }
388  // ----------------------------------------------------------------------------------------
391  virtual Skidding *getSkidding() OVERRIDE { return m_skidding.get(); }
393  // ========================================================================================
394  // NITRO related functions.
395  // ----------------------------------------------------------------------------------------
397  virtual float getEnergy() const OVERRIDE { return m_collected_energy; }
398  // ----------------------------------------------------------------------------------------
400  virtual void setEnergy(float val) OVERRIDE { m_collected_energy = val; }
401  // ----------------------------------------------------------------------------------------
405  virtual bool isOnMinNitroTime() const OVERRIDE { return m_min_nitro_ticks > 0; }
407  // ========================================================================================
408  // POWERUP related functions.
409  // ----------------------------------------------------------------------------------------
411  virtual void setPowerup (PowerupManager::PowerupType t, int n) OVERRIDE;
412  // ----------------------------------------------------------------------------------------
414  virtual void setLastUsedPowerup (PowerupManager::PowerupType t);
415  // ----------------------------------------------------------------------------------------
417  virtual const Powerup* getPowerup() const OVERRIDE { return m_powerup; }
418  // ----------------------------------------------------------------------------------------
420  virtual Powerup* getPowerup() OVERRIDE { return m_powerup; }
421  // ----------------------------------------------------------------------------------------
423  virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
424  {
425  return m_last_used_powerup;
426  }
427  // ----------------------------------------------------------------------------------------
429  virtual int getNumPowerup() const OVERRIDE;
431  // ========================================================================================
432  // SPECIAL-STATUS related functions (plunger, squash, shield, immunity).
433  // ----------------------------------------------------------------------------------------
435  virtual void setInvulnerableTicks(int ticks) OVERRIDE
436  {
437  // int16_t max
438  if (ticks > 32767)
439  ticks = 32767;
440  m_invulnerable_ticks = ticks;
441  } // setInvulnerableTicks
442  // ----------------------------------------------------------------------------------------
444  virtual bool isInvulnerable() const OVERRIDE { return m_invulnerable_ticks > 0; }
445  // ----------------------------------------------------------------------------------------
447  virtual int getBlockedByPlungerTicks() const OVERRIDE
448  { return m_view_blocked_by_plunger; }
449  // ----------------------------------------------------------------------------------------
452  virtual void blockViewWithPlunger() OVERRIDE;
453  // ----------------------------------------------------------------------------------------
455  virtual void setShieldTime(float t) OVERRIDE;
456  // ----------------------------------------------------------------------------------------
458  virtual bool isShielded() const OVERRIDE;
459  // ----------------------------------------------------------------------------------------
461  virtual float getShieldTime() const OVERRIDE;
462  // ----------------------------------------------------------------------------------------
464  virtual void decreaseShieldTime() OVERRIDE;
465  // ----------------------------------------------------------------------------------------
467  virtual bool isSquashed() const OVERRIDE;
469  // ========================================================================================
470  // CONTROLLER related functions
471  // ----------------------------------------------------------------------------------------
472  virtual void setBoostAI (bool boosted) OVERRIDE;
473  // ----------------------------------------------------------------------------------------
474  virtual bool getBoostAI () const OVERRIDE;
475  // ----------------------------------------------------------------------------------------
477  virtual Controller* getController() OVERRIDE { return m_controller; }
478  // ----------------------------------------------------------------------------------------
480  const Controller* getController() const OVERRIDE { return m_controller; }
482  // ========================================================================================
483  // LOCATION ON-TRACK related functions
484  // ----------------------------------------------------------------------------------------
487  virtual const Vec3& getFrontXYZ() const OVERRIDE { return m_xyz_front; }
488  // -----------------------------------------------------------------------------------------
492  virtual btTransform getAlignedTransform(const float customPitch=-1) OVERRIDE;
493  // ----------------------------------------------------------------------------------------
495  const btTransform& getResetTransform() const {return m_reset_transform;}
496  // ----------------------------------------------------------------------------------------
498  virtual bool isOnGround() const OVERRIDE;
499  // ----------------------------------------------------------------------------------------
502  bool isNearGround() const;
503  // ----------------------------------------------------------------------------------------
506  virtual const Vec3& getNormal() const OVERRIDE;
507  // ----------------------------------------------------------------------------------------
509  virtual const Vec3& getPreviousXYZ() const OVERRIDE
510  { return m_previous_xyz[m_xyz_history_size-1]; }
511  // ----------------------------------------------------------------------------------------
513  virtual const Vec3& getRecentPreviousXYZ() const OVERRIDE;
514  // ----------------------------------------------------------------------------------------
516  virtual const float getRecentPreviousXYZTime() const OVERRIDE
517  { return m_previous_xyz_times[m_xyz_history_size/5]; }
518  // ----------------------------------------------------------------------------------------
520  bool isFlying() const { return m_flying; }
521  // ----------------------------------------------------------------------------------------
523  virtual bool isJumping() const OVERRIDE { return m_is_jumping; }
524  // ----------------------------------------------------------------------------------------
526  virtual const TerrainInfo *getTerrainInfo() const OVERRIDE { return m_terrain_info; }
528  // ========================================================================================
529  // ----------------------------------------------------------------------------------------
531  virtual KartGFX* getKartGFX() OVERRIDE { return m_kart_gfx.get(); }
532  // ----------------------------------------------------------------------------------------
534  virtual int getPosition() const OVERRIDE { return m_race_position; }
535  // ----------------------------------------------------------------------------------------
537  virtual int getInitialPosition () const OVERRIDE { return m_initial_position; }
538  // ----------------------------------------------------------------------------------------
540  virtual float getFinishTime () const OVERRIDE { return m_finish_time; }
541  // ----------------------------------------------------------------------------------------
543  virtual bool hasFinishedRace () const OVERRIDE { return m_finished_race; }
544  // -----------------------------------------------------------------------------------------
546  const irr::video::SColor &getColor() const;
547  // ----------------------------------------------------------------------------------------
548  virtual RaceManager::KartType getType() const OVERRIDE { return m_type; }
549  // ----------------------------------------------------------------------------------------
551  virtual btKart *getVehicle() const OVERRIDE { return m_vehicle.get(); }
552  // ----------------------------------------------------------------------------------------
553  virtual btQuaternion getVisualRotation() const OVERRIDE;
554  // ----------------------------------------------------------------------------------------
556  virtual const SlipStream* getSlipstream() const OVERRIDE { return m_slipstream.get(); }
557  // ----------------------------------------------------------------------------------------
559  virtual SlipStream* getSlipstream() OVERRIDE {return m_slipstream.get(); }
560  // ----------------------------------------------------------------------------------------
562  virtual void setSlipstreamEffect(float f) OVERRIDE;
563  // ----------------------------------------------------------------------------------------
564  virtual bool isEliminated() const OVERRIDE { return m_eliminated; }
565  // ----------------------------------------------------------------------------------------
566  virtual void eliminate() OVERRIDE;
567  // ----------------------------------------------------------------------------------------
568  virtual void setOnScreenText(const core::stringw& text) OVERRIDE;
569  // ----------------------------------------------------------------------------------------
571  virtual bool getRaceResult() const OVERRIDE { return m_race_result; }
572  // ----------------------------------------------------------------------------------------
574  void setRaceResult();
575  // ----------------------------------------------------------------------------------------
577  virtual bool isGhostKart() const OVERRIDE { return false; }
578  // ----------------------------------------------------------------------------------------
579  SFXBase* getNextEmitter();
580  // ----------------------------------------------------------------------------------------
581  virtual void playSound(SFXBuffer* buffer) OVERRIDE;
582  // ----------------------------------------------------------------------------------------
583  virtual bool isVisible() const OVERRIDE;
584  // ----------------------------------------------------------------------------------------
586  virtual void showStarEffect(float t) OVERRIDE;
587  // ----------------------------------------------------------------------------------------
588  virtual Stars* getStarsEffect() const OVERRIDE
589  { return m_stars_effect.get(); }
590  // ------------------------------------------------------------------------
593  int getNetworkConfirmedFinishTicks() const OVERRIDE
594  { return m_network_confirmed_finish_ticks; }
596 }; // Kart
599 #endif
601 /* EOF */
virtual const Vec3 & getRecentPreviousXYZ() const OVERRIDE
Returns a more recent different previous position.
Definition: kart.cpp:3405
virtual bool playCustomSFX(unsigned int type) OVERRIDE
This function will play a particular character voice for this kart.
Definition: kart.cpp:2545
bool m_flying
True if kart is flying (for debug purposes only).
Definition: kart.hpp:175
virtual const Material * getLastMaterial() const OVERRIDE
Returns the previous material the kart was one (which might be the same as getMaterial() ).
Definition: kart.cpp:540
void updateEnginePowerAndBrakes(int ticks)
Sets the engine power.
Definition: kart.cpp:2749
Handicap per player.
Definition: remote_kart_info.hpp:39
Definition: kart_gfx.hpp:39
void playCrashSFX(const Material *m, AbstractKart *k)
Common code used when a kart or a material was hit.
Definition: kart.cpp:2449
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:45
The main kart class.
Definition: kart.hpp:68
virtual void adjustSpeed(float f) OVERRIDE
Multiplies the velocity of the kart by a factor f (both linear and angular).
Definition: kart.cpp:870
int16_t m_bubblegum_ticks
If > 0 then bubble gum effect is on.
Definition: kart.hpp:203
std::unique_ptr< KartGFX > m_kart_gfx
All particle effects.
Definition: kart.hpp:140
virtual const Skidding * getSkidding() const OVERRIDE
Returns the skidding object for this kart (which can be used to query skidding related values).
Definition: kart.hpp:387
Definition: max_speed.hpp:30
type of particles
Definition: particle_kind.hpp:41
int8_t m_min_nitro_ticks
To prevent using nitro in too short bursts.
Definition: kart.hpp:213
rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
Definition: btKart.hpp:31
void updateFlying()
Adjusts kart translation if the kart is flying (in debug mode).
Definition: kart.cpp:2933
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
virtual void setPosition(int p) OVERRIDE
Sets the position in race this kart has .
Definition: kart.cpp:600
virtual Controller * getController() OVERRIDE
Returns the controller of this kart.
Definition: kart.hpp:477
virtual void setEnergy(float val) OVERRIDE
Sets the energy the kart has collected.
Definition: kart.hpp:400
void handleMaterialSFX()
Plays any terrain specific sound effect.
Definition: kart.cpp:1937
virtual float getMaxSteerAngle() const OVERRIDE
Returns the maximum steering angle for this kart, which depends on the speed.
Definition: kart.hpp:373
float m_max_gear_rpm
Maximum engine rpm's for the current gear.
Definition: kart.hpp:193
float applyAirFriction(float engine_power)
Reduces the engine power according to speed.
Definition: kart.cpp:2708
A small interface for effects to be used when a kart is hit.
Definition: hit_effect.hpp:32
This objects is permanently available in a kart and stores information about addons.
Definition: attachment.hpp:51
Controller * m_controller
The main controller of this object, used for driving.
Definition: kart.hpp:164
virtual btKart * getVehicle() const OVERRIDE
Returns the bullet vehicle which represents this kart.
Definition: kart.hpp:551
virtual int getBlockedByPlungerTicks() const OVERRIDE
Returns true if the kart has a plunger attached to its face.
Definition: kart.hpp:447
virtual const Vec3 & getPreviousXYZ() const OVERRIDE
Returns the position 0.25s before.
Definition: kart.hpp:509
virtual const TerrainInfo * getTerrainInfo() const OVERRIDE
Returns the terrain info oject.
Definition: kart.hpp:526
virtual void crashed(AbstractKart *k, bool update_attachments) OVERRIDE
Called when the kart crashes against another kart.
Definition: kart.cpp:2296
Powerup * m_powerup
Handles the powerup of a kart.
Definition: kart.hpp:116
virtual void handleZipper(const Material *m=NULL, bool play_sound=false) OVERRIDE
Sets zipper time, and apply one time additional speed boost.
Definition: kart.cpp:2161
virtual bool isShielded() const OVERRIDE
Returns if the kart is protected by a shield.
Definition: kart.cpp:1269
virtual bool isInRest() const OVERRIDE
Returns true if the kart is 'resting', i.e.
Definition: kart.cpp:860
virtual bool isOnGround() const OVERRIDE
True if the wheels are touching the ground.
Definition: kart.cpp:1235
virtual const Material * getMaterial() const OVERRIDE
Returns the current material the kart is on.
Definition: kart.cpp:532
virtual float getShieldTime() const OVERRIDE
Returns the remaining time the kart is protected by a shield.
Definition: kart.cpp:1287
virtual bool setSquash(float time, float slowdown) OVERRIDE
Squashes this kart: it will scale the kart in up direction, and causes a slowdown while this kart is ...
Definition: kart.cpp:1853
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE
Returns how much increased speed time is left over in the given category.
Definition: kart.cpp:514
Different kart types: A local player, a player connected via network, an AI kart, the leader kart (cu...
Definition: race_manager.hpp:236
MaxSpeed * m_max_speed
Handles speed increase and capping due to powerup, terrain, ...
Definition: kart.hpp:110
virtual void setSlipstreamEffect(float f) OVERRIDE
Activates a slipstream effect, atm that is display some nitro.
Definition: kart.cpp:2285
PowerupManager::PowerupType m_last_used_powerup
Remember the last used powerup type of a kart for AI purposes.
Definition: kart.hpp:172
virtual int getPosition() const OVERRIDE
Returns the current position of this kart in the race.
Definition: kart.hpp:534
std::unique_ptr< Skidding > m_skidding
This object handles all skidding.
Definition: kart.hpp:123
SFXBase * m_terrain_sound
Sound to be played depending on terrain.
Definition: kart.hpp:257
The buffer (data) for one kind of sound effects.
Definition: sfx_buffer.hpp:45
const btTransform & getResetTransform() const
Returns the start transform, i.e.
Definition: kart.hpp:495
Definition: kart.hpp:147
uint8_t m_bounce_back_ticks
A short time after a collision acceleration is disabled to allow the karts to bounce back.
Definition: kart.hpp:106
std::vector< Vec3 > m_previous_xyz
The coordinates of the XYZ_HISTORY_SIZE previous positions.
Definition: kart.hpp:90
virtual bool hasFinishedRace() const OVERRIDE
Returns true if this kart has finished the race.
Definition: kart.hpp:543
std::unique_ptr< SkidMarks > m_skidmarks
The skidmarks object for this kart.
Definition: kart.hpp:136
virtual void increaseMaxSpeed(unsigned int category, float add_speed, float engine_force, int duration, int fade_out_time) OVERRIDE
Sets an increased maximum speed for a category.
Definition: kart.cpp:484
void loadData(RaceManager::KartType type, bool animatedModel)
Attaches the right model, creates the physics and loads all special effects (particle systems etc....
Definition: kart.cpp:2977
virtual const Vec3 & getNormal() const OVERRIDE
Returns the normal of the terrain the kart is over atm.
Definition: kart.cpp:3398
void updateSpeed()
Updates the local speed based on the current physical velocity.
Definition: kart.cpp:1801
virtual void collectedItem(ItemState *item) OVERRIDE
Called when an item is collected.
Definition: kart.cpp:1133
manages smoke particle effects
Definition: particle_emitter.hpp:41
virtual void setSlowdown(unsigned int category, float max_speed_fraction, int fade_in_time) OVERRIDE
Defines a slowdown, which is in fraction of top speed.
Definition: kart.cpp:502
virtual void setController(Controller *controller) OVERRIDE
Saves the old controller in m_saved_controller and stores a new controller.
Definition: kart.cpp:589
virtual void flyUp() OVERRIDE
Enter flying mode.
Definition: kart.cpp:807
int16_t m_invulnerable_ticks
Time a kart is invulnerable.
Definition: kart.hpp:200
virtual void init(RaceManager::KartType type) OVERRIDE
This is a second initialisation phase, necessary since in the constructor virtual functions are not c...
Definition: kart.cpp:197
bool isNearGround() const
Returns true if the kart is close to the ground, used to dis/enable the upright constraint to allow f...
Definition: kart.cpp:1245
std::unique_ptr< SlipStream > m_slipstream
Handles all slipstreaming.
Definition: kart.hpp:143
virtual int getNumPowerup() const OVERRIDE
Returns the number of powerups.
Definition: kart.cpp:578
virtual void createPhysics()
Creates the physical representation of this kart.
Definition: kart.cpp:663
Definition: powerup.hpp:37
virtual btTransform getAlignedTransform(const float customPitch=-1) OVERRIDE
Returns a bullet transform object located at the kart's position and oriented in the direction the ka...
Definition: kart.cpp:633
bool m_is_jumping
Is time flying activated.
Definition: kart.hpp:99
int m_race_position
Current race position (1-num_karts).
Definition: kart.hpp:190
virtual void beep() OVERRIDE
Plays a beep sfx.
Definition: kart.cpp:2508
virtual int getInitialPosition() const OVERRIDE
Returns the initial position of this kart.
Definition: kart.hpp:537
Definition: skidding.hpp:39
virtual bool isSquashed() const OVERRIDE
Returns if the kart is currently being squashed.
Definition: kart.cpp:1928
virtual float getCurrentMaxSpeed() const OVERRIDE
Returns the current maximum speed for this kart, this includes all bonus and maluses that are current...
Definition: kart.cpp:509
virtual void instantSpeedIncrease(unsigned int category, float add_max_speed, float speed_boost, float engine_force, int duration, int fade_out_time) OVERRIDE
This adjusts the top speed using increaseMaxSpeed, but additionally causes an instant speed boost,...
Definition: kart.cpp:493
int m_initial_position
Initial rank of the kart.
Definition: kart.hpp:187
float m_collected_energy
The amount of energy collected with nitro cans.
Definition: kart.hpp:227
float m_graphical_y_offset
Offset of the graphical kart chassis from the physical chassis.
Definition: kart.hpp:76
virtual float getFinishTime() const OVERRIDE
Returns the finished time for a kart.
Definition: kart.hpp:540
virtual bool isJumping() const OVERRIDE
Returns whether this kart is jumping.
Definition: kart.hpp:523
int16_t m_view_blocked_by_plunger
When a kart has its view blocked by the plunger, this variable will be 0 the number it contains is th...
Definition: kart.hpp:207
virtual float getTimeFullSteer(float steer) const OVERRIDE
Returns the time till full steering is reached for this kart.
Definition: kart.cpp:654
float m_default_suspension_force
For changeKart.
Definition: kart.hpp:246
float m_speed
The current speed (i.e.
Definition: kart.hpp:240
virtual void kartIsInRestNow() OVERRIDE
Computes the transform of the graphical kart chasses with regards to the physical chassis.
Definition: kart.cpp:3058
virtual float getSpeed() const OVERRIDE
Returns the speed of the kart in meters/second.
Definition: kart.hpp:360
virtual void setOnScreenText(const core::stringw &text) OVERRIDE
Sets a text that is being displayed on top of a kart.
Definition: kart.cpp:3370
virtual void setLastUsedPowerup(PowerupManager::PowerupType t)
Sets the last used powerup.
Definition: kart.cpp:572
std::unique_ptr< Shadow > m_shadow
The shadow of a kart.
Definition: kart.hpp:133
virtual void blockViewWithPlunger() OVERRIDE
Sets the view to blocked by a plunger.
Definition: kart.cpp:610
Controller * m_saved_controller
This saves the original controller when the end controller is used.
Definition: kart.hpp:169
virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
Returns the last used powerup.
Definition: kart.hpp:423
Definition: item.hpp:323
virtual void eliminate() OVERRIDE
Marks this kart to be eliminated.
Definition: kart.cpp:1319
This class stores information about the triangle that's under an object, i.e.
Definition: terrain_info.hpp:31
This class is used to display rotating stars around a kart's head.
Definition: stars.hpp:40
bool m_fire_clicked
True if fire button was pushed and not released.
Definition: kart.hpp:216
virtual bool isGhostKart() const OVERRIDE
Returns whether this kart is a ghost (replay) kart.
Definition: kart.hpp:577
virtual void setPowerup(PowerupManager::PowerupType t, int n) OVERRIDE
Sets a new powerup.
Definition: kart.cpp:563
virtual void reset() OVERRIDE
Reset before a new race.
Definition: kart.cpp:320
This class is responsible for drawing skid marks for a kart.
Definition: skid_marks.hpp:46
virtual void setSpeed(float s) OVERRIDE
This is used on the client side only to set the speed of the kart from the server information.
Definition: kart.hpp:366
virtual void applyEngineForce(float force)
Applies engine power to all the wheels that are traction capable, so other parts of code do not have ...
Definition: kart.cpp:3029
virtual bool isInvulnerable() const OVERRIDE
Returns if the kart is invulnerable.
Definition: kart.hpp:444
Definition: kart_rewinder.hpp:29
virtual float getSpeedForTurnRadius(float radius) const OVERRIDE
Returns the (maximum) speed for a given turn radius.
Definition: kart.cpp:897
virtual void setShieldTime(float t) OVERRIDE
Enables a kart shield protection for a certain amount of time.
Definition: kart.cpp:1257
virtual void startEngineSFX() OVERRIDE
Starts the engine sound effect.
Definition: kart.cpp:830
int m_brake_ticks
How long the brake key has been pressed - the longer the harder the kart will brake.
Definition: kart.hpp:197
void updateEngineSFX(float dt)
Adjust the engine sound effect depending on the speed of the kart.
Definition: kart.cpp:2660
Definition: material.hpp:46
const Material * m_last_sound_material
The material for which the last sound effect was played.
Definition: kart.hpp:260
void updatePhysics(int ticks)
Updates the physics for this kart: computing the driving force, set steering, handles skidding,...
Definition: kart.cpp:2588
virtual const Powerup * getPowerup() const OVERRIDE
Returns the current powerup.
Definition: kart.hpp:417
void updateSliding()
Handles sliding, i.e.
Definition: kart.cpp:2876
void updateNitro(int ticks)
Updates the current nitro status.
Definition: kart.cpp:2223
bool isFlying() const
For debugging only: check if a kart is flying.
Definition: kart.hpp:520
TerrainInfo * m_terrain_info
Stores information about the terrain the kart is on.
Definition: kart.hpp:113
virtual const SlipStream * getSlipstream() const OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:556
virtual void setInvulnerableTicks(int ticks) OVERRIDE
Makes a kart invulnerable for a certain amount of time.
Definition: kart.hpp:435
float m_last_factor_engine_sound
For smoothing engine sound.
Definition: kart.hpp:243
virtual float getHoT() const OVERRIDE
Returns the height of the terrain.
Definition: kart.cpp:553
SFXBase * m_previous_terrain_sound
A pointer to the previous terrain sound needs to be saved so that an 'older' sfx can be finished and ...
Definition: kart.hpp:265
Kart(const std::string &ident, unsigned int world_kart_id, int position, const btTransform &init_transform, HandicapLevel handicap, std::shared_ptr< RenderInfo > ri)
The kart constructor.
Definition: kart.cpp:114
virtual void updateGraphics(float dt) OVERRIDE
Updates the graphics model.
Definition: kart.cpp:3190
Vec3 m_xyz_front
The coordinates of the front of the kart, used to determine when a new lap is triggered.
Definition: kart.hpp:80
virtual bool isOnMinNitroTime() const OVERRIDE
Return whether nitro is being used despite the nitro button not being pressed due to minimal use time...
Definition: kart.hpp:405
virtual void showStarEffect(float t) OVERRIDE
Shows the star effect for a certain time.
Definition: kart.cpp:1313
virtual float getEnergy() const OVERRIDE
Returns the remaining collected energy.
Definition: kart.hpp:397
virtual void decreaseShieldTime() OVERRIDE
Decreases the kart's shield time.
Definition: kart.cpp:1301
virtual Powerup * getPowerup() OVERRIDE
Returns the current powerup.
Definition: kart.hpp:420
virtual bool isEliminated() const OVERRIDE
Returns true if the kart is eliminated.
Definition: kart.hpp:564
virtual float getTerrainPitch(float heading) const OVERRIDE
Returns the pitch of the terrain depending on the heading.
Definition: kart.cpp:546
virtual ~Kart()
The destructor frees the memory of this kart, but note that the actual kart model is still stored in ...
Definition: kart.cpp:277
Definition: render_info.hpp:27
float getActualWheelForce()
Simulates gears by adjusting the force of the engine.
Definition: kart.cpp:1210
btTransform m_reset_transform
Reset position.
Definition: kart.hpp:249
bool m_boosted_ai
True if the kart has been selected to have a boosted ai.
Definition: kart.hpp:219
virtual void setXYZ(const Vec3 &a) OVERRIDE
Sets the XYZ coordinates of the moveable.
Definition: kart.cpp:476
const Controller * getController() const OVERRIDE
Returns the controller of this kart (const version).
Definition: kart.hpp:480
virtual SlipStream * getSlipstream() OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:559
virtual void showZipperFire() OVERRIDE
Show fire to go with a zipper.
Definition: kart.cpp:1840
virtual void setBoostAI(bool boosted) OVERRIDE
Sets the kart AI boost state.
Definition: kart.cpp:520
The base class for sound effects.
Definition: sfx_base.hpp:42
virtual void update(int ticks) OVERRIDE
Updates the kart in each time step.
Definition: kart.cpp:1357
std::unique_ptr< Stars > m_stars_effect
For stars rotating around head effect.
Definition: kart.hpp:126
virtual Skidding * getSkidding() OVERRIDE
Returns the skidding object for this kart (which can be used to query skidding related values) - non-...
Definition: kart.hpp:391
virtual void finishedRace(float time, bool from_server=false) OVERRIDE
Sets that this kart has finished the race and finishing time.
Definition: kart.cpp:940
bool m_bubblegum_torque_sign
The sign of torque to apply after hitting a bubble gum.
Definition: kart.hpp:102
virtual const Vec3 & getFrontXYZ() const OVERRIDE
Returns the coordinates of the front of the kart.
Definition: kart.hpp:487
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:59
virtual void unsetSquash() OVERRIDE
Makes the kart unsquashed again.
Definition: kart.cpp:1902
const irr::video::SColor & getColor() const
Returns the color used for this kart.
Definition: kart.cpp:3420
bool m_race_result
True if the kart wins, false otherwise.
Definition: kart.hpp:181
virtual void changeKart(const std::string &new_ident, HandicapLevel handicap, std::shared_ptr< RenderInfo > ri) OVERRIDE
Change to new kart instancely (used in network live join).
Definition: kart.cpp:233
Contains the state information of an item, i.e.
Definition: item.hpp:52
ParticleEmitter * m_collision_particles
For collisions.
Definition: kart.hpp:159
virtual bool getBoostAI() const OVERRIDE
Returns the kart AI boost state.
Definition: kart.cpp:525
This class is used to enable a shadow for a kart.
Definition: shadow.hpp:39
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
void setRaceResult()
Set this kart race result.
Definition: kart.cpp:1062
virtual const float getRecentPreviousXYZTime() const OVERRIDE
Returns the time at which the recent previous position occured.
Definition: kart.hpp:516
void updateWeight()
This method is to be called every time the mass of the kart is updated, which includes attaching an a...
Definition: kart.cpp:880
std::vector< float > m_previous_xyz_times
The times at which the previous positions occured.
Definition: kart.hpp:94
bool m_eliminated
True if the kart is eliminated.
Definition: kart.hpp:184
virtual bool getRaceResult() const OVERRIDE
Returns whether this kart wins or loses.
Definition: kart.hpp:571
void handleMaterialGFX(float dt)
Handles material specific GFX, mostly particle effects.
Definition: kart.cpp:2035
float m_current_lean
Current leaning of the kart.
Definition: kart.hpp:210
int getNetworkConfirmedFinishTicks() const OVERRIDE
Return the confirmed finish ticks (sent by the server) indicating that this kart has really finished ...
Definition: kart.hpp:593
bool m_has_caught_nolok_bubblegum
Set when hitting bubblegum.
Definition: kart.hpp:178
Definition: slip_stream.hpp:47
virtual float getStartupBoostFromStartTicks(int ticks) const OVERRIDE
Called the first time a kart accelerates after 'ready'.
Definition: kart.cpp:1191
virtual KartGFX * getKartGFX() OVERRIDE
Returns a pointer to this kart's graphical effects.
Definition: kart.hpp:531