SuperTuxKart
Loading...
Searching...
No Matches
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.
 
virtual bool isPlayerController () const =0
 This function checks if this player is not an AI, i.e.
 
virtual bool disableSlipstreamBonus () const =0
 
virtual bool saveState (BareNetworkString *buffer) const =0
 
virtual void rewindTo (BareNetworkString *buffer)=0
 
virtual void rumble (float strength_low, float strength_high, uint16_t duration)
 
virtual void setControllerName (const std::string &name)
 Sets the controller name for this controller.
 
const std::string & getControllerName () const
 Returns the name of this controller.
 
virtual bool action (PlayerAction action, int value, bool dry_run=false)=0
 Default: ignore actions.
 
virtual void newLap (int lap)=0
 Callback whenever a new lap is triggered.
 
virtual void skidBonusTriggered ()=0
 
virtual void finishedRace (float time)=0
 Called whan this controller's kart finishes the last lap.
 
virtual KartControlgetControls ()
 Get a pointer on the kart controls.
 
void setControls (KartControl *kc)
 
virtual bool canGetAchievements () const
 Only local players can get achievements.
 
virtual core::stringw getName (bool include_handicap_string=true) const
 Display name of the controller.
 
AbstractKartgetKart () const
 Returns the kart controlled by this controller.
 

Protected Attributes

AbstractKartm_kart
 Pointer to the kart that is controlled by this controller.
 
KartControlm_controls
 A pointer to the main controller, from which the kart takes it commands.
 
std::string m_controller_name
 The name of the controller, mainly used for debugging purposes.
 

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 EndController, AIBaseController, GhostController, LocalPlayerController, and PlayerController.

◆ canGetAchievements()

virtual bool Controller::canGetAchievements ( ) const
inlinevirtual

Only local players can get achievements.

Reimplemented in EndController, LocalPlayerController, and NetworkPlayerController.

◆ collectedItem()

virtual void Controller::collectedItem ( const ItemState item,
float  previous_energy = 0 
)
pure virtual

Implemented in LocalPlayerController.

◆ crashed() [1/2]

virtual void Controller::crashed ( const AbstractKart k)
pure virtual

Implemented in SpareTireAI.

◆ crashed() [2/2]

virtual void Controller::crashed ( const Material m)
pure virtual

Implemented in AIBaseController.

◆ disableSlipstreamBonus()

virtual bool Controller::disableSlipstreamBonus ( ) const
pure virtual

Implemented in AIBaseController, and PlayerController.

◆ finishedRace()

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

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

Implemented in AIBaseController, GhostController, LocalPlayerController, and PlayerController.

◆ 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, LocalPlayerController, and PlayerController.

◆ handleZipper()

virtual void Controller::handleZipper ( bool  play_sound)
pure virtual

◆ 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, GhostController, LocalPlayerController, NetworkAIController, NetworkPlayerController, and PlayerController.

◆ 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, GhostController, LocalPlayerController, 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 AIBaseLapController, EndController, ArenaAI, GhostController, and PlayerController.

◆ reset()

virtual void Controller::reset ( )
pure virtual

◆ setControllerName()

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

Sets the controller name for this controller.

Reimplemented in AIBaseController.

◆ setPosition()

virtual void Controller::setPosition ( int  p)
pure virtual

◆ skidBonusTriggered()

virtual void Controller::skidBonusTriggered ( )
pure virtual

Implemented in PlayerController.

◆ update()

virtual void Controller::update ( int  ticks)
pure virtual

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