SuperTuxKart
|
Virtual base class for a check structure. More...
#include <check_structure.hpp>
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. | |
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. | |
virtual void | trigger (unsigned int kart_index) |
Is called when this check structure is triggered. | |
virtual void | reset (const Track &track) |
Initialises the 'previous positions' of all karts with the start position defined for this track. | |
CheckType | getType () const |
Returns the type of this check structure. | |
void | addSuccessor (unsigned int i) |
Adds the index of a successor check structure which will get triggered by this check structure. | |
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 |
virtual CheckStructure * | clone ()=0 |
Clone to child process for server usage (atm no sound or scripting). | |
Protected Member Functions | |
CheckStructure () | |
For CheckTrigger or CheckCylinder. | |
Protected Attributes | |
AlignedArray< Vec3 > | m_previous_position |
Stores the previous position of all karts. | |
std::vector< bool > | m_is_active |
Stores if this check structure is active (for a given kart). | |
bool | m_active_at_reset |
True if this check structure should be activated at a reset. | |
unsigned int | m_index |
Stores the index of this check structure. | |
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. | |
Private Attributes | |
CheckType | m_check_type |
The type of this checkline. | |
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). | |
std::vector< int > | m_same_group |
A list of check lines that should be activated/switched when this lines is activated/switched. | |
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.
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.
|
inlinevirtual |
Reimplemented in CheckCannon.
|
private |
Changes the status (active/inactive) of all check structures contained in the index list indices.
indices | List of index of check structures in the CheckManager that are to be changed. |
int | kart_index For which the status should be changed. |
change_state | How to change the state (active, deactivate, toggle). |
|
pure virtual |
Clone to child process for server usage (atm no sound or scripting).
Implemented in CheckCylinder, CheckSphere, CheckCannon, CheckGoal, CheckLap, CheckLine, and CheckTrigger.
|
pure virtual |
True if going from old_pos to new_pos crosses this checkline.
This function is called from update (of the checkline structure).
old_pos | Position in previous frame. |
new_pos | Position in current frame. |
indx | Index of the kart, can be used to store kart specific additional data. |
Implemented in CheckGoal, CheckLap, CheckLine, CheckCylinder, CheckSphere, and CheckTrigger.
|
virtual |
|
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.
|
virtual |
Updates all check structures.
Called one per time step.
dt | Time since last call. |
Reimplemented in CheckCannon, and CheckGoal.
|
protected |
Stores the index of this check structure.
This is only used for debugging (use –check-debug option).
|
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.
|
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.