SuperTuxKart
Public Member Functions | Protected Attributes | List of all members
Controller Class Referenceabstract

This is the base class for kart controller - that can be a player or a a robot. More...

#include <controller.hpp>

Inheritance diagram for Controller:
Inheritance graph
[legend]

Public Member Functions

 Controller (AbstractKart *kart)
 Constructor, saves the kart pointer and a pointer to the KartControl of the kart.
 
virtual void reset ()=0
 
virtual void update (int ticks)=0
 
virtual void handleZipper (bool play_sound)=0
 
virtual void collectedItem (const ItemState &item, float previous_energy=0)=0
 
virtual void crashed (const AbstractKart *k)=0
 
virtual void crashed (const Material *m)=0
 
virtual void setPosition (int p)=0
 
virtual bool isLocalPlayerController () const =0
 This function checks if this is a local player. More...
 
virtual bool isPlayerController () const =0
 This function checks if this player is not an AI, i.e. More...
 
virtual bool disableSlipstreamBonus () const =0
 
virtual bool saveState (BareNetworkString *buffer) const =0
 
virtual void rewindTo (BareNetworkString *buffer)=0
 
virtual void setControllerName (const std::string &name)
 Sets the controller name for this controller. More...
 
const std::string & getControllerName () const
 Returns the name of this controller. More...
 
virtual bool action (PlayerAction action, int value, bool dry_run=false)=0
 Default: ignore actions. More...
 
virtual void newLap (int lap)=0
 Callback whenever a new lap is triggered. More...
 
virtual void skidBonusTriggered ()=0
 
virtual void finishedRace (float time)=0
 Called whan this controller's kart finishes the last lap. More...
 
virtual KartControlgetControls ()
 Get a pointer on the kart controls. More...
 
void setControls (KartControl *kc)
 
virtual bool canGetAchievements () const
 Only local players can get achievements. More...
 
virtual core::stringw getName (bool include_handicap_string=true) const
 Display name of the controller. More...
 
AbstractKartgetKart () const
 Returns the kart controlled by this controller. More...
 

Protected Attributes

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...
 

Detailed Description

This is the base class for kart controller - that can be a player or a a robot.

Member Function Documentation

◆ action()

virtual bool Controller::action ( PlayerAction  action,
int  value,
bool  dry_run = false 
)
pure virtual

Default: ignore actions.

Only PlayerController get them.

Implemented in AIBaseController, EndController, LocalPlayerController, GhostController, and PlayerController.

◆ canGetAchievements()

virtual bool Controller::canGetAchievements ( ) const
inlinevirtual

Only local players can get achievements.

Reimplemented in EndController, LocalPlayerController, and NetworkPlayerController.

◆ finishedRace()

virtual void Controller::finishedRace ( float  time)
pure virtual

Called whan this controller's kart finishes the last lap.

Implemented in AIBaseController, PlayerController, LocalPlayerController, and GhostController.

◆ getControllerName()

const std::string& Controller::getControllerName ( ) const
inline

Returns the name of this controller.

◆ getControls()

virtual KartControl* Controller::getControls ( )
inlinevirtual

Get a pointer on the kart controls.

◆ getKart()

AbstractKart* Controller::getKart ( ) const
inline

Returns the kart controlled by this controller.

◆ getName()

core::stringw Controller::getName ( bool  include_handicap_string = true) const
virtual

Display name of the controller.

Defaults to kart name; overriden by controller classes (such as player controllers) to display username.

Reimplemented in EndController, GhostController, PlayerController, and LocalPlayerController.

◆ isLocalPlayerController()

virtual bool Controller::isLocalPlayerController ( ) const
pure virtual

This function checks if this is a local player.

A local player will get special graphical effects enabled, has a camera, and sound effects will be played with normal volume.

Implemented in EndController, AIBaseController, LocalPlayerController, GhostController, PlayerController, and NetworkPlayerController.

◆ isPlayerController()

virtual bool Controller::isPlayerController ( ) const
pure virtual

This function checks if this player is not an AI, i.e.

it is either a a local or a remote/networked player. This is tested e.g. by the AI for rubber-banding.

Implemented in EndController, AIBaseController, LocalPlayerController, GhostController, and PlayerController.

◆ newLap()

virtual void Controller::newLap ( int  lap)
pure virtual

Callback whenever a new lap is triggered.

Used by the AI to trigger a recomputation of the way to use.

Implemented in ArenaAI, EndController, PlayerController, GhostController, and AIBaseLapController.

◆ setControllerName()

virtual void Controller::setControllerName ( const std::string &  name)
inlinevirtual

Sets the controller name for this controller.

Reimplemented in AIBaseController.

Member Data Documentation

◆ m_controller_name

std::string Controller::m_controller_name
protected

The name of the controller, mainly used for debugging purposes.

◆ m_controls

KartControl* Controller::m_controls
protected

A pointer to the main controller, from which the kart takes it commands.

◆ m_kart

AbstractKart* Controller::m_kart
protected

Pointer to the kart that is controlled by this controller.


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