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  void initSound();
293 public:
294  Kart(const std::string& ident, unsigned int world_kart_id,
295  int position, const btTransform& init_transform,
296  HandicapLevel handicap,
297  std::shared_ptr<RenderInfo> ri);
298  virtual ~Kart();
299  virtual void init(RaceManager::KartType type) OVERRIDE;
300  virtual void kartIsInRestNow() OVERRIDE;
301  virtual void updateGraphics(float dt) OVERRIDE;
302  virtual void createPhysics ();
303  virtual bool isInRest () const OVERRIDE;
304  virtual void applyEngineForce (float force);
306  virtual void flyUp() OVERRIDE;
307  virtual void flyDown() OVERRIDE;
309  virtual void startEngineSFX () OVERRIDE;
310  virtual void collectedItem(ItemState *item) OVERRIDE;
311  virtual float getStartupBoostFromStartTicks(int ticks) const OVERRIDE;
312  virtual float getStartupBoost() const OVERRIDE { return m_startup_boost; }
313  virtual void setStartupBoost(float val) OVERRIDE { m_startup_boost = val; }
314  virtual const Material *getMaterial() const OVERRIDE;
315  virtual const Material *getLastMaterial() const OVERRIDE;
317  virtual float getTerrainPitch(float heading) const OVERRIDE;
319  virtual void reset () OVERRIDE;
320  virtual void handleZipper (const Material *m=NULL,
321  bool play_sound=false) OVERRIDE;
322  virtual bool setSquash (float time, float slowdown) OVERRIDE;
323  void setSquashGraphics();
324  virtual void unsetSquash () OVERRIDE;
326  virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;
327  virtual void crashed (const Material *m, const Vec3 &normal) OVERRIDE;
328  virtual float getHoT () const OVERRIDE;
329  virtual void update (int ticks) OVERRIDE;
330  virtual void finishedRace (float time, bool from_server=false) OVERRIDE;
331  virtual void setPosition (int p) OVERRIDE;
332  virtual void beep () OVERRIDE;
333  virtual void showZipperFire () OVERRIDE;
336  virtual bool playCustomSFX (unsigned int type) OVERRIDE;
337  virtual void setController(Controller *controller) OVERRIDE;
338  virtual void setXYZ(const Vec3& a) OVERRIDE;
339  virtual void changeKart(const std::string& new_ident,
340  HandicapLevel handicap,
341  std::shared_ptr<RenderInfo> ri) OVERRIDE;
343  // ========================================================================================
344  // SPEED and speed-boost related functions
345  // ----------------------------------------------------------------------------------------
346  virtual void adjustSpeed (float f) OVERRIDE;
347  // ----------------------------------------------------------------------------------------
348  virtual void increaseMaxSpeed(unsigned int category, float add_speed,
349  float engine_force, int duration,
350  int fade_out_time) OVERRIDE;
351  // ----------------------------------------------------------------------------------------
352  virtual void instantSpeedIncrease(unsigned int category, float add_max_speed,
353  float speed_boost, float engine_force,
354  int duration, int fade_out_time) OVERRIDE;
355  // ----------------------------------------------------------------------------------------
356  virtual void setSlowdown(unsigned int category, float max_speed_fraction,
357  int fade_in_time) OVERRIDE;
358  // ----------------------------------------------------------------------------------------
359  virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE;
360  // ----------------------------------------------------------------------------------------
361  virtual float getSpeed() const OVERRIDE { return m_speed; }
362  // ----------------------------------------------------------------------------------------
363  virtual float getCurrentMaxSpeed() const OVERRIDE;
364  // ----------------------------------------------------------------------------------------
367  virtual void setSpeed(float s) OVERRIDE { m_speed = s; }
369  // ========================================================================================
370  // STEERING and skidding related functions
371  // ----------------------------------------------------------------------------------------
374  virtual float getMaxSteerAngle () const OVERRIDE
375  { return getMaxSteerAngle(getSpeed()); }
376  // ----------------------------------------------------------------------------------------
380  virtual float getTimeFullSteer(float steer) const OVERRIDE;
381  // ----------------------------------------------------------------------------------------
382  virtual float getSpeedForTurnRadius(float radius) const OVERRIDE;
383  // ----------------------------------------------------------------------------------------
384  virtual float getMaxSteerAngle(float speed) const;
385  // ----------------------------------------------------------------------------------------
388  virtual const Skidding *getSkidding() const OVERRIDE { return m_skidding.get(); }
389  // ----------------------------------------------------------------------------------------
392  virtual Skidding *getSkidding() OVERRIDE { return m_skidding.get(); }
394  // ========================================================================================
395  // NITRO related functions.
396  // ----------------------------------------------------------------------------------------
398  virtual float getEnergy() const OVERRIDE { return m_collected_energy; }
399  // ----------------------------------------------------------------------------------------
401  virtual void setEnergy(float val) OVERRIDE { m_collected_energy = val; }
402  // ----------------------------------------------------------------------------------------
406  virtual bool isOnMinNitroTime() const OVERRIDE { return m_min_nitro_ticks > 0; }
408  // ========================================================================================
409  // POWERUP related functions.
410  // ----------------------------------------------------------------------------------------
412  virtual void setPowerup (PowerupManager::PowerupType t, int n) OVERRIDE;
413  // ----------------------------------------------------------------------------------------
415  virtual void setLastUsedPowerup (PowerupManager::PowerupType t);
416  // ----------------------------------------------------------------------------------------
418  virtual const Powerup* getPowerup() const OVERRIDE { return m_powerup; }
419  // ----------------------------------------------------------------------------------------
421  virtual Powerup* getPowerup() OVERRIDE { return m_powerup; }
422  // ----------------------------------------------------------------------------------------
424  virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
425  {
426  return m_last_used_powerup;
427  }
428  // ----------------------------------------------------------------------------------------
430  virtual int getNumPowerup() const OVERRIDE;
432  // ========================================================================================
433  // SPECIAL-STATUS related functions (plunger, squash, shield, immunity).
434  // ----------------------------------------------------------------------------------------
436  virtual void setInvulnerableTicks(int ticks) OVERRIDE
437  {
438  // int16_t max
439  if (ticks > 32767)
440  ticks = 32767;
441  m_invulnerable_ticks = ticks;
442  } // setInvulnerableTicks
443  // ----------------------------------------------------------------------------------------
445  virtual bool isInvulnerable() const OVERRIDE { return m_invulnerable_ticks > 0; }
446  // ----------------------------------------------------------------------------------------
448  virtual int getBlockedByPlungerTicks() const OVERRIDE
449  { return m_view_blocked_by_plunger; }
450  // ----------------------------------------------------------------------------------------
453  virtual void blockViewWithPlunger() OVERRIDE;
454  // ----------------------------------------------------------------------------------------
456  virtual void setShieldTime(float t) OVERRIDE;
457  // ----------------------------------------------------------------------------------------
459  virtual bool isShielded() const OVERRIDE;
460  // ----------------------------------------------------------------------------------------
462  virtual float getShieldTime() const OVERRIDE;
463  // ----------------------------------------------------------------------------------------
465  virtual void decreaseShieldTime() OVERRIDE;
466  // ----------------------------------------------------------------------------------------
468  virtual bool isSquashed() const OVERRIDE;
470  // ========================================================================================
471  // CONTROLLER related functions
472  // ----------------------------------------------------------------------------------------
473  virtual void setBoostAI (bool boosted) OVERRIDE;
474  // ----------------------------------------------------------------------------------------
475  virtual bool getBoostAI () const OVERRIDE;
476  // ----------------------------------------------------------------------------------------
478  virtual Controller* getController() OVERRIDE { return m_controller; }
479  // ----------------------------------------------------------------------------------------
481  const Controller* getController() const OVERRIDE { return m_controller; }
483  // ========================================================================================
484  // LOCATION ON-TRACK related functions
485  // ----------------------------------------------------------------------------------------
488  virtual const Vec3& getFrontXYZ() const OVERRIDE { return m_xyz_front; }
489  // -----------------------------------------------------------------------------------------
493  virtual btTransform getAlignedTransform(const float customPitch=-1) OVERRIDE;
494  // ----------------------------------------------------------------------------------------
496  const btTransform& getResetTransform() const {return m_reset_transform;}
497  // ----------------------------------------------------------------------------------------
499  virtual bool isOnGround() const OVERRIDE;
500  // ----------------------------------------------------------------------------------------
503  bool isNearGround() const;
504  // ----------------------------------------------------------------------------------------
507  virtual const Vec3& getNormal() const OVERRIDE;
508  // ----------------------------------------------------------------------------------------
510  virtual const Vec3& getPreviousXYZ() const OVERRIDE
511  { return m_previous_xyz[m_xyz_history_size-1]; }
512  // ----------------------------------------------------------------------------------------
514  virtual const Vec3& getRecentPreviousXYZ() const OVERRIDE;
515  // ----------------------------------------------------------------------------------------
517  virtual const float getRecentPreviousXYZTime() const OVERRIDE
518  { return m_previous_xyz_times[m_xyz_history_size/5]; }
519  // ----------------------------------------------------------------------------------------
521  bool isFlying() const { return m_flying; }
522  // ----------------------------------------------------------------------------------------
524  virtual bool isJumping() const OVERRIDE { return m_is_jumping; }
525  // ----------------------------------------------------------------------------------------
527  virtual const TerrainInfo *getTerrainInfo() const OVERRIDE { return m_terrain_info; }
529  // ========================================================================================
530  // ----------------------------------------------------------------------------------------
532  virtual KartGFX* getKartGFX() OVERRIDE { return m_kart_gfx.get(); }
533  // ----------------------------------------------------------------------------------------
535  virtual int getPosition() const OVERRIDE { return m_race_position; }
536  // ----------------------------------------------------------------------------------------
538  virtual int getInitialPosition () const OVERRIDE { return m_initial_position; }
539  // ----------------------------------------------------------------------------------------
541  virtual float getFinishTime () const OVERRIDE { return m_finish_time; }
542  // ----------------------------------------------------------------------------------------
544  virtual bool hasFinishedRace () const OVERRIDE { return m_finished_race; }
545  // -----------------------------------------------------------------------------------------
547  const irr::video::SColor &getColor() const;
548  // ----------------------------------------------------------------------------------------
549  virtual RaceManager::KartType getType() const OVERRIDE { return m_type; }
550  // ----------------------------------------------------------------------------------------
552  virtual btKart *getVehicle() const OVERRIDE { return m_vehicle.get(); }
553  // ----------------------------------------------------------------------------------------
554  virtual btQuaternion getVisualRotation() const OVERRIDE;
555  // ----------------------------------------------------------------------------------------
557  virtual const SlipStream* getSlipstream() const OVERRIDE { return m_slipstream.get(); }
558  // ----------------------------------------------------------------------------------------
560  virtual SlipStream* getSlipstream() OVERRIDE {return m_slipstream.get(); }
561  // ----------------------------------------------------------------------------------------
563  virtual void setSlipstreamEffect(float f) OVERRIDE;
564  // ----------------------------------------------------------------------------------------
565  virtual bool isEliminated() const OVERRIDE { return m_eliminated; }
566  // ----------------------------------------------------------------------------------------
567  virtual void eliminate() OVERRIDE;
568  // ----------------------------------------------------------------------------------------
569  virtual void setOnScreenText(const core::stringw& text) OVERRIDE;
570  // ----------------------------------------------------------------------------------------
572  virtual bool getRaceResult() const OVERRIDE { return m_race_result; }
573  // ----------------------------------------------------------------------------------------
575  void setRaceResult();
576  // ----------------------------------------------------------------------------------------
578  virtual bool isGhostKart() const OVERRIDE { return false; }
579  // ----------------------------------------------------------------------------------------
580  SFXBase* getNextEmitter();
581  // ----------------------------------------------------------------------------------------
582  virtual void playSound(SFXBuffer* buffer) OVERRIDE;
583  // ----------------------------------------------------------------------------------------
584  virtual bool isVisible() const OVERRIDE;
585  // ----------------------------------------------------------------------------------------
587  virtual void showStarEffect(float t) OVERRIDE;
588  // ----------------------------------------------------------------------------------------
589  virtual Stars* getStarsEffect() const OVERRIDE
590  { return m_stars_effect.get(); }
591  // ------------------------------------------------------------------------
594  int getNetworkConfirmedFinishTicks() const OVERRIDE
595  { return m_network_confirmed_finish_ticks; }
597 }; // Kart
600 #endif
602 /* EOF */
virtual const Vec3 & getRecentPreviousXYZ() const OVERRIDE
Returns a more recent different previous position.
Definition: kart.cpp:3434
virtual bool playCustomSFX(unsigned int type) OVERRIDE
This function will play a particular character voice for this kart.
Definition: kart.cpp:2550
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:530
void updateEnginePowerAndBrakes(int ticks)
Sets the engine power.
Definition: kart.cpp:2754
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:2454
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:45
Definition: script_kart.cpp:38
virtual void adjustSpeed(float f) OVERRIDE
Multiplies the velocity of the kart by a factor f (both linear and angular).
Definition: kart.cpp:860
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:388
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
Definition: script_track.cpp:471
void updateFlying()
Adjusts kart translation if the kart is flying (in debug mode).
Definition: kart.cpp:2938
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
virtual void setPosition(int p) OVERRIDE
Sets the position in race this kart has .
Definition: kart.cpp:590
virtual Controller * getController() OVERRIDE
Returns the controller of this kart.
Definition: kart.hpp:478
virtual void setEnergy(float val) OVERRIDE
Sets the energy the kart has collected.
Definition: kart.hpp:401
void handleMaterialSFX()
Plays any terrain specific sound effect.
Definition: kart.cpp:1931
virtual float getMaxSteerAngle() const OVERRIDE
Returns the maximum steering angle for this kart, which depends on the speed.
Definition: kart.hpp:374
float m_max_gear_rpm
Maximum engine rpm&#39;s for the current gear.
Definition: kart.hpp:193
float applyAirFriction(float engine_power)
Reduces the engine power according to speed.
Definition: kart.cpp:2713
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:552
virtual int getBlockedByPlungerTicks() const OVERRIDE
Returns true if the kart has a plunger attached to its face.
Definition: kart.hpp:448
virtual const Vec3 & getPreviousXYZ() const OVERRIDE
Returns the position 0.25s before.
Definition: kart.hpp:510
virtual const TerrainInfo * getTerrainInfo() const OVERRIDE
Returns the terrain info oject.
Definition: kart.hpp:527
virtual void crashed(AbstractKart *k, bool update_attachments) OVERRIDE
Called when the kart crashes against another kart.
Definition: kart.cpp:2300
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:2165
virtual bool isShielded() const OVERRIDE
Returns if the kart is protected by a shield.
Definition: kart.cpp:1261
virtual bool isInRest() const OVERRIDE
Returns true if the kart is &#39;resting&#39;, i.e.
Definition: kart.cpp:850
virtual bool isOnGround() const OVERRIDE
True if the wheels are touching the ground.
Definition: kart.cpp:1227
virtual const Material * getMaterial() const OVERRIDE
Returns the current material the kart is on.
Definition: kart.cpp:522
virtual float getShieldTime() const OVERRIDE
Returns the remaining time the kart is protected by a shield.
Definition: kart.cpp:1279
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:1847
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE
Returns how much increased speed time is left over in the given category.
Definition: kart.cpp:504
Different kart types: A local player, a player connected via network, an AI kart, the leader kart (cu...
Definition: race_manager.hpp:241
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:2289
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:535
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:43
const btTransform & getResetTransform() const
Returns the start transform, i.e.
Definition: kart.hpp:496
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:544
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:474
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:2982
virtual const Vec3 & getNormal() const OVERRIDE
Returns the normal of the terrain the kart is over atm.
Definition: kart.cpp:3427
void updateSpeed()
Updates the local speed based on the current physical velocity.
Definition: kart.cpp:1795
virtual void collectedItem(ItemState *item) OVERRIDE
Called when an item is collected.
Definition: kart.cpp:1125
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:492
virtual void setController(Controller *controller) OVERRIDE
Saves the old controller in m_saved_controller and stores a new controller.
Definition: kart.cpp:579
virtual void flyUp() OVERRIDE
Enter flying mode.
Definition: kart.cpp:797
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:194
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:1237
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:568
virtual void createPhysics()
Creates the physical representation of this kart.
Definition: kart.cpp:653
Definition: powerup.hpp:37
virtual btTransform getAlignedTransform(const float customPitch=-1) OVERRIDE
Returns a bullet transform object located at the kart&#39;s position and oriented in the direction the ka...
Definition: kart.cpp:623
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:2513
virtual int getInitialPosition() const OVERRIDE
Returns the initial position of this kart.
Definition: kart.hpp:538
Definition: skidding.hpp:39
virtual bool isSquashed() const OVERRIDE
Returns if the kart is currently being squashed.
Definition: kart.cpp:1922
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:499
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:483
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:541
virtual bool isJumping() const OVERRIDE
Returns whether this kart is jumping.
Definition: kart.hpp:524
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:644
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:3083
virtual float getSpeed() const OVERRIDE
Returns the speed of the kart in meters/second.
Definition: kart.hpp:361
virtual void setOnScreenText(const core::stringw &text) OVERRIDE
Sets a text that is being displayed on top of a kart.
Definition: kart.cpp:3399
virtual void setLastUsedPowerup(PowerupManager::PowerupType t)
Sets the last used powerup.
Definition: kart.cpp:562
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:600
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:424
Definition: item.hpp:323
virtual void eliminate() OVERRIDE
Marks this kart to be eliminated.
Definition: kart.cpp:1312
This class stores information about the triangle that&#39;s under an object, i.e.
Definition: terrain_info.hpp:31
This class is used to display rotating stars around a kart&#39;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:578
virtual void setPowerup(PowerupManager::PowerupType t, int n) OVERRIDE
Sets a new powerup.
Definition: kart.cpp:553
virtual void reset() OVERRIDE
Reset before a new race.
Definition: kart.cpp:308
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:367
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:3054
virtual bool isInvulnerable() const OVERRIDE
Returns if the kart is invulnerable.
Definition: kart.hpp:445
Definition: kart_rewinder.hpp:29
virtual float getSpeedForTurnRadius(float radius) const OVERRIDE
Returns the (maximum) speed for a given turn radius.
Definition: kart.cpp:887
virtual void setShieldTime(float t) OVERRIDE
Enables a kart shield protection for a certain amount of time.
Definition: kart.cpp:1249
virtual void startEngineSFX() OVERRIDE
Starts the engine sound effect.
Definition: kart.cpp:820
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:2665
Definition: material.hpp:47
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:2593
virtual const Powerup * getPowerup() const OVERRIDE
Returns the current powerup.
Definition: kart.hpp:418
void updateSliding()
Handles sliding, i.e.
Definition: kart.cpp:2881
void updateNitro(int ticks)
Updates the current nitro status.
Definition: kart.cpp:2227
bool isFlying() const
For debugging only: check if a kart is flying.
Definition: kart.hpp:521
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:557
virtual void setInvulnerableTicks(int ticks) OVERRIDE
Makes a kart invulnerable for a certain amount of time.
Definition: kart.hpp:436
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:543
SFXBase * m_previous_terrain_sound
A pointer to the previous terrain sound needs to be saved so that an &#39;older&#39; 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:113
virtual void updateGraphics(float dt) OVERRIDE
Updates the graphics model.
Definition: kart.cpp:3215
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:406
virtual void showStarEffect(float t) OVERRIDE
Shows the star effect for a certain time.
Definition: kart.cpp:1305
virtual float getEnergy() const OVERRIDE
Returns the remaining collected energy.
Definition: kart.hpp:398
virtual void decreaseShieldTime() OVERRIDE
Decreases the kart&#39;s shield time.
Definition: kart.cpp:1293
virtual Powerup * getPowerup() OVERRIDE
Returns the current powerup.
Definition: kart.hpp:421
virtual bool isEliminated() const OVERRIDE
Returns true if the kart is eliminated.
Definition: kart.hpp:565
virtual float getTerrainPitch(float heading) const OVERRIDE
Returns the pitch of the terrain depending on the heading.
Definition: kart.cpp:536
virtual ~Kart()
The destructor frees the memory of this kart, but note that the actual kart model is still stored in ...
Definition: kart.cpp:263
Definition: render_info.hpp:27
float getActualWheelForce()
Simulates gears by adjusting the force of the engine.
Definition: kart.cpp:1202
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:466
const Controller * getController() const OVERRIDE
Returns the controller of this kart (const version).
Definition: kart.hpp:481
virtual SlipStream * getSlipstream() OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:560
virtual void showZipperFire() OVERRIDE
Show fire to go with a zipper.
Definition: kart.cpp:1834
virtual void setBoostAI(bool boosted) OVERRIDE
Sets the kart AI boost state.
Definition: kart.cpp:510
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:1351
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:392
virtual void finishedRace(float time, bool from_server=false) OVERRIDE
Sets that this kart has finished the race and finishing time.
Definition: kart.cpp:930
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:488
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:1896
const irr::video::SColor & getColor() const
Returns the color used for this kart.
Definition: kart.cpp:3449
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:224
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:515
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:1053
virtual const float getRecentPreviousXYZTime() const OVERRIDE
Returns the time at which the recent previous position occured.
Definition: kart.hpp:517
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:870
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:572
void handleMaterialGFX(float dt)
Handles material specific GFX, mostly particle effects.
Definition: kart.cpp:2029
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:594
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 &#39;ready&#39;.
Definition: kart.cpp:1183
virtual KartGFX * getKartGFX() OVERRIDE
Returns a pointer to this kart&#39;s graphical effects.
Definition: kart.hpp:532