V-Gears 0
Free Final Fantasy VII engine.
EntityTrigger Class Reference

An entity trigger. More...

#include <EntityTrigger.h>

Collaboration diagram for EntityTrigger:

Public Member Functions

 EntityTrigger (const Ogre::String &name)
 Constructor. More...
 
virtual ~EntityTrigger ()
 Destructor. More...
 
void UpdateDebug ()
 Updates the trigger state with debug information. More...
 
const Ogre::String & GetName () const
 Retrieves the trigger name. More...
 
void SetEnabled (const bool enabled)
 Enables or disables the trigger. More...
 
bool IsEnabled () const
 Checks if the trigger is enabled. More...
 
void SetPoints (const Ogre::Vector3 &point1, const Ogre::Vector3 &point2)
 Sets the vertices of the line that acts as the trigger. More...
 
const Ogre::Vector3 & GetPoint1 () const
 Retrieves the first vertex of the line that acts as trigger. More...
 
const Ogre::Vector3 & GetPoint2 () const
 Retrieves the second vertex of the line that acts as trigger. More...
 
const bool CheckApproached ()
 Check if the line has been approached. More...
 
void SetApproached (const bool approached)
 Sets if the the playable entity has approached the line. More...
 
const bool CheckCrossed ()
 Check if the line has been crossed. More...
 
void SetCrossed (const bool crossed)
 Sets if the the playable entity has crossed the line. More...
 
const bool CheckNearSingleEventTriggered ()
 Checks if the on_near_once event has been fired. More...
 
void SetNearSingleEventTriggered (const bool triggered)
 Sets if the on_near_once have been triggered. More...
 
const int GetNearEventCooldown ()
 Checks if the cooldown that prevents caling the on_near event multiple times has ended. More...
 
void DecreaseNearEventCooldown ()
 Decreases the cooldown time required between calls to on_near event by one. More...
 
void ResetNearEventCooldown ()
 Resets the cooldown time required between calls to on_near event. More...
 
void ClearNearEventCooldown ()
 Sets the cooldown time required between calls to on_near event to 0. More...
 
void Clear ()
 Clears the proximity statuses and event triggering statuses. More...
 

Protected Attributes

Ogre::String name_
 The name of the trigger. More...
 
bool enabled_
 Indicates if the trigger is enabled or disabled. More...
 
Ogre::Vector3 point_1_
 One of the vertices of the trigger line. More...
 
Ogre::Vector3 point_2_
 One of the vertices of the trigger line. More...
 

Private Attributes

bool approached_
 Indicates if the playable entity has approached the line. More...
 
bool crossed_
 Indicates if the playable entity has crossed the line. More...
 
bool near_single_event_triggered_
 Indicates if the near_once event has been triggered. More...
 
int near_event_cooldown_
 Remaining frames to cooldown after triggering on_near event. More...
 

Static Private Attributes

static int NEAR_EVENT_COOLDOWN_FRAMES = 5
 Frames to cooldown after triggering on_near event. More...
 

Detailed Description

An entity trigger.

Constructor & Destructor Documentation

◆ EntityTrigger()

EntityTrigger::EntityTrigger ( const Ogre::String &  name)

Constructor.

Parameters
[in]nameThe trigger name.

◆ ~EntityTrigger()

EntityTrigger::~EntityTrigger ( )
virtual

Destructor.

Member Function Documentation

◆ CheckApproached()

const bool EntityTrigger::CheckApproached ( )

Check if the line has been approached.

Returns
True if the playable entity solid radius has collided with the line and has not existed yet, false otherwise.

◆ CheckCrossed()

const bool EntityTrigger::CheckCrossed ( )

Check if the line has been crossed.

Returns
True if the playable entity's center has collided with the line and has not existed yet (exit as in the line being outside the entity solid radius), false otherwise.

◆ CheckNearSingleEventTriggered()

const bool EntityTrigger::CheckNearSingleEventTriggered ( )

Checks if the on_near_once event has been fired.

Returns
True if the on_near_once event has been fired and the entity has not yet exited the line (exit as in the line being outside the entity solid radius), and false if the playable entity has approached the line but the event has not been triggered yet.

◆ Clear()

void EntityTrigger::Clear ( )

Clears the proximity statuses and event triggering statuses.

Can be called once the playable entity leaves the line.

◆ ClearNearEventCooldown()

void EntityTrigger::ClearNearEventCooldown ( )

