SuperTuxKart
Public Types | Public Member Functions | Private Attributes | List of all members
CheckGoal Class Reference

Implements a simple checkline that will score a point when the soccer ball crosses it. More...

#include <check_goal.hpp>

Inheritance diagram for CheckGoal:
Inheritance graph
[legend]

Public Types

enum  PointLocation { POINT_FIRST, POINT_CENTER, POINT_LAST }
 Used by AIs to test whether the ball is likely to goal. More...
 
- Public Types inherited from CheckStructure
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

 CheckGoal (const XMLNode &node, unsigned int index)
 Constructor for a check goal line. More...
 
virtual void update (float dt) OVERRIDE
 Checks the soccer balls to see if they crossed the line and trigger the goal accordingly.
 
virtual void trigger (unsigned int kart_index) OVERRIDE
 Called when the goal line is triggered. More...
 
virtual bool isTriggered (const Vec3 &old_pos, const Vec3 &new_pos, int indx) OVERRIDE
 True if going from old_pos to new_pos crosses this checkline. More...
 
virtual void reset (const Track &track) OVERRIDE
 Initialises the 'previous positions' of all karts with the start position defined for this track. More...
 
bool getTeam () const
 
const Vec3getPoint (PointLocation point) const
 
- Public Member Functions inherited from CheckStructure
 CheckStructure (const XMLNode &node, unsigned int index)
 
virtual void resetAfterKartMove (unsigned int kart_index)
 
virtual void resetAfterRewind (unsigned int kart_index)
 
virtual void changeDebugColor (bool is_active)
 
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
 

Private Attributes

Vec3 m_previous_ball_position
 Previois ball position. More...
 
bool m_first_goal
 Which team is this goal for?
 
core::line2df m_line
 The line that is tested for being crossed. More...
 
Vec3 m_p1
 Used by AIs to test whether the ball is likely to goal. More...
 
Vec3 m_p2
 
Vec3 m_p3
 

Additional Inherited Members

- Protected Member Functions inherited from CheckStructure
 CheckStructure (unsigned index)
 For CheckTrigger or CheckCylinder.
 
- Protected Attributes inherited from CheckStructure
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...
 

Detailed Description

Implements a simple checkline that will score a point when the soccer ball crosses it.

Member Enumeration Documentation

◆ PointLocation

Used by AIs to test whether the ball is likely to goal.

Constructor & Destructor Documentation

◆ CheckGoal()

CheckGoal::CheckGoal ( const XMLNode node,
unsigned int  index 
)

Constructor for a check goal line.

Parameters
nodeXML node containing the parameters for this goal line.
indexIndex of this check structure in the check manager.

Member Function Documentation

◆ isTriggered()

bool CheckGoal::isTriggered ( const Vec3 old_pos,
const Vec3 new_pos,
int  indx 
)
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.

Implements CheckStructure.

◆ reset()

void CheckGoal::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 from CheckStructure.

◆ trigger()

void CheckGoal::trigger ( unsigned int  i)
virtual

Called when the goal line is triggered.

Input any integer for i to use

Reimplemented from CheckStructure.

Member Data Documentation

◆ m_line

core::line2df CheckGoal::m_line
private

The line that is tested for being crossed.

◆ m_p1

Vec3 CheckGoal::m_p1
private

Used by AIs to test whether the ball is likely to goal.

◆ m_previous_ball_position

Vec3 CheckGoal::m_previous_ball_position
private

Previois ball position.


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