20#ifndef HEADER_KART_HPP
21#define HEADER_KART_HPP
29#include "LinearMath/btTransform.h"
31#include "items/powerup_manager.hpp"
32#include "karts/abstract_kart.hpp"
33#include "utils/cpp2011.hpp"
34#include "utils/no_copy.hpp"
41class btUprightConstraint;
72 int m_network_finish_check_ticks;
73 int m_network_confirmed_finish_ticks;
83 const float XYZ_HISTORY_TIME = 0.25f;
87 int m_xyz_history_size;
96 float m_time_previous_counter;
118 std::unique_ptr<btVehicleRaycaster> m_vehicle_raycaster;
120 std::unique_ptr<btKart> m_vehicle;
149 void operator()(btCompoundShape* p)
const
151 for(
int i = 0; i< p->getNumChildShapes(); i++)
152 delete p->getChildShape(i);
156 std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis;
221 bool m_finished_race;
229 float m_consumption_per_tick;
231 float m_energy_to_min_ratio;
233 float m_startup_boost;
235 float m_falling_time;
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];
268 static const int CRASH_SOUND_COUNT = 3;
269 SFXBuffer *m_crash_sounds[CRASH_SOUND_COUNT];
274 int m_ticks_last_crash;
275 int m_ticks_last_zipper;
294 Kart(
const std::string& ident,
unsigned int world_kart_id,
295 int position,
const btTransform& init_transform,
297 std::shared_ptr<GE::GERenderInfo> ri);
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; }
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,
341 std::shared_ptr<GE::GERenderInfo> ri,
347 virtual
void adjustSpeed (
float f) OVERRIDE;
349 virtual
void increaseMaxSpeed(
unsigned int category,
float add_speed,
350 float engine_force,
int duration,
351 int fade_out_time) OVERRIDE;
353 virtual
void instantSpeedIncrease(
unsigned int category,
float add_max_speed,
354 float speed_boost,
float engine_force,
355 int duration,
int fade_out_time) OVERRIDE;
357 virtual
void setSlowdown(
unsigned int category,
float max_speed_fraction,
358 int fade_in_time) OVERRIDE;
360 virtual
int getSpeedIncreaseTicksLeft(
unsigned int category) const OVERRIDE;
362 virtual
float getSpeed() const OVERRIDE {
return m_speed; }
364 virtual float getCurrentMaxSpeed() const OVERRIDE;
368 virtual
void setSpeed(
float s) OVERRIDE { m_speed = s; }
381 virtual float getTimeFullSteer(
float steer)
const OVERRIDE;
383 virtual float getSpeedForTurnRadius(
float radius)
const OVERRIDE;
385 virtual float getMaxSteerAngle(
float speed)
const;
399 virtual float getEnergy() const OVERRIDE {
return m_collected_energy; }
402 virtual void setEnergy(
float val) OVERRIDE { m_collected_energy = val; }
413 virtual void setPowerup (PowerupManager::PowerupType t,
int n) OVERRIDE;
416 virtual void setLastUsedPowerup (PowerupManager::PowerupType t);
427 return m_last_used_powerup;
431 virtual int getNumPowerup() const OVERRIDE;
437 virtual
void setInvulnerableTicks(
int ticks) OVERRIDE
442 m_invulnerable_ticks = ticks;
446 virtual bool isInvulnerable() const OVERRIDE {
return m_invulnerable_ticks > 0; }
450 {
return m_view_blocked_by_plunger; }
454 virtual void blockViewWithPlunger() OVERRIDE;
457 virtual
void setShieldTime(
float t) OVERRIDE;
460 virtual
bool isShielded() const OVERRIDE;
463 virtual
float getShieldTime() const OVERRIDE;
466 virtual
void decreaseShieldTime() OVERRIDE;
469 virtual
bool isSquashed() const OVERRIDE;
474 virtual
void setBoostAI (
bool boosted) OVERRIDE;
476 virtual
bool getBoostAI () const OVERRIDE;
479 virtual
Controller* getController() OVERRIDE {
return m_controller; }
494 virtual btTransform getAlignedTransform(
const float customPitch=-1) OVERRIDE;
497 const btTransform& getResetTransform()
const {
return m_reset_transform;}
500 virtual bool isOnGround() const OVERRIDE;
504 bool isNearGround() const;
508 virtual const
Vec3& getNormal() const OVERRIDE;
511 virtual const
Vec3& getPreviousXYZ() const OVERRIDE
512 {
return m_previous_xyz[m_xyz_history_size-1]; }
515 virtual const Vec3& getRecentPreviousXYZ() const OVERRIDE;
518 virtual const
float getRecentPreviousXYZTime() const OVERRIDE
519 {
return m_previous_xyz_times[m_xyz_history_size/5]; }
525 virtual bool isJumping() const OVERRIDE {
return m_is_jumping; }
536 virtual int getPosition() const OVERRIDE {
return m_race_position; }
548 const irr::video::SColor &getColor()
const;
555 virtual btQuaternion getVisualRotation() const OVERRIDE;
558 virtual const
SlipStream* getSlipstream() const OVERRIDE {
return m_slipstream.get(); }
564 virtual void setSlipstreamEffect(
float f) OVERRIDE;
568 virtual void eliminate() OVERRIDE;
570 virtual
void setOnScreenText(const core::stringw& text) OVERRIDE;
573 virtual
bool getRaceResult() const OVERRIDE {
return m_race_result; }
576 void setRaceResult();
583 virtual void playSound(
SFXBuffer* buffer) OVERRIDE;
585 virtual bool isVisible() const OVERRIDE;
588 virtual
void showStarEffect(
float t) OVERRIDE;
590 virtual
Stars* getStarsEffect() const OVERRIDE
591 {
return m_stars_effect.get(); }
596 {
return m_network_confirmed_finish_ticks; }
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: kart_data.hpp:12
Definition: kart_gfx.hpp:40
Definition: kart_rewinder.hpp:30
The main kart class.
Definition: kart.hpp:69
std::unique_ptr< SlipStream > m_slipstream
Handles all slipstreaming.
Definition: kart.hpp:143
virtual float getMaxSteerAngle() const OVERRIDE
Returns the maximum steering angle for this kart, which depends on the speed.
Definition: kart.hpp:375
float m_default_suspension_force
For changeKart.
Definition: kart.hpp:246
void updateSpeed()
Updates the local speed based on the current physical velocity.
Definition: kart.cpp:1797
virtual const Vec3 & getFrontXYZ() const OVERRIDE
Returns the coordinates of the front of the kart.
Definition: kart.hpp:489
virtual PowerupManager::PowerupType getLastUsedPowerup() OVERRIDE
Returns the last used powerup.
Definition: kart.hpp:425
btTransform m_reset_transform
Reset position.
Definition: kart.hpp:249
bool m_is_jumping
Is time flying activated.
Definition: kart.hpp:99
MaxSpeed * m_max_speed
Handles speed increase and capping due to powerup, terrain, ...
Definition: kart.hpp:110
std::unique_ptr< Shadow > m_shadow
The shadow of a kart.
Definition: kart.hpp:133
virtual const Material * getMaterial() const OVERRIDE
Returns the current material the kart is on.
Definition: kart.cpp:524
const Material * m_last_sound_material
The material for which the last sound effect was played.
Definition: kart.hpp:260
bool isFlying() const
For debugging only: check if a kart is flying.
Definition: kart.hpp:522
virtual int getBlockedByPlungerTicks() const OVERRIDE
Returns true if the kart has a plunger attached to its face.
Definition: kart.hpp:449
Powerup * m_powerup
Handles the powerup of a kart.
Definition: kart.hpp:116
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 Skidding * getSkidding() OVERRIDE
Returns the skidding object for this kart (which can be used to query skidding related values) - non-...
Definition: kart.hpp:393
std::unique_ptr< Stars > m_stars_effect
For stars rotating around head effect.
Definition: kart.hpp:126
virtual btKart * getVehicle() const OVERRIDE
Returns the bullet vehicle which represents this kart.
Definition: kart.hpp:553
virtual KartGFX * getKartGFX() OVERRIDE
Returns a pointer to this kart's graphical effects.
Definition: kart.hpp:533
int m_race_position
Current race position (1-num_karts).
Definition: kart.hpp:190
virtual void kartIsInRestNow() OVERRIDE
Computes the transform of the graphical kart chasses with regards to the physical chassis.
Definition: kart.cpp:3086
void updateEngineSFX(float dt)
Adjust the engine sound effect depending on the speed of the kart.
Definition: kart.cpp:2668
void handleMaterialGFX(float dt)
Handles material specific GFX, mostly particle effects.
Definition: kart.cpp:2031
std::vector< Vec3 > m_previous_xyz
The coordinates of the XYZ_HISTORY_SIZE previous positions.
Definition: kart.hpp:90
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:389
bool m_bubblegum_torque_sign
The sign of torque to apply after hitting a bubble gum.
Definition: kart.hpp:102
virtual bool isEliminated() const OVERRIDE
Returns true if the kart is eliminated.
Definition: kart.hpp:566
virtual void setEnergy(float val) OVERRIDE
Sets the energy the kart has collected.
Definition: kart.hpp:402
float m_last_factor_engine_sound
For smoothing engine sound.
Definition: kart.hpp:243
int8_t m_min_nitro_ticks
To prevent using nitro in too short bursts.
Definition: kart.hpp:213
virtual const Powerup * getPowerup() const OVERRIDE
Returns the current powerup.
Definition: kart.hpp:419
void playCrashSFX(const Material *m, AbstractKart *k)
Common code used when a kart or a material was hit.
Definition: kart.cpp:2457
float applyAirFriction(float engine_power)
Reduces the engine power according to speed.
Definition: kart.cpp:2716
void updatePhysics(int ticks)
Updates the physics for this kart: computing the driving force, set steering, handles skidding,...
Definition: kart.cpp:2596
float getActualWheelForce()
Simulates gears by adjusting the force of the engine.
Definition: kart.cpp:1204
PowerupManager::PowerupType m_last_used_powerup
Remember the last used powerup type of a kart for AI purposes.
Definition: kart.hpp:172
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:195
void updateNitro(int ticks)
Updates the current nitro status.
Definition: kart.cpp:2230
virtual Powerup * getPowerup() OVERRIDE
Returns the current powerup.
Definition: kart.hpp:422
Controller * m_controller
The main controller of this object, used for driving.
Definition: kart.hpp:164
virtual int getInitialPosition() const OVERRIDE
Returns the initial position of this kart.
Definition: kart.hpp:539
virtual int getPosition() const OVERRIDE
Returns the current position of this kart in the race.
Definition: kart.hpp:536
virtual float getSpeed() const OVERRIDE
Returns the speed of the kart in meters/second.
Definition: kart.hpp:362
bool m_flying
True if kart is flying (for debug purposes only).
Definition: kart.hpp:175
void updateSliding()
Handles sliding, i.e.
Definition: kart.cpp:2884
std::vector< float > m_previous_xyz_times
The times at which the previous positions occured.
Definition: kart.hpp:94
void updateFlying()
Adjusts kart translation if the kart is flying (in debug mode).
Definition: kart.cpp:2941
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
void handleMaterialSFX()
Plays any terrain specific sound effect.
Definition: kart.cpp:1933
Controller * m_saved_controller
This saves the original controller when the end controller is used.
Definition: kart.hpp:169
int16_t m_invulnerable_ticks
Time a kart is invulnerable.
Definition: kart.hpp:200
TerrainInfo * m_terrain_info
Stores information about the terrain the kart is on.
Definition: kart.hpp:113
int getNetworkConfirmedFinishTicks() const OVERRIDE
Return the confirmed finish ticks (sent by the server) indicating that this kart has really finished ...
Definition: kart.hpp:595
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:2985
int16_t m_bubblegum_ticks
If > 0 then bubble gum effect is on.
Definition: kart.hpp:203
float m_max_gear_rpm
Maximum engine rpm's for the current gear.
Definition: kart.hpp:193
SFXBase * m_terrain_sound
Sound to be played depending on terrain.
Definition: kart.hpp:257
virtual float getFinishTime() const OVERRIDE
Returns the finished time for a kart.
Definition: kart.hpp:542
virtual bool isInvulnerable() const OVERRIDE
Returns if the kart is invulnerable.
Definition: kart.hpp:446
float m_current_lean
Current leaning of the kart.
Definition: kart.hpp:210
bool m_boosted_ai
True if the kart has been selected to have a boosted ai.
Definition: kart.hpp:219
virtual bool isJumping() const OVERRIDE
Returns whether this kart is jumping.
Definition: kart.hpp:525
bool m_has_caught_nolok_bubblegum
Set when hitting bubblegum.
Definition: kart.hpp:178
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:872
float m_collected_energy
The amount of energy collected with nitro cans.
Definition: kart.hpp:227
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
bool m_fire_clicked
True if fire button was pushed and not released.
Definition: kart.hpp:216
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 t...
Definition: kart.hpp:207
virtual float getEnergy() const OVERRIDE
Returns the remaining collected energy.
Definition: kart.hpp:399
bool m_eliminated
True if the kart is eliminated.
Definition: kart.hpp:184
std::unique_ptr< Skidding > m_skidding
This object handles all skidding.
Definition: kart.hpp:123
ParticleEmitter * m_collision_particles
For collisions.
Definition: kart.hpp:159
virtual bool isGhostKart() const OVERRIDE
Returns whether this kart is a ghost (replay) kart.
Definition: kart.hpp:579
std::unique_ptr< KartGFX > m_kart_gfx
All particle effects.
Definition: kart.hpp:140
int m_initial_position
Initial rank of the kart.
Definition: kart.hpp:187
void updateEnginePowerAndBrakes(int ticks)
Sets the engine power.
Definition: kart.cpp:2757
std::unique_ptr< SkidMarks > m_skidmarks
The skidmarks object for this kart.
Definition: kart.hpp:136
virtual bool hasFinishedRace() const OVERRIDE
Returns true if this kart has finished the race.
Definition: kart.hpp:545
float m_speed
The current speed (i.e.
Definition: kart.hpp:240
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:407
virtual SlipStream * getSlipstream() OVERRIDE
Returns the slipstream object of this kart.
Definition: kart.hpp:561
const Controller * getController() const OVERRIDE
Returns the controller of this kart (const version).
Definition: kart.hpp:482
float m_graphical_y_offset
Offset of the graphical kart chassis from the physical chassis.
Definition: kart.hpp:76
virtual const TerrainInfo * getTerrainInfo() const OVERRIDE
Returns the terrain info oject.
Definition: kart.hpp:528
bool m_race_result
True if the kart wins, false otherwise.
Definition: kart.hpp:181
int m_brake_ticks
How long the brake key has been pressed - the longer the harder the kart will brake.
Definition: kart.hpp:197
Definition: material.hpp:48
Definition: max_speed.hpp:31
manages smoke particle effects
Definition: particle_emitter.hpp:42
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:242
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.: the normal,...
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
void changeKart(int idKart, std::string *new_id)
Gets the maximum speed (velocity) a kart can reach.
Definition: script_kart.cpp:144
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:42