Sets the cooldown time required between calls to on_near event to 0.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

Must be called whent the playable entity gets away from the line

◆ DecreaseNearEventCooldown()

void EntityTrigger::DecreaseNearEventCooldown ( )

Decreases the cooldown time required between calls to on_near event by one.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

◆ GetName()

const Ogre::String & EntityTrigger::GetName ( ) const

Retrieves the trigger name.

Returns
The trigger name.

◆ GetNearEventCooldown()

const int EntityTrigger::GetNearEventCooldown ( )

Checks if the cooldown that prevents caling the on_near event multiple times has ended.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

Returns
The number of frames remaining in the cooldown. If it's 0, the on_near event can be called again. If not, {
See also
DecreaseNearEventCooldown} must be called.

◆ GetPoint1()

const Ogre::Vector3 & EntityTrigger::GetPoint1 ( ) const

Retrieves the first vertex of the line that acts as trigger.

Returns
The first vertex.

◆ GetPoint2()

const Ogre::Vector3 & EntityTrigger::GetPoint2 ( ) const

Retrieves the second vertex of the line that acts as trigger.

Returns
The second vertex.

◆ IsEnabled()

bool EntityTrigger::IsEnabled ( ) const

Checks if the trigger is enabled.

Returns
True if it's enabled, false otherwise.

◆ ResetNearEventCooldown()

void EntityTrigger::ResetNearEventCooldown ( )

Resets the cooldown time required between calls to on_near event.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

Must be called after firing the on_near event. After calling this, the cooldown will be reset, and all frames must be waited before calling it again.

◆ SetApproached()

void EntityTrigger::SetApproached ( const bool  approached)

Sets if the the playable entity has approached the line.

Must be set to true when the playable entity's solid radius touches the line while manually moving, and to false when the playable entity is not near the line.

Parameters
[in]approachedIf the line has been approached.

◆ SetCrossed()

void EntityTrigger::SetCrossed ( const bool  crossed)

Sets if the the playable entity has crossed the line.

Must be set to true when the playable entity's center touches the line while manually moving, and to false when the playable entity is not near the line.

Parameters
[in]crossedIf the line has been approached.

◆ SetEnabled()

void EntityTrigger::SetEnabled ( const bool  enabled)

Enables or disables the trigger.

When disabled, all the activators are removed.

Parameters
[in]enabledTrue to enable the trigger, false to disable it.

◆ SetNearSingleEventTriggered()

void EntityTrigger::SetNearSingleEventTriggered ( const bool  triggered)

Sets if the on_near_once have been triggered.

Must be set to true when it's run, and to false when the playable entity is not near the line.

Parameters
[in]triggeredIf the on_near_once has been triggered.

◆ SetPoints()

void EntityTrigger::SetPoints ( const Ogre::Vector3 &  point1,
const Ogre::Vector3 &  point2 
)

Sets the vertices of the line that acts as the trigger.

Parameters
[in]point1One of the vertices of the line.
[in]point2One of the vertices of the line.

◆ UpdateDebug()

void EntityTrigger::UpdateDebug ( )

Updates the trigger state with debug information.

Member Data Documentation

◆ approached_

bool EntityTrigger::approached_
private

Indicates if the playable entity has approached the line.

◆ crossed_

bool EntityTrigger::crossed_
private

Indicates if the playable entity has crossed the line.

◆ enabled_

bool EntityTrigger::enabled_
protected

Indicates if the trigger is enabled or disabled.

◆ name_

Ogre::String EntityTrigger::name_
protected

The name of the trigger.

◆ near_event_cooldown_

int EntityTrigger::near_event_cooldown_
private

Remaining frames to cooldown after triggering on_near event.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

◆ NEAR_EVENT_COOLDOWN_FRAMES

int EntityTrigger::NEAR_EVENT_COOLDOWN_FRAMES = 5
staticprivate

Frames to cooldown after triggering on_near event.

After the on_near script is run, a cooltime of a number of frames is set before running it again. This is because most of the time this trigger checks for a key, and if its pressed, is run multiple times.

◆ near_single_event_triggered_

bool EntityTrigger::near_single_event_triggered_
private

Indicates if the near_once event has been triggered.

◆ point_1_

Ogre::Vector3 EntityTrigger::point_1_
protected

One of the vertices of the trigger line.

◆ point_2_

Ogre::Vector3 EntityTrigger::point_2_
protected

One of the vertices of the trigger line.


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