SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EndController Class Reference
Inheritance diagram for EndController:
Inheritance graph
[legend]

Public Member Functions

 EndController (AbstractKart *kart, Controller *prev_controller)
 
 ~EndController ()
 The destructor deletes the shared TrackInfo objects if no more EndController instances are around.
 
virtual void update (int ticks)
 Updates the ai base controller each time step. More...
 
virtual void reset ()
 
virtual bool action (PlayerAction action, int value, bool dry_run=false)
 The end controller must forward 'fire' presses to the race gui.
 
virtual void newLap (int lap)
 Callback when a new lap is triggered. More...
 
virtual bool canGetAchievements () const
 Only local players can get achievements. More...
 
virtual bool isPlayerController () const
 Returns if the original controller of the kart was a player controller. More...
 
virtual bool isLocalPlayerController () const
 Returns if the original controller of the kart was a local player controller. More...
 
core::stringw getName (bool include_handicap_string=true) const
 Returns the name of the previous controller (which has the right player name associated). More...
 
- Public Member Functions inherited from AIBaseLapController
 AIBaseLapController (AbstractKart *kart)
 This is the base class for all AIs. More...
 
- Public Member Functions inherited from AIBaseController
 AIBaseController (AbstractKart *kart)
 
virtual bool disableSlipstreamBonus () const OVERRIDE
 Certain AI levels will not receive a slipstream bonus in order to be not as hard.
 
virtual void crashed (const Material *m) OVERRIDE
 This is called when the kart crashed with the terrain. More...
 
virtual void crashed (const AbstractKart *k) OVERRIDE
 
virtual void handleZipper (bool play_sound) OVERRIDE
 
virtual void finishedRace (float time) OVERRIDE
 Called whan this controller's kart finishes the last lap. More...
 
virtual void collectedItem (const ItemState &item, float previous_energy=0) OVERRIDE
 
virtual void setPosition (int p) OVERRIDE
 
virtual void skidBonusTriggered () OVERRIDE
 
virtual bool saveState (BareNetworkString *buffer) const OVERRIDE
 
virtual void rewindTo (BareNetworkString *buffer) OVERRIDE
 
void setNetworkAI (bool val)
 
- Public Member Functions inherited from Controller
 Controller (AbstractKart *kart)
 Constructor, saves the kart pointer and a pointer to the KartControl of the kart.
 
const std::string & getControllerName () const
 Returns the name of this controller. More...
 
virtual KartControlgetControls ()
 Get a pointer on the kart controls. More...
 
void setControls (KartControl *kc)
 
AbstractKartgetKart () const
 Returns the kart controlled by this controller. More...
 

Private Member Functions

void handleSteering (float dt)
 
void handleRescue (const float DELTA)
 
void checkCrashes (const int STEPS, const Vec3 &pos)
 
void findNonCrashingPoint (Vec3 *result)
 Find the sector that at the longest distance from the kart, that can be driven to without crashing with the track, then find towards which of the two edges of the track is closest to the next curve after wards, and return the position of that edge.
 
int calcSteps ()
 calc_steps() divides the velocity vector by the lenght of the kart, and gets the number of steps to use for the sight line of the kart. More...
 
virtual bool canSkid (float steer_fraction)
 Return true if AI can skid now. More...
 

Private Attributes

bool m_was_player_controller
 Stores the type of the previous controller. More...
 
int m_min_steps
 
float m_max_handicap_accel
 
float m_crash_time
 
float m_time_since_stuck
 
Controllerm_previous_controller
 Stores a pointer to the original controller. More...
 
irr::scene::ISceneNode * m_debug_sphere
 For debugging purpose: a sphere indicating where the AI is targeting at. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AIBaseController
static void enableDebug ()
 
static void setTestAI (int n)
 
static int getTestAI ()
 
- Protected Member Functions inherited from AIBaseLapController
virtual unsigned int getNextSector (unsigned int index)
 Returns the next sector of the given sector index. More...
 
float steerToAngle (const unsigned int sector, const float angle)
 This function steers towards a given angle. More...
 
void computePath ()
 Computes a path for the AI to follow. More...
 
virtual void raceFinished ()
 Nothing special to do when the race is finished. More...
 
- Protected Member Functions inherited from AIBaseController
void setControllerName (const std::string &name) OVERRIDE
 In debug mode when the user specified –ai-debug on the command line set the name of the controller as on-screen text, so that the different AI controllers can be distinguished. More...
 
