SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
GhostController Class Reference

A class for Ghost controller. More...

#include <ghost_controller.hpp>

Inheritance diagram for GhostController:
Inheritance graph
[legend]

Public Member Functions

 GhostController (AbstractKart *kart, core::stringw display_name)
 
virtual void reset () OVERRIDE
 
virtual void update (int ticks) OVERRIDE
 
virtual bool disableSlipstreamBonus () const OVERRIDE
 
virtual void crashed (const Material *m) OVERRIDE
 
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.
 
virtual void collectedItem (const ItemState &item, float previous_energy=0) OVERRIDE
 
virtual void setPosition (int p) OVERRIDE
 
virtual bool isPlayerController () const OVERRIDE
 This function checks if this player is not an AI, i.e.
 
virtual bool isLocalPlayerController () const OVERRIDE
 This function checks if this is a local player.
 
virtual bool action (PlayerAction action, int value, bool dry_run=false) OVERRIDE
 Default: ignore actions.
 
virtual void skidBonusTriggered () OVERRIDE
 
virtual void newLap (int lap) OVERRIDE
 Callback whenever a new lap is triggered.
 
virtual bool saveState (BareNetworkString *buffer) const OVERRIDE
 
virtual void rewindTo (BareNetworkString *buffer) OVERRIDE
 
void addReplayTime (float time)
 
bool isReplayEnd () const
 
float getReplayDelta () const
 
unsigned int getCurrentReplayIndex () const
 
float getTimeAtIndex (unsigned int index) const
 
core::stringw getName (bool include_handicap_string=true) const OVERRIDE
 Return the display name; if not set, use default display name (kart name)
 
- Public Member Functions inherited from Controller
 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.
 

Private Attributes

unsigned int m_current_index
 Pointer to the last index in m_all_times that is smaller than the current world time.
 
float m_current_time
 The current world time.
 
core::stringw m_display_name
 Player name of the ghost kart.
 
std::vector< float > m_all_times
 The list of the times at which the events of kart were reached.
 

Additional Inherited Members

- Protected Attributes inherited from Controller
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

A class for Ghost controller.

Member Function Documentation

◆ action()

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

Default: ignore actions.

Only PlayerController get them.

Implements Controller.

◆ collectedItem()

virtual void GhostController::collectedItem ( const ItemState item,
float  previous_energy = 0 
)
inlinevirtual

Implements Controller.

◆ crashed() [1/2]

virtual void GhostController::crashed ( const AbstractKart k)
inlinevirtual

Implements Controller.

◆ crashed() [2/2]

virtual void GhostController::crashed ( const Material m)
inlinevirtual

Implements Controller.

◆ disableSlipstreamBonus()

virtual bool GhostController::disableSlipstreamBonus ( ) const
inlinevirtual

Implements Controller.

◆ finishedRace()

virtual void GhostController::finishedRace ( float  time)
inlinevirtual

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

Implements Controller.

◆ getName()

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

Return the display name; if not set, use default display name (kart name)

Reimplemented from Controller.

◆ handleZipper()

virtual void GhostController::handleZipper ( bool  play_sound)
inlinevirtual

Implements Controller.

◆ isLocalPlayerController()

virtual bool GhostController::isLocalPlayerController ( ) const
inlinevirtual

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.

Implements Controller.

◆ isPlayerController()

virtual bool GhostController::isPlayerController ( ) const
inlinevirtual

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.

Implements Controller.

◆ newLap()

virtual void GhostController::newLap ( int  lap)
inlinevirtual

Callback whenever a new lap is triggered.

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

Implements Controller.

◆ reset()

void GhostController::reset ( )
virtual

Implements Controller.

◆ rewindTo()

virtual void GhostController::rewindTo ( BareNetworkString buffer)
inlinevirtual

Implements Controller.

◆ saveState()

virtual bool GhostController::saveState ( BareNetworkString buffer) const
inlinevirtual

Implements Controller.

◆ setPosition()

virtual void GhostController::setPosition ( int  p)
inlinevirtual

Implements Controller.

◆ skidBonusTriggered()

virtual void GhostController::skidBonusTriggered ( )
inlinevirtual

Implements Controller.

◆ update()

void GhostController::update ( int  ticks)
virtual

Implements Controller.


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