Emergency 20 Dokumentation  4.2.0
qsf::ai::reactionrules::ForwardLocalEventRule Class Referenceabstract

#include <LocalEventRules.h>

Inheritance diagram for qsf::ai::reactionrules::ForwardLocalEventRule:
qsf::ai::reactionrules::StandardRule qsf::ai::ReactionRule

Public Member Functions

 ForwardLocalEventRule (bool sensorAutoPush)
virtual bool handle (const EvaluationParameters &parameters)
- Public Member Functions inherited from qsf::ai::reactionrules::StandardRule
 StandardRule (EvaluationParameters::PerceptionEventSource eventSource)
virtual const char * getRegistrationName () const =0
virtual void deserialize (const boost::property_tree::ptree &tree)
virtual void serialize (boost::property_tree::ptree &tree) const
- Public Member Functions inherited from qsf::ai::ReactionRule
 ReactionRule ()
 ReactionRule (const ReactionRule &src)
virtual ~ReactionRule ()
virtual ReactionRuleclone () const =0
virtual bool wantsHandlingDespiteOfLowerPriority () const
virtual void serialize (BinarySerializer &serializer)
const std::string & getName () const
uint32 getId () const
Percentage getProbability () const
void setProbability (Percentage probability)
action::Priority getPriority () const

Protected Member Functions

virtual bool fireLocalEvent (const EvaluationParameters &parameters)=0
- Protected Member Functions inherited from qsf::ai::reactionrules::StandardRule
EvaluationParameters::PerceptionEventIterator checkForEvent (const EvaluationParameters &parameters) const
- Protected Member Functions inherited from qsf::ai::ReactionRule
bool pushEventToEntity (const PerceptionEvent &perceptionEvent) const

Additional Inherited Members

- Static Public Member Functions inherited from qsf::ai::ReactionRule
static bool compareByPriority (const ReactionRule *a, const ReactionRule *b)
- Protected Attributes inherited from qsf::ai::reactionrules::StandardRule
NamedIdentifier mEventId
EvaluationParameters::PerceptionEventSource mEventSource

Detailed Description

General notes regarding local events:

The most obvious way of defining a reaction to a local event is to attach a sensor- and a reaction-component for that event to an entity. This approach is fine if there are many sources for that event (for example: detect and react on burning objects if 50% of the map is burning).

But often the "inverse" strategy is more appropriate: if there aren't that many sources for that event it is more efficient to attach a sensor to detect potential REACT-entities to the event-source-entity. That sensor is checked by a pseudo-reaction-rule on that source-entity that then pushs actual events to the target-entities in range. That way you only need 1 sensor for all potential targets; that sensor only needs to be updated / checked if the source-entity decides that this is actually necessary.

The explosion of an entity would be one example. The entity knows best when / if it is exploding, so instead of letting all other entities scan the map for explosions all the time, better let the exploding entity scan for potential observers nearby and notify those.

The following classes are designed to be used with the latter case. ForwardLocalEventRule is a ReactionRule to be attached to a event-source-entity's ReactionComponent. It works in combination with a SensorComponent also attached to that entity. The sensor's purpose is to detect entities that will potentially react on the event. If the rule decides that the local event is happening, it checks the sensor for potential targets and notifies those.

Implement fireLocalEvent and return true if your concrete event condition is satisfied. In turn this class will notify all potential target entities.

Sensor-Configuration: The corresponding sensor has to be configured to match the constructor's sensorAutoPush parameter

sensorAutoPush = true: The sensor is expected to update its perceptions in the sensor-interval specified. Use this mode if your event is triggered pretty often (e.g. entity constantly burning).

sensorAutoPush = false: The sensor is updated by the rule itself if fireLocalEvent returns true. Use this mode if your event is seldomly triggered (e.g. entity explodes).

Constructor & Destructor Documentation

qsf::ai::reactionrules::ForwardLocalEventRule::ForwardLocalEventRule ( bool  sensorAutoPush)

Member Function Documentation

virtual bool qsf::ai::reactionrules::ForwardLocalEventRule::fireLocalEvent ( const EvaluationParameters parameters)
protectedpure virtual
virtual bool qsf::ai::reactionrules::ForwardLocalEventRule::handle ( const EvaluationParameters parameters)

Implements qsf::ai::ReactionRule.

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