Orxonox
0.0.5 Codename: Arcturus
|
Triggers are objects which react to certain events by changing their boolean state. More...
Files | |
file | CheckPoint.cc |
Implementation of the CheckPoint class. | |
file | CheckPoint.h |
Definition of the CheckPoint class. | |
file | DistanceTrigger.cc |
Implementation of the DistanceTrigger class. | |
file | DistanceTrigger.h |
Definition of the DistanceTrigger class. | |
file | EventTrigger.cc |
Implementation of the EventTrigger class. | |
file | EventTrigger.h |
Definition of the EventTrigger class. | |
file | Trigger.cc |
Implementation of the Trigger class. | |
file | Trigger.h |
Definition of the Trigger class. | |
Classes | |
class | orxonox::CheckPoint |
class | orxonox::DistanceTrigger |
The DistanceTrigger is a Trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceTrigger. More... | |
class | orxonox::EventTrigger |
The EventTrigger class provides a way to have a Trigger triggered by any kinds of Events. More... | |
class | orxonox::Trigger |
A Trigger is an object that can either be active or inactive, with a specified behavior how to switch between the two. More... | |
Enumerations | |
enum | orxonox::DistanceTriggerBeaconMode { orxonox::DistanceTriggerBeaconMode::off, orxonox::DistanceTriggerBeaconMode::identify, orxonox::DistanceTriggerBeaconMode::exclude } |
Enum for the beacon mode of the DistanceTrigger. More... | |
Triggers are objects which react to certain events by changing their boolean state.
That state is the trigger's activity orxonox::Trigger can be either active or not active.
A common Trigger is an object that can either be active or inactive, with a specified behavior how to switch between the two. Each time a switch occurs an Event is fired (see the Eventsystem for more information about how that works exactly), with th Trigger as the originator. This way the entity that reacts to the Trigger triggering receives information about the Trigger that created the Event. If the Trigger is also a PlayerTrigger, under some conditions, the entity that caused the Trigger to trigger can be accessed.
Also, just as with all triggers, Triggers can be nested (even with e.g. MultiTriggers).
Triggers also allow for additional complexity which can be added through the choice of the parameters explained below. But first it is important to understand a small implementation detail. There is a distinction between the Trigger being triggered (there is the state triggered for that) and the Trigger being active (for that is the state activity). From the outside only the activity is visible. The state triggered tells us whether the trigger is actually triggered, but it could pretend (for some reason, some of which we will see shortly) to be active to the outside, while it in fact isn't. The standard behavior is, that the activity changes, when the Trigger transits from being triggered to being not triggered or the other way around.
The parameters of the Trigger are:
0.0
.true
the Trigger is in switch-mode, meaning, that the activity changes only when the trigger is triggered, not when it is not triggered (Just like a light switch does). This means, that in switch-mode the activity only changes, when the trigger changes from being not triggered to being triggered but not the other way around. The default is false
.true
the Trigger stays active after it has been activated as many times as specified by the parameter activations. In essence this means, that after the last time it is activated it cannot be deactivated. The default is false
.-1
, which denotes infinity.true
the Trigger is in invert-mode, meaning, that if the triggering condition is fulfilled the Trigger will have the state not triggered and and if the condition is not fulfilled it will have the state triggered. In short it inverts the behavior of the Trigger. The default is false
.An EventTrigger can either be used to be triggered when an Event, that itself is triggering, arrives at its event port.
A common usage could look like this:
The DistanceTrigger is a Trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceTrigger. The object can be specified further by setting the beaconMode and attaching a DistanceTriggerBeacon to the object. Parameters are (additional to the ones of Trigger):
100
."Pawn"
.A simple DistanceTrigger could look like this:
An implementation that only reacts to objects with a DistanceTriggerBeacon attached would look like this:
This particular DistanceTrigger would only react if an object was in range, that had a DistanceTriggerBeacon with the name beacon1 attached.
|
strong |
Enum for the beacon mode of the DistanceTrigger.
Enumerator | |
---|---|
off | |
identify | |
exclude |