SuperTuxKart
kart.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
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
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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.
19 
20 #ifndef HEADER_KART_HPP
21 #define HEADER_KART_HPP
22 
29 #include "LinearMath/btTransform.h"
30 
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"
35 
36 #include <SColor.h>
37 
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 ParticleKind;
50 class SFXBase;
51 class Shadow;
52 class Skidding;
53 class SkidMarks;
54 class SlipStream;
55 class Stars;
56 class TerrainInfo;
57 
58 #ifndef SERVER_ONLY
59 class ParticleEmitter;
60 #endif
61 
71 class Kart : public AbstractKart
72 {
73  friend class Skidding;
74 private:
75  int m_network_finish_check_ticks;
76  int m_network_confirmed_finish_ticks;
77 protected:
80 
84 
85  /* Determines the time covered by the history size, in seconds */
86  const float XYZ_HISTORY_TIME = 0.25f;
87 
88  /* Determines the number of previous XYZ positions of the kart to remember
89  Initialized in the constructor and unchanged from then on */
90  int m_xyz_history_size;
91 
93  std::vector<Vec3> m_previous_xyz;
94 
97  std::vector<float> m_previous_xyz_times;
98 
99  float m_time_previous_counter;
100 
103 
106 
110 
111 protected:
114 
117 
120 
121  std::unique_ptr<btVehicleRaycaster> m_vehicle_raycaster;
122 
123  std::unique_ptr<btKart> m_vehicle;
124 
126  std::unique_ptr<Skidding> m_skidding;
127 
129  std::unique_ptr<Stars> m_stars_effect;
130 
131  // Graphical effects
132  // -----------------
133 
134 #ifndef SERVER_ONLY
136  std::unique_ptr<Shadow> m_shadow;
137 
139  std::unique_ptr<SkidMarks> m_skidmarks;
140 #endif
141 
143  std::unique_ptr<KartGFX> m_kart_gfx;
144 
146  std::unique_ptr<SlipStream> m_slipstream;
147 
148  // Bullet physics parameters
149  // -------------------------
151  {
152  void operator()(btCompoundShape* p) const
153  {
154  for(int i = 0; i< p->getNumChildShapes(); i++)
155  delete p->getChildShape(i);
156  delete p;
157  }
158  };
159  std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis;
160 
161 #ifndef SERVER_ONLY
164 #endif
165 
170 
175 
177  PowerupManager::PowerupType m_last_used_powerup;
178 
180  bool m_flying;
181 
184 
187 
190 
193 
196 
199 
203 
206 
209 
213 
216 
219 
222 
225 
226  bool m_finished_race;
227 
228  float m_finish_time;
229 
233 
234  float m_consumption_per_tick;
235 
236  float m_energy_to_min_ratio;
237 
238  float m_startup_boost;
239 
240  float m_falling_time;
241 
242  float m_weight;
243 
245  float m_speed;
246 
249 
252 
254  btTransform m_reset_transform;
255 
256  std::vector<SFXBase*> m_custom_sounds;
257  int m_emitter_id = 0;
258  static const int EMITTER_COUNT = 3;
259  SFXBase *m_emitters[EMITTER_COUNT];
260  SFXBase *m_engine_sound;
263 
266 
267  SFXBase *m_nitro_sound;
271  SFXBase *m_skid_sound;
272  SFXBuffer *m_horn_sound;
273  static const int CRASH_SOUND_COUNT = 3;
274  SFXBuffer *m_crash_sounds[CRASH_SOUND_COUNT];
275  SFXBuffer *m_goo_sound;
276  SFXBuffer *m_boing_sound;
277  /* Used to avoid re-play the sound during rewinding, if it's happening at
278  * the same ticks. */
279  int m_ticks_last_crash;
280  int m_ticks_last_zipper;
281  RaceManager::KartType m_type;
282 
283  void updatePhysics(int ticks);
284  void handleMaterialSFX();
285  void handleMaterialGFX(float dt);
286  void updateFlying();
287  void updateSliding();
288  void updateEnginePowerAndBrakes(int ticks);
289  void updateEngineSFX(float dt);
290  void updateSpeed();
291  void updateNitro(int ticks);
292  float applyAirFriction (float engine_power);
293  float getActualWheelForce();
294  void playCrashSFX(const Material* m, AbstractKart *k);
295  void loadData(RaceManager::KartType type, bool animatedModel);
296  void updateWeight();
297  void initSound();
298 public:
299  Kart(const std::string& ident, unsigned int world_kart_id,
300  int position, const btTransform& init_transform,
301  HandicapLevel handicap,
302  std::shared_ptr<GE::GERenderInfo> ri);
303  virtual ~Kart();
304  virtual void init(RaceManager::KartType type) OVERRIDE;
305  virtual void kartIsInRestNow() OVERRIDE;
306  virtual void updateGraphics(float dt) OVERRIDE;
307  virtual void createPhysics ();
308  virtual bool isInRest () const OVERRIDE;
309  virtual void applyEngineForce (float force);
310 
311  virtual void flyUp() OVERRIDE;
312  virtual void flyDown() OVERRIDE;
313 
314  virtual void startEngineSFX () OVERRIDE;
315  virtual void collectedItem(ItemState *item) OVERRIDE;
316  virtual float getStartupBoostFromStartTicks(int ticks) const OVERRIDE;
317  virtual float getStartupBoost() const OVERRIDE { return m_startup_boost; }
318  virtual void setStartupBoost(float val) OVERRIDE { m_startup_boost = val; }
319  virtual const Material *getMaterial() const OVERRIDE;
320  virtual const Material *getLastMaterial() const OVERRIDE;
322  virtual float getTerrainPitch(float heading) const OVERRIDE;
323 
324  virtual void reset () OVERRIDE;
325  virtual void handleZipper (const Material *m=NULL,
326  bool play_sound=false) OVERRIDE;
327  virtual bool setSquash (float time, float slowdown) OVERRIDE;
328  void setSquashGraphics();
329  virtual void unsetSquash () OVERRIDE;
330 
331  virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;
332  virtual void crashed (const Material *m, const Vec3 &normal) OVERRIDE;
333  virtual float getHoT () const OVERRIDE;
334  virtual void update (int ticks) OVERRIDE;
335  virtual void finishedRace (float time, bool from_server=false) OVERRIDE;
336  virtual void setPosition (int p) OVERRIDE;
337  virtual void beep () OVERRIDE;
338  virtual void showZipperFire () OVERRIDE;
339 
340 
341  virtual bool playCustomSFX (unsigned int type) OVERRIDE;
342  virtual void setController(Controller *controller) OVERRIDE;
343  virtual void setXYZ(const Vec3& a) OVERRIDE;
344  virtual void changeKart(const std::string& new_ident,
345  HandicapLevel handicap,
346  std::shared_ptr<GE::GERenderInfo> ri,
347  const KartData& kart_data = KartData()) OVERRIDE;
348 
349  // ========================================================================================
350  // SPEED and speed-boost related functions
351  // ----------------------------------------------------------------------------------------
352  virtual void adjustSpeed (float f) OVERRIDE;
353  // ----------------------------------------------------------------------------------------
354  virtual void increaseMaxSpeed(unsigned int category, float add_speed,
355  float engine_force, int duration,
356  int fade_out_time) OVERRIDE;
357  // ----------------------------------------------------------------------------------------
358  virtual void instantSpeedIncrease(unsigned int category, float add_max_speed,
359  float speed_boost, float engine_force,
360  int duration, int fade_out_time) OVERRIDE;
361  // ----------------------------------------------------------------------------------------
362  virtual void setSlowdown(unsigned int category, float max_speed_fraction,
363  int fade_in_time) OVERRIDE;
364  // ----------------------------------------------------------------------------------------
365  virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE;
366  // ----------------------------------------------------------------------------------------
367  virtual float getSpeed() const OVERRIDE { return m_speed; }
368  // ----------------------------------------------------------------------------------------
369  virtual float getCurrentMaxSpeed() const OVERRIDE;
370  // ----------------------------------------------------------------------------------------
373  virtual void setSpeed(float s) OVERRIDE { m_speed = s; }
374 
375  // ========================================================================================
376  // STEERING and skidding related functions
377  // ----------------------------------------------------------------------------------------
380  virtual float getMaxSteerAngle () const OVERRIDE
381  { return getMaxSteerAngle(getSpeed()); }
382  // ----------------------------------------------------------------------------------------
386  virtual float getTimeFullSteer(float steer) const OVERRIDE;
387  // ----------------------------------------------------------------------------------------
388  virtual float getSpeedForTurnRadius(float radius) const OVERRIDE;
389  // ----------------------------------------------------------------------------------------
390  virtual float getMaxSteerAngle(float speed) const;
391  // ----------------------------------------------------------------------------------------
394  virtual const Skidding *getSkidding() const OVERRIDE { return m_skidding.get(); }
395  // ----------------------------------------------------------------------------------------
398  virtual Skidding *getSkidding() OVERRIDE { return m_skidding.get(); }
399 
400  // ========================================================================================
401  // NITRO related functions.
402  // ----------------------------------------------------------------------------------------
404  virtual float getEnergy() const OVERRIDE { return m_collected_energy; }
405  // ----------------------------------------------------------------------------------------
407  virtual void setEnergy(float val) OVERRIDE { m_collected_energy = val; }
408  // ----------------------------------------------------------------------------------------
412  virtual bool isOnMinNitroTime() const OVERRIDE { return m_min_nitro_ticks > 0; }
413 
414  // ========================================================================================
415  // POWERUP related functions.
416  // ----------------------------------------------------------------------------------------
418  virtual void setPowerup (PowerupManager::PowerupType t, int n) OVERRIDE;
419  // ----------------------------------------------------------------------------------------
421  virtual void setLastUsedPowerup (PowerupManager::PowerupType t);
422  // ----------------------------------------------------------------------------------------
424  virtual const Powerup* getPowerup() const OVERRIDE { return m_powerup; }
425  // ----------------------------------------------------------------------------------------
427  virtual Powerup* getPowerup() OVERRIDE { return m_powerup; }
428  // ----------------------------------------------------------------------------------------
430  virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
431  {
432  return m_last_used_powerup;
433  }
434  // ----------------------------------------------------------------------------------------
436  virtual int getNumPowerup() const OVERRIDE;
437 
438  // ========================================================================================
439  // SPECIAL-STATUS related functions (plunger, squash, shield, immunity).
440  // ----------------------------------------------------------------------------------------
442  virtual void setInvulnerableTicks(int ticks) OVERRIDE
443  {
444  // int16_t max
445  if (ticks > 32767)
446  ticks = 32767;
447  m_invulnerable_ticks = ticks;
448  } // setInvulnerableTicks
449  // ----------------------------------------------------------------------------------------
451  virtual bool isInvulnerable() const OVERRIDE { return m_invulnerable_ticks > 0; }
452  // ----------------------------------------------------------------------------------------
454  virtual int getBlockedByPlungerTicks() const OVERRIDE
455  { return m_view_blocked_by_plunger; }
456  // ----------------------------------------------------------------------------------------
459  virtual void blockViewWithPlunger() OVERRIDE;
460  // ----------------------------------------------------------------------------------------
462  virtual void setShieldTime(float t) OVERRIDE;
463  // ----------------------------------------------------------------------------------------
465  virtual bool isShielded() const OVERRIDE;
466  // ----------------------------------------------------------------------------------------
468  virtual float getShieldTime() const OVERRIDE;
469  // ----------------------------------------------------------------------------------------
471  virtual void decreaseShieldTime() OVERRIDE;
472  // ----------------------------------------------------------------------------------------
474  virtual bool isSquashed() const OVERRIDE;
475 
476  // ========================================================================================
477  // CONTROLLER related functions
478  // ----------------------------------------------------------------------------------------
479  virtual void setBoostAI (bool boosted) OVERRIDE;
480  // ----------------------------------------------------------------------------------------
481  virtual bool getBoostAI () const OVERRIDE;
482  // ----------------------------------------------------------------------------------------
484  virtual Controller* getController() OVERRIDE { return m_controller; }
485  // ----------------------------------------------------------------------------------------
487  const Controller* getController() const OVERRIDE { return m_controller; }
488 
489  // ========================================================================================
490  // LOCATION ON-TRACK related functions
491  // ----------------------------------------------------------------------------------------
494  virtual const Vec3& getFrontXYZ() const OVERRIDE { return m_xyz_front; }
495  // -----------------------------------------------------------------------------------------
499  virtual btTransform getAlignedTransform(const float customPitch=-1) OVERRIDE;
500  // ----------------------------------------------------------------------------------------
502  const btTransform& getResetTransform() const {return m_reset_transform;}
503  // ----------------------------------------------------------------------------------------
505  virtual bool isOnGround() const OVERRIDE;
506  // ----------------------------------------------------------------------------------------
509  bool isNearGround() const;
510  // ----------------------------------------------------------------------------------------
513  virtual const Vec3& getNormal() const OVERRIDE;
514  // ----------------------------------------------------------------------------------------
516  virtual const Vec3& getPreviousXYZ() const OVERRIDE
517  { return m_previous_xyz[m_xyz_history_size-1]; }
518  // ----------------------------------------------------------------------------------------
520  virtual const Vec3& getRecentPreviousXYZ() const OVERRIDE;
521  // ----------------------------------------------------------------------------------------
523  virtual const float getRecentPreviousXYZTime() const OVERRIDE
524  { return m_previous_xyz_times[m_xyz_history_size/5]; }
525  // ----------------------------------------------------------------------------------------
527  bool isFlying() const { return m_flying; }
528  // ----------------------------------------------------------------------------------------
530  virtual bool isJumping() const OVERRIDE { return m_is_jumping; }
531  // ----------------------------------------------------------------------------------------
533  virtual const TerrainInfo *getTerrainInfo() const OVERRIDE { return m_terrain_info; }
534 
535  // ========================================================================================
536  // ----------------------------------------------------------------------------------------
538  virtual KartGFX* getKartGFX() OVERRIDE { return m_kart_gfx.get(); }
539  // ----------------------------------------------------------------------------------------
541  virtual int getPosition() const OVERRIDE { return m_race_position; }
542  // ----------------------------------------------------------------------------------------
544  virtual int getInitialPosition () const OVERRIDE { return m_initial_position; }
545  // ----------------------------------------------------------------------------------------
547  virtual float getFinishTime () const OVERRIDE { return m_finish_time; }
548  // ----------------------------------------------------------------------------------------
550  virtual bool hasFinishedRace () const OVERRIDE { return m_finished_race; }
551  // -----------------------------------------------------------------------------------------
553  const irr::video::SColor &getColor() const;
554  // ----------------------------------------------------------------------------------------
555  virtual RaceManager::KartType getType() const OVERRIDE { return m_type; }
556  // ----------------------------------------------------------------------------------------
558  virtual btKart *getVehicle() const OVERRIDE { return m_vehicle.get(); }
559  // ----------------------------------------------------------------------------------------
560  virtual btQuaternion getVisualRotation() const OVERRIDE;
561  // ----------------------------------------------------------------------------------------
563  virtual const SlipStream* getSlipstream() const OVERRIDE { return m_slipstream.get(); }
564  // ----------------------------------------------------------------------------------------
566  virtual SlipStream* getSlipstream() OVERRIDE {return m_slipstream.get(); }
567  // ----------------------------------------------------------------------------------------
569  virtual void setSlipstreamEffect(float f) OVERRIDE;
570  // ----------------------------------------------------------------------------------------
571  virtual bool isEliminated() const OVERRIDE { return m_eliminated; }
572  // ----------------------------------------------------------------------------------------
573  virtual void eliminate() OVERRIDE;
574  // ----------------------------------------------------------------------------------------
575  virtual void setOnScreenText(const core::stringw& text) OVERRIDE;
576  // ----------------------------------------------------------------------------------------
578  virtual bool getRaceResult() const OVERRIDE { return m_race_result; }
579  // ----------------------------------------------------------------------------------------
581  void setRaceResult();
582  // ----------------------------------------------------------------------------------------
584  virtual bool isGhostKart() const OVERRIDE { return false; }
585  // ----------------------------------------------------------------------------------------
586  SFXBase* getNextEmitter();
587  // ----------------------------------------------------------------------------------------
588  virtual void playSound(SFXBuffer* buffer) OVERRIDE;
589  // ----------------------------------------------------------------------------------------
590  virtual bool isVisible() const OVERRIDE;
591  // ----------------------------------------------------------------------------------------
593  virtual void showStarEffect(float t) OVERRIDE;
594  // ----------------------------------------------------------------------------------------
595  virtual Stars* getStarsEffect() const OVERRIDE
596  { return m_stars_effect.get(); }
597  // ------------------------------------------------------------------------
600  int getNetworkConfirmedFinishTicks() const OVERRIDE
601  { return m_network_confirmed_finish_ticks; }
602 
603 }; // Kart
604 
605 
606 #endif
607 
608 /* EOF */
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:60
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
This objects is permanently available in a kart and stores information about addons.
Definition: attachment.hpp:52
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:46
A small interface for effects to be used when a kart is hit.
Definition: hit_effect.hpp:33
Contains the state information of an item, i.e.
Definition: item.hpp:53
Definition: item.hpp:324
Definition: kart_data.hpp:12
Definition: kart_gfx.hpp:43
Definition: kart_rewinder.hpp:30
The main kart class.
Definition: kart.hpp:72
std::unique_ptr< SlipStream > m_slipstream
Handles all slipstreaming.
Definition: kart.hpp:146
virtual float getMaxSteerAngle() const OVERRIDE
Returns the maximum steering angle for this kart, which depends on the speed.
Definition: kart.hpp:380
float m_default_suspension_force
For changeKart.
Definition: kart.hpp:251
virtual void blockViewWithPlunger() OVERRIDE
Sets the view to blocked by a plunger.
Definition: kart.cpp:606
virtual void decreaseShieldTime() OVERRIDE
Decreases the kart's shield time.
Definition: kart.cpp:1307
virtual float getShieldTime() const OVERRIDE
Returns the remaining time the kart is protected by a shield.
Definition: kart.cpp:1293
virtual void startEngineSFX() OVERRIDE
Starts the engine sound effect.
Definition: kart.cpp:826
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE
Returns how much increased speed time is left over in the given category.
Definition: kart.cpp:510
void updateSpeed()
Updates the local speed based on the current physical velocity.
Definition: kart.cpp:1810
virtual void setPowerup(PowerupManager::PowerupType t, int n) OVERRIDE
Sets a new powerup.
Definition: kart.cpp:559
virtual void showStarEffect(float t) OVERRIDE
Shows the star effect for a certain time.
Definition: kart.cpp:1319
virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
Returns the last used powerup.
Definition: kart.hpp:430
virtual SlipStream * getSlipstream() OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:566
btTransform m_reset_transform
Reset position.
Definition: kart.hpp:254
bool m_is_jumping
Is time flying activated.
Definition: kart.hpp:102
MaxSpeed * m_max_speed
Handles speed increase and capping due to powerup, terrain, ...
Definition: kart.hpp:113
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:629
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:505
virtual bool getRaceResult() const OVERRIDE
Returns whether this kart wins or loses.
Definition: kart.hpp:578
virtual float getTimeFullSteer(float steer) const OVERRIDE
Returns the time till full steering is reached for this kart.
Definition: kart.cpp:650
virtual const Vec3 & getPreviousXYZ() const OVERRIDE
Returns the position 0.25s before.
Definition: kart.hpp:516
std::unique_ptr< Shadow > m_shadow
The shadow of a kart.
Definition: kart.hpp:136
virtual bool isShielded() const OVERRIDE
Returns if the kart is protected by a shield.
Definition: kart.cpp:1275
virtual void setOnScreenText(const core::stringw &text) OVERRIDE
Sets a text that is being displayed on top of a kart.
Definition: kart.cpp:3424
virtual const Material * getMaterial() const OVERRIDE
Returns the current material the kart is on.
Definition: kart.cpp:528
const Material * m_last_sound_material
The material for which the last sound effect was played.
Definition: kart.hpp:265
bool isFlying() const
For debugging only: check if a kart is flying.
Definition: kart.hpp:527
virtual void changeKart(const std::string &new_ident, HandicapLevel handicap, std::shared_ptr< GE::GERenderInfo > ri, const KartData &kart_data=KartData()) OVERRIDE
Change to new kart instancely (used in network live join).
Definition: kart.cpp:227
const Controller * getController() const OVERRIDE
Returns the controller of this kart (const version).
Definition: kart.hpp:487
virtual void eliminate() OVERRIDE
Marks this kart to be eliminated.
Definition: kart.cpp:1326
virtual void setController(Controller *controller) OVERRIDE
Saves the old controller in m_saved_controller and stores a new controller.
Definition: kart.cpp:585
virtual int getBlockedByPlungerTicks() const OVERRIDE
Returns true if the kart has a plunger attached to its face.
Definition: kart.hpp:454
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:394
Powerup * m_powerup
Handles the powerup of a kart.
Definition: kart.hpp:119
Vec3 m_xyz_front
The coordinates of the front of the kart, used to determine when a new lap is triggered.
Definition: kart.hpp:83
virtual void updateGraphics(float dt) OVERRIDE
Updates the graphics model.
Definition: kart.cpp:3240
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:498
std::unique_ptr< Stars > m_stars_effect
For stars rotating around head effect.
Definition: kart.hpp:129
virtual void setInvulnerableTicks(int ticks) OVERRIDE
Makes a kart invulnerable for a certain amount of time.
Definition: kart.hpp:442
virtual bool playCustomSFX(unsigned int type) OVERRIDE
This function will play a particular character voice for this kart.
Definition: kart.cpp:2567
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:3079
int m_race_position
Current race position (1-num_karts).
Definition: kart.hpp:195
virtual void kartIsInRestNow() OVERRIDE
Computes the transform of the graphical kart chasses with regards to the physical chassis.
Definition: kart.cpp:3108
virtual void collectedItem(ItemState *item) OVERRIDE
Called when an item is collected.
Definition: kart.cpp:1139
void setRaceResult()
Set this kart race result.
Definition: kart.cpp:1067
void updateEngineSFX(float dt)
Adjust the engine sound effect depending on the speed of the kart.
Definition: kart.cpp:2682
void handleMaterialGFX(float dt)
Handles material specific GFX, mostly particle effects.
Definition: kart.cpp:2045
std::vector< Vec3 > m_previous_xyz
The coordinates of the XYZ_HISTORY_SIZE previous positions.
Definition: kart.hpp:93
virtual ~Kart()
The destructor frees the memory of this kart, but note that the actual kart model is still stored in ...
Definition: kart.cpp:267
bool m_bubblegum_torque_sign
The sign of torque to apply after hitting a bubble gum.
Definition: kart.hpp:105
virtual float getHoT() const OVERRIDE
Returns the height of the terrain.
Definition: kart.cpp:549
virtual void reset() OVERRIDE
Reset before a new race.
Definition: kart.cpp:314
virtual float getStartupBoostFromStartTicks(int ticks) const OVERRIDE
Called the first time a kart accelerates after 'ready'.
Definition: kart.cpp:1197
virtual bool isEliminated() const OVERRIDE
Returns true if the kart is eliminated.
Definition: kart.hpp:571
virtual void setEnergy(float val) OVERRIDE
Sets the energy the kart has collected.
Definition: kart.hpp:407
virtual void createPhysics()
Creates the physical representation of this kart.
Definition: kart.cpp:659
float m_last_factor_engine_sound
For smoothing engine sound.
Definition: kart.hpp:248
virtual void showZipperFire() OVERRIDE
Show fire to go with a zipper.
Definition: kart.cpp:1849
int8_t m_min_nitro_ticks
To prevent using nitro in too short bursts.
Definition: kart.hpp:218
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:489
virtual const Vec3 & getFrontXYZ() const OVERRIDE
Returns the coordinates of the front of the kart.
Definition: kart.hpp:494
virtual void setShieldTime(float t) OVERRIDE
Enables a kart shield protection for a certain amount of time.
Definition: kart.cpp:1263
virtual int getNumPowerup() const OVERRIDE
Returns the number of powerups.
Definition: kart.cpp:574
virtual Powerup * getPowerup() OVERRIDE
Returns the current powerup.
Definition: kart.hpp:427
void playCrashSFX(const Material *m, AbstractKart *k)
Common code used when a kart or a material was hit.
Definition: kart.cpp:2471
float applyAirFriction(float engine_power)
Reduces the engine power according to speed.
Definition: kart.cpp:2738
void updatePhysics(int ticks)
Updates the physics for this kart: computing the driving force, set steering, handles skidding,...
Definition: kart.cpp:2610
float getActualWheelForce()
Simulates gears by adjusting the force of the engine.
Definition: kart.cpp:1216
virtual float getSpeedForTurnRadius(float radius) const OVERRIDE
Returns the (maximum) speed for a given turn radius.
Definition: kart.cpp:896
PowerupManager::PowerupType m_last_used_powerup
Remember the last used powerup type of a kart for AI purposes.
Definition: kart.hpp:177
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
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:2182
virtual void setSlipstreamEffect(float f) OVERRIDE
Activates a slipstream effect, atm that is display some nitro.
Definition: kart.cpp:2306
void updateNitro(int ticks)
Updates the current nitro status.
Definition: kart.cpp:2244
Controller * m_controller
The main controller of this object, used for driving.
Definition: kart.hpp:169
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:373
virtual void setXYZ(const Vec3 &a) OVERRIDE
Sets the XYZ coordinates of the moveable.
Definition: kart.cpp:472
virtual void unsetSquash() OVERRIDE
Makes the kart unsquashed again.
Definition: kart.cpp:1911
virtual int getInitialPosition() const OVERRIDE
Returns the initial position of this kart.
Definition: kart.hpp:544
virtual const Material * getLastMaterial() const OVERRIDE
Returns the previous material the kart was one (which might be the same as getMaterial() ).
Definition: kart.cpp:536
virtual Controller * getController() OVERRIDE
Returns the controller of this kart.
Definition: kart.hpp:484
virtual int getPosition() const OVERRIDE
Returns the current position of this kart in the race.
Definition: kart.hpp:541
virtual float getSpeed() const OVERRIDE
Returns the speed of the kart in meters/second.
Definition: kart.hpp:367
virtual void setLastUsedPowerup(PowerupManager::PowerupType t)
Sets the last used powerup.
Definition: kart.cpp:568
virtual const TerrainInfo * getTerrainInfo() const OVERRIDE
Returns the terrain info oject.
Definition: kart.hpp:533
virtual void setPosition(int p) OVERRIDE
Sets the position in race this kart has .
Definition: kart.cpp:596
bool m_flying
True if kart is flying (for debug purposes only).
Definition: kart.hpp:180
virtual void finishedRace(float time, bool from_server=false) OVERRIDE
Sets that this kart has finished the race and finishing time.
Definition: kart.cpp:939
void updateSliding()
Handles sliding, i.e.
Definition: kart.cpp:2906
virtual void update(int ticks) OVERRIDE
Updates the kart in each time step.
Definition: kart.cpp:1365
virtual void flyUp() OVERRIDE
Enter flying mode.
Definition: kart.cpp:803
std::vector< float > m_previous_xyz_times
The times at which the previous positions occured.
Definition: kart.hpp:97
void updateFlying()
Adjusts kart translation if the kart is flying (in debug mode).
Definition: kart.cpp:2963
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:109
void handleMaterialSFX()
Plays any terrain specific sound effect.
Definition: kart.cpp:1946
Controller * m_saved_controller
This saves the original controller when the end controller is used.
Definition: kart.hpp:174
int16_t m_invulnerable_ticks
Time a kart is invulnerable.
Definition: kart.hpp:205
virtual bool isSquashed() const OVERRIDE
Returns if the kart is currently being squashed.
Definition: kart.cpp:1937
TerrainInfo * m_terrain_info
Stores information about the terrain the kart is on.
Definition: kart.hpp:116
int getNetworkConfirmedFinishTicks() const OVERRIDE
Return the confirmed finish ticks (sent by the server) indicating that this kart has really finished ...
Definition: kart.hpp:600
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:1251
const btTransform & getResetTransform() const
Returns the start transform, i.e.
Definition: kart.hpp:502
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:3007
int16_t m_bubblegum_ticks
If > 0 then bubble gum effect is on.
Definition: kart.hpp:208
float m_max_gear_rpm
Maximum engine rpm's for the current gear.
Definition: kart.hpp:198
virtual bool getBoostAI() const OVERRIDE
Returns the kart AI boost state.
Definition: kart.cpp:521
SFXBase * m_terrain_sound
Sound to be played depending on terrain.
Definition: kart.hpp:262
virtual bool isInRest() const OVERRIDE
Returns true if the kart is 'resting', i.e.
Definition: kart.cpp:856
virtual float getFinishTime() const OVERRIDE
Returns the finished time for a kart.
Definition: kart.hpp:547
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:1862
virtual void setBoostAI(bool boosted) OVERRIDE
Sets the kart AI boost state.
Definition: kart.cpp:516
virtual bool isInvulnerable() const OVERRIDE
Returns if the kart is invulnerable.
Definition: kart.hpp:451
float m_current_lean
Current leaning of the kart.
Definition: kart.hpp:215
bool m_boosted_ai
True if the kart has been selected to have a boosted ai.
Definition: kart.hpp:224
Kart(const std::string &ident, unsigned int world_kart_id, int position, const btTransform &init_transform, HandicapLevel handicap, std::shared_ptr< GE::GERenderInfo > ri)
The kart constructor.
Definition: kart.cpp:114
virtual bool isJumping() const OVERRIDE
Returns whether this kart is jumping.
Definition: kart.hpp:530
virtual float getTerrainPitch(float heading) const OVERRIDE
Returns the pitch of the terrain depending on the heading.
Definition: kart.cpp:542
bool m_has_caught_nolok_bubblegum
Set when hitting bubblegum.
Definition: kart.hpp:183
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:879
virtual btKart * getVehicle() const OVERRIDE
Returns the bullet vehicle which represents this kart.
Definition: kart.hpp:558
virtual const Vec3 & getRecentPreviousXYZ() const OVERRIDE
Returns a more recent different previous position.
Definition: kart.cpp:3459
float m_collected_energy
The amount of energy collected with nitro cans.
Definition: kart.hpp:232
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:480
virtual bool isOnGround() const OVERRIDE
True if the wheels are touching the ground.
Definition: kart.cpp:1241
virtual void adjustSpeed(float f) OVERRIDE
Multiplies the velocity of the kart by a factor f (both linear and angular).
Definition: kart.cpp:865
virtual const Vec3 & getNormal() const OVERRIDE
Returns the normal of the terrain the kart is over atm.
Definition: kart.cpp:3452
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:270
bool m_fire_clicked
True if fire button was pushed and not released.
Definition: kart.hpp:221
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:212
virtual float getEnergy() const OVERRIDE
Returns the remaining collected energy.
Definition: kart.hpp:404
bool m_eliminated
True if the kart is eliminated.
Definition: kart.hpp:189
std::unique_ptr< Skidding > m_skidding
This object handles all skidding.
Definition: kart.hpp:126
virtual const Powerup * getPowerup() const OVERRIDE
Returns the current powerup.
Definition: kart.hpp:424
ParticleEmitter * m_collision_particles
For collisions.
Definition: kart.hpp:163
virtual bool isGhostKart() const OVERRIDE
Returns whether this kart is a ghost (replay) kart.
Definition: kart.hpp:584
virtual Skidding * getSkidding() OVERRIDE
Returns the skidding object for this kart (which can be used to query skidding related values) - non-...
Definition: kart.hpp:398
virtual void crashed(AbstractKart *k, bool update_attachments) OVERRIDE
Called when the kart crashes against another kart.
Definition: kart.cpp:2317
virtual const SlipStream * getSlipstream() const OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:563
std::unique_ptr< KartGFX > m_kart_gfx
All particle effects.
Definition: kart.hpp:143
int m_initial_position
Initial rank of the kart.
Definition: kart.hpp:192
void updateEnginePowerAndBrakes(int ticks)
Sets the engine power.
Definition: kart.cpp:2779
virtual void beep() OVERRIDE
Plays a beep sfx.
Definition: kart.cpp:2530
std::unique_ptr< SkidMarks > m_skidmarks
The skidmarks object for this kart.
Definition: kart.hpp:139
virtual bool hasFinishedRace() const OVERRIDE
Returns true if this kart has finished the race.
Definition: kart.hpp:550
float m_speed
The current speed (i.e.
Definition: kart.hpp:245
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:412
virtual const float getRecentPreviousXYZTime() const OVERRIDE
Returns the time at which the recent previous position occured.
Definition: kart.hpp:523
float m_graphical_y_offset
Offset of the graphical kart chassis from the physical chassis.
Definition: kart.hpp:79
bool m_race_result
True if the kart wins, false otherwise.
Definition: kart.hpp:186
virtual KartGFX * getKartGFX() OVERRIDE
Returns a pointer to this kart's graphical effects.
Definition: kart.hpp:538
int m_brake_ticks
How long the brake key has been pressed - the longer the harder the kart will brake.
Definition: kart.hpp:202
const irr::video::SColor & getColor() const
Returns the color used for this kart.
Definition: kart.cpp:3474
Definition: material.hpp:48
Definition: max_speed.hpp:31
manages smoke particle effects
Definition: particle_emitter.hpp:44
type of particles
Definition: particle_kind.hpp:42
Definition: powerup.hpp:38
KartType
Different kart types: A local player, a player connected via network, an AI kart, the leader kart (cu...
Definition: race_manager.hpp:243
The base class for sound effects.
Definition: sfx_base.hpp:43
The buffer (data) for one kind of sound effects.
Definition: sfx_buffer.hpp:44
This class is used to enable a shadow for a kart.
Definition: shadow.hpp:48
This class is responsible for drawing skid marks for a kart.
Definition: skid_marks.hpp:54
Definition: skidding.hpp:40
Definition: slip_stream.hpp:48
This class is used to display rotating stars around a kart's head.
Definition: stars.hpp:41
This class stores information about the triangle that's under an object, i.e.
Definition: terrain_info.hpp:32
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
Definition: btKart.hpp:32
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:43
Definition: kart.hpp:151