An entity trigger.
More...
#include <EntityTrigger.h>
◆ EntityTrigger()
EntityTrigger::EntityTrigger |
( |
const Ogre::String & |
name | ) |
|
Constructor.
- Parameters
-
[in] | name | The trigger name. |
◆ ~EntityTrigger()
EntityTrigger::~EntityTrigger |
( |
| ) |
|
|
virtual |
◆ 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] | approached | If 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] | crossed | If 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] | enabled | True 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] | triggered | If 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] | point1 | One of the vertices of the line. |
[in] | point2 | One of the vertices of the line. |
◆ UpdateDebug()
void EntityTrigger::UpdateDebug |
( |
| ) |
|
Updates the trigger state with debug information.
◆ 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 |
◆ 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: