CEL: Crystal Entity Layer: iPcTrigger Struct Reference (CEL: Crystal Entity Layer Public API Reference)

| ## Public API Reference

- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iPcTrigger Struct Reference

This is a trigger property class. More...

`#include <propclass/trigger.h>`

List of all members.

## Public Member Functions
virtual void | AddTriggerListener (iPcTriggerListener *listener)=0
| Add a trigger listener.
virtual bool | Check ()=0
| This only works if we are monitoring an individual entity.
virtual void | EnableMessagesToOthers (bool en)=0
| Enable/disable sending messages to the entities that enter or leave this trigger (messages like pctrigger_entertrigger and pctrigger_leavetrigger).
virtual void | EnableMessagesToSelf (bool en)=0
| Enable/disable sending messages to the entity containing the trigger about other entities leaving of entering (messages like pctrigger_entityenters and pctrigger_entityleaves).
virtual void | EnableTrigger (bool en)=0
| Disable trigger.
virtual const csWeakRefArray< iCelEntity > & | GetEntitiesInTrigger () const =0
| Get an array of all entities that are currently in the trigger area.
virtual const char * | GetMonitorEntity () const =0
| Return the entity name that we are currently monitoring or 0 if monitoring all entities.
virtual bool | IsEnabled () const =0
| Return true if trigger is enabled.
virtual void | MonitorEntity (const char *entityname)=0
| By default pctrigger will monitor all entities.
virtual void | RemoveTriggerListener (iPcTriggerListener *listener)=0
| Remove a trigger listener.
virtual void | SetMonitorDelay (csTicks delay, csTicks jitter)=0
| Set the number of milliseconds we delay before monitoring all entities again.
virtual void | SetupTriggerAboveMesh (iPcMesh *mesh, float maxdistance)=0
| Setup a trigger to fire if this mesh ends up above another mesh.
virtual void | SetupTriggerBox (iSector *sector, const csBox3 &box)=0
| Setup a box trigger zone.
virtual void | SetupTriggerSphere (iSector *sector, const char *center_name, float radius)=0
| Setup a spherical area as trigger zone.
virtual void | SetupTriggerSphere (iSector *sector, const csVector3 &center, float radius)=0
| Setup a spherical area as trigger zone.

## Detailed Description

This is a trigger property class.

It is capable of detecting when another entity (that has a pcmesh) enters or leaves an area defined by this trigger. In that case it can send messages to the entity that contains this property class and/or the entities that enter/leave the trigger area.

This property class supports the following actions (add prefix 'cel.action.' to get the ID of the action and add prefix 'cel.parameter.' to get the ID of the parameter):

- SetupTriggerSphere: parameters 'sector' (string), 'position' (vector3 or string (name of mapnode in that case)), and 'radius' (float).
- SetupTriggerBox: parameters 'sector' (string), 'minbox' (vector3), and 'maxbox' (vector3).
- SetupTriggerAboveMesh: parameters 'entity' (string) and 'maxdistance' (float),

This property class can send out the following messages to the behaviour (add prefix 'cel.parameter.' to get the ID for parameters):

- pctrigger_entityenters: an entity enters this trigger (entity).
- pctrigger_entityleaves: an entity leaves this trigger (entity).
- pctrigger_entertrigger: this entity enters a trigger (entity).
- pctrigger_leavetrigger: this entity leaves a trigger (entity).

This property class supports the following properties (add prefix 'cel.property.' to get the ID of the property:

- delay (long, read/write): update delay for checking trigger.
- jitter (long, read/write): random jitter added to update delay.
- monitor (string, read/write): name of entity to monitor.

Definition at line 100 of file trigger.h.

## Member Function Documentation

virtual void iPcTrigger::AddTriggerListener | ( | iPcTriggerListener * | listener | ) | `[pure virtual]`

| Add a trigger listener. Trigger listeners are called right before the behaviour is called.

virtual bool iPcTrigger::Check | ( |  | ) | `[pure virtual]`

| This only works if we are monitoring an individual entity. In that case it will return true if the entity is already in the trigger.

virtual void iPcTrigger::EnableMessagesToOthers | ( | bool | en | ) | `[pure virtual]`

| Enable/disable sending messages to the entities that enter or leave this trigger (messages like pctrigger_entertrigger and pctrigger_leavetrigger). This is enabled by default.

virtual void iPcTrigger::EnableMessagesToSelf | ( | bool | en | ) | `[pure virtual]`

| Enable/disable sending messages to the entity containing the trigger about other entities leaving of entering (messages like pctrigger_entityenters and pctrigger_entityleaves). This is enabled by default.

virtual void iPcTrigger::EnableTrigger | ( | bool | en | ) | `[pure virtual]`

| Disable trigger. Triggers are enabled by default.

virtual const csWeakRefArray<iCelEntity>& iPcTrigger::GetEntitiesInTrigger | ( |  | ) | const`[pure virtual]`

| Get an array of all entities that are currently in the trigger area.

virtual const char* iPcTrigger::GetMonitorEntity | ( |  | ) | const`[pure virtual]`

| Return the entity name that we are currently monitoring or 0 if monitoring all entities.

virtual bool iPcTrigger::IsEnabled | ( |  | ) | const`[pure virtual]`

| Return true if trigger is enabled.

virtual void iPcTrigger::MonitorEntity | ( | const char * | entityname | ) | `[pure virtual]`

| By default pctrigger will monitor all entities. If you only want pctrigger to monitor one entity then you can give the name of that entity here. pctrigger will try to find the entity with that name and monitor it. To go back to monitoring all entities just call this function with a 0 name.

virtual void iPcTrigger::RemoveTriggerListener | ( | iPcTriggerListener * | listener | ) | `[pure virtual]`

| Remove a trigger listener.

virtual void iPcTrigger::SetMonitorDelay | ( | csTicks | delay,
|  | csTicks | jitter
| ) | `[pure virtual]`

| Set the number of milliseconds we delay before monitoring all entities again. There is also a jitter parameter which will add a small random amount to that time to prevent all triggers trying to do the monitoring at once. By default this is set to 200/20 (i.e. roughly five times per second).

virtual void iPcTrigger::SetupTriggerAboveMesh | ( | iPcMesh * | mesh,
|  | float | maxdistance
| ) | `[pure virtual]`

| Setup a trigger to fire if this mesh ends up above another mesh. This works by tracing a beam down from the center of the mesh.

virtual void iPcTrigger::SetupTriggerBox | ( | iSector * | sector,
|  | const csBox3 & | box
| ) | `[pure virtual]`

| Setup a box trigger zone.

virtual void iPcTrigger::SetupTriggerSphere | ( | iSector * | sector,
|  | const char * | center_name,
|  | float | radius
| ) | `[pure virtual]`

| Setup a spherical area as trigger zone. This version uses a mapnode (<node> in XML) in the sector to get the position from.

virtual void iPcTrigger::SetupTriggerSphere | ( | iSector * | sector,
|  | const csVector3 & | center,
|  | float | radius
| ) | `[pure virtual]`

| Setup a spherical area as trigger zone.

The documentation for this struct was generated from the following file:

- propclass/trigger.h