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

This class implements a check point like item, but used only for scripting or sound trigger. More...

#include <check_trigger.hpp>

Inheritance diagram for CheckTrigger:
Inheritance graph
[legend]

Public Member Functions

 CheckTrigger (const Vec3 &center, float distance, std::function< void(int)> triggering_function)
 Constructor for a check trigger. More...
 
virtual bool isTriggered (const Vec3 &old_pos, const Vec3 &new_pos, int kart_id) OVERRIDE
 Copied from item state.
 
virtual void trigger (unsigned int kart_index) OVERRIDE
 Is called when this check structure is triggered. More...
 
- Public Member Functions inherited from CheckStructure
 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 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
 

Private Attributes

const Vec3 m_center
 Center of the trigger. More...
 
const float m_distance2
 Squared of the triggering distance. More...
 
const std::function< void(int)> m_triggering_function
 Function to call when triggered. More...
 
uint64_t m_last_triggered_time
 Time since last trigger, if any triggering between 2 seconds ignored (like items). More...
 

Additional Inherited Members

- 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...
 
- 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

This class implements a check point like item, but used only for scripting or sound trigger.

Constructor & Destructor Documentation

◆ CheckTrigger()

CheckTrigger::CheckTrigger ( const Vec3 center,
float  distance,
std::function< void(int)>  triggering_function 
)

Constructor for a check trigger.

Parameters
centerCenter point of this trigger
distanceKart within it between center will trigger
triggering_functioncallback function to be used when triggered

Member Function Documentation

◆ trigger()

virtual void CheckTrigger::trigger ( unsigned int  kart_index)
inlinevirtual

Is called when this check structure is triggered.

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

Reimplemented from CheckStructure.

Member Data Documentation

◆ m_center

const Vec3 CheckTrigger::m_center
private

Center of the trigger.

◆ m_distance2

const float CheckTrigger::m_distance2
private

Squared of the triggering distance.

◆ m_last_triggered_time

uint64_t CheckTrigger::m_last_triggered_time
private

Time since last trigger, if any triggering between 2 seconds ignored (like items).

◆ m_triggering_function

const std::function<void(int)> CheckTrigger::m_triggering_function
private

Function to call when triggered.


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