SuperTuxKart
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
CheckStructure Class Referenceabstract

Virtual base class for a check structure. More...

#include <check_structure.hpp>

Inheritance diagram for CheckStructure:
Inheritance graph
[legend]

Public Types

enum  CheckType {
  CT_NEW_LAP, CT_ACTIVATE, CT_TOGGLE, CT_CANNON,
  CT_GOAL, CT_AMBIENT_SPHERE, CT_TRIGGER
}
 Different types of check structures: ACTIVATE: Activates another check structure (independent of the state that check structure is in) TOGGLE: Switches (inverts) the state of another check structure. More...
 

Public Member Functions

 CheckStructure (const XMLNode &node, unsigned int index)
 
virtual void update (float dt)
 Updates all check structures. More...
 
virtual void resetAfterKartMove (unsigned int kart_index)
 
virtual void resetAfterRewind (unsigned int kart_index)
 
virtual void changeDebugColor (bool is_active)
 
virtual bool isTriggered (const Vec3 &old_pos, const Vec3 &new_pos, int indx)=0
 True if going from old_pos to new_pos crosses this checkline. More...
 
virtual void trigger (unsigned int kart_index)
 Is called when this check structure is triggered. More...
 
virtual void reset (const Track &track)
 Initialises the 'previous positions' of all karts with the start position defined for this track. More...
 
CheckType getType () const
 Returns the type of this check structure. More...
 
void addSuccessor (unsigned int i)
 Adds the index of a successor check structure which will get triggered by this check structure. More...
 
virtual bool triggeringCheckline () const
 
virtual void saveCompleteState (BareNetworkString *bns)
 
virtual void restoreCompleteState (const BareNetworkString &b)
 
void saveIsActive (int kart_id, BareNetworkString *bns)
 
void restoreIsActive (int kart_id, const BareNetworkString &b)
 
int getIndex () const
 

Protected Member Functions

 CheckStructure (unsigned index)
 For CheckTrigger or CheckCylinder.
 

Protected Attributes

AlignedArray< Vec3m_previous_position
 Stores the previous position of all karts. More...
 
std::vector< bool > m_is_active
 Stores if this check structure is active (for a given kart). More...
 
bool m_active_at_reset
 True if this check structure should be activated at a reset. More...
 
unsigned int m_index
 Stores the index of this check structure. More...
 

Private Types

enum  ChangeState { CS_DEACTIVATE, CS_ACTIVATE, CS_TOGGLE }
 

Private Member Functions

void changeStatus (const std::vector< int > &indices, int kart_index, ChangeState change_state)
 Changes the status (active/inactive) of all check structures contained in the index list indices. More...
 

Private Attributes

CheckType m_check_type
 The type of this checkline. More...
 
std::vector< int > m_check_structures_to_change_state
 Contains the indices of the corresponding check structures that get their state changed (activated or switched). More...
 
std::vector< int > m_same_group
 A list of check lines that should be activated/switched when this lines is activated/switched. More...
 

Detailed Description

Virtual base class for a check structure.

A check structure has a certain ype: CT_NEW_LAP : triggering this check structure will cause a new lap to be counted. If this type is triggered, it will set itselt to inactive (which means it is not possible to count several laps by driving over the starting line forwardws and backwards) CT_ACTIVATE: Activates the specified other check structures. CT_TOGGLE: Toggles the specified other check structures (active to inactive and vice versa. CT_CANNON: A check line that 'shoots' the kart to a specified location. CT_GOAL: A goal line in soccer mode. Each check structure can be active or inactive. Only lap counters are initialised to be active, all other check structures are inactive.

Member Enumeration Documentation

◆ CheckType

Different types of check structures: ACTIVATE: Activates another check structure (independent of the state that check structure is in) TOGGLE: Switches (inverts) the state of another check structure.

NEW_LAP: On crossing a new lap is counted. CANNON: Causes the kart to be shot to a specified point. GOAL: Causes a point to be scored when a soccer ball crosses its line AMBIENT_SPHERE: Modifies the ambient color. TRIGGER: Run custom trigger function A combination of an activate and new_lap line are used to avoid shortcuts: a new_lap line is deactivated after crossing it, and you have to cross a corresponding activate structure to re-activate it, enabling you to count the lap again.

Member Function Documentation

◆ addSuccessor()

void CheckStructure::addSuccessor ( unsigned int  i)
inline

Adds the index of a successor check structure which will get triggered by this check structure.

◆ changeStatus()

void CheckStructure::changeStatus ( const std::vector< int > &  indices,
int  kart_index,
ChangeState  change_state 
)
private

Changes the status (active/inactive) of all check structures contained in the index list indices.

Parameters
indicesList of index of check structures in the CheckManager that are to be changed.
intkart_index For which the status should be changed.
change_stateHow to change the state (active, deactivate, toggle).

◆ getType()

CheckType CheckStructure::getType ( ) const
inline

Returns the type of this check structure.

◆ isTriggered()

virtual bool CheckStructure::isTriggered ( const Vec3 old_pos,
const Vec3 new_pos,
int  indx 
)
pure virtual

True if going from old_pos to new_pos crosses this checkline.

This function is called from update (of the checkline structure).

Parameters
old_posPosition in previous frame.
new_posPosition in current frame.
indxIndex of the kart, can be used to store kart specific additional data.

Implemented in CheckLine, CheckGoal, CheckCylinder, CheckTrigger, CheckSphere, and CheckLap.

◆ reset()

void CheckStructure::reset ( const Track track)
virtual

Initialises the 'previous positions' of all karts with the start position defined for this track.

Parameters
trackThe track object defining the start positions.

Reimplemented in CheckLine, CheckGoal, and CheckLap.

◆ trigger()

void CheckStructure::trigger ( unsigned int  kart_index)
virtual

Is called when this check structure is triggered.

This then can cause a lap to be counted, animation to be started etc.

Reimplemented in CheckCannon, CheckGoal, and CheckTrigger.

◆ update()

void CheckStructure::update ( float  dt)
virtual

Updates all check structures.

Called one per time step.

Parameters
dtTime since last call.

Reimplemented in CheckCannon, and CheckGoal.

Member Data Documentation

◆ m_active_at_reset

bool CheckStructure::m_active_at_reset
protected

True if this check structure should be activated at a reset.

◆ m_check_structures_to_change_state

std::vector<int> CheckStructure::m_check_structures_to_change_state
private

Contains the indices of the corresponding check structures that get their state changed (activated or switched).

◆ m_check_type

CheckType CheckStructure::m_check_type
private

The type of this checkline.

◆ m_index

unsigned int CheckStructure::m_index
protected

Stores the index of this check structure.

This is only used for debugging (use –check-debug option).

◆ m_is_active

std::vector<bool> CheckStructure::m_is_active
protected

Stores if this check structure is active (for a given kart).

◆ m_previous_position

AlignedArray<Vec3> CheckStructure::m_previous_position
protected

Stores the previous position of all karts.

This is needed to detect when e.g. a check point is reached the first time, or a checkline is crossed.

◆ m_same_group

std::vector<int> CheckStructure::m_same_group
private

A list of check lines that should be activated/switched when this lines is activated/switched.

I.e. can be used if more than one lap counting line is used to make sure they are all in synch, otherwise players could cross first one then the other lap counting line as huge shortcuts.


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