float steerToPoint (const Vec3 &point)
 Computes the steering angle to reach a certain point. More...
 
float normalizeAngle (float angle)
 Normalises an angle to be between -pi and _ pi. More...
 
bool isStuck () const
 This can be called to detect if the kart is stuck (i.e. More...
 
void determineTurnRadius (const Vec3 &end, Vec3 *center, float *radius) const
 Determine the center point and radius of a circle given two points on the circle and the tangent at the first point. More...
 
virtual void setSteering (float angle, float dt)
 Converts the steering angle to a lr steering in the range of -1 to 1. More...
 
- Protected Attributes inherited from AIBaseLapController
int m_track_node
 The current node the kart is on. More...
 
LinearWorldm_world
 Keep a pointer to world. More...
 
std::vector< int > m_successor_index
 Which of the successors of a node was selected by the AI. More...
 
std::vector< int > m_next_node_index
 For each node in the graph this list contains the chosen next node. More...
 
std::vector< std::vector< int > > m_all_look_aheads
 For each graph node this list contains a list of the next X graph nodes. More...
 
- Protected Attributes inherited from AIBaseController
bool m_enabled_network_ai
 
float m_kart_length
 Length of the kart, storing it here saves many function calls. More...
 
float m_kart_width
 Cache width of kart. More...
 
Trackm_track
 Keep a pointer to the track to reduce calls.
 
const AIPropertiesm_ai_properties
 A pointer to the AI properties for this kart. More...
 
- Protected Attributes inherited from Controller
AbstractKartm_kart
 Pointer to the kart that is controlled by this controller. More...
 
KartControlm_controls
 A pointer to the main controller, from which the kart takes it commands. More...
 
std::string m_controller_name
 The name of the controller, mainly used for debugging purposes. More...
 
- Static Protected Attributes inherited from AIBaseController
static bool m_ai_debug = false
 
static int m_test_ai = 0
 Stores the '–test-ai=n' command line parameter: It indicates which fraction of the AIs are going to be the test AI: 1 means only to use the TestAI, 2 means every second AI will be test etc. More...
 

Member Function Documentation

◆ calcSteps()

int EndController::calcSteps ( )
private

calc_steps() divides the velocity vector by the lenght of the kart, and gets the number of steps to use for the sight line of the kart.

The calling sequence guarantees that m_future_sector is not UNKNOWN.

◆ canGetAchievements()

virtual bool EndController::canGetAchievements ( ) const
inlinevirtual

Only local players can get achievements.

Reimplemented from Controller.

◆ canSkid()

virtual bool EndController::canSkid ( float  steer_fraction)
inlineprivatevirtual

Return true if AI can skid now.

Implements AIBaseController.

◆ getName()

core::stringw EndController::getName ( bool  include_handicap_string = true) const
inlinevirtual

Returns the name of the previous controller (which has the right player name associated).

Reimplemented from Controller.

◆ isLocalPlayerController()

virtual bool EndController::isLocalPlayerController ( ) const
inlinevirtual

Returns if the original controller of the kart was a local player controller.

This way e.g. highscores can still be assigned to the right player.

Reimplemented from AIBaseController.

◆ isPlayerController()

virtual bool EndController::isPlayerController ( ) const
inlinevirtual

Returns if the original controller of the kart was a player controller.

This way e.g. highscores can still be assigned to the right player.

Reimplemented from AIBaseController.

◆ newLap()

void EndController::newLap ( int  lap)
virtual

Callback when a new lap is triggered.

It is used to switch to the first end camera (which is esp. useful in fixing up end cameras in reverse mode, since otherwise the switch to the first end camera usually happens way too late)

Reimplemented from AIBaseLapController.

◆ update()

void EndController::update ( int  ticks)
virtual

Updates the ai base controller each time step.

Note that any calls to isStuck() must be done before update is called, since update will call AIBaseController::update() which will reset the isStuck flag!

Parameters
ticksNumber of physics time steps - should be 1.

Reimplemented from AIBaseLapController.

Member Data Documentation

◆ m_debug_sphere

irr::scene::ISceneNode* EndController::m_debug_sphere
private

For debugging purpose: a sphere indicating where the AI is targeting at.

◆ m_previous_controller

Controller* EndController::m_previous_controller
private

Stores a pointer to the original controller.

◆ m_was_player_controller

bool EndController::m_was_player_controller
private

Stores the type of the previous controller.

This is necessary so that after the end of race ths kart (and its results) can still be identified to be from a player kart.


The documentation for this class was generated from the following files: