Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/MultiTrigger


Ignore:
Timestamp:
Aug 31, 2010, 5:49:56 PM (14 years ago)
Author:
dafrick
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/MultiTrigger

    v1 v1  
     1= Multi Trigger =
     2
     3== Author ==
     4
     5[wiki:DamianFrick "Damian Frick"]
     6
     7== Description ==
     8
     9MultiTriggers are (just as Triggers) objects which react to certain events. They offer all the functionality that Triggers do with one significant difference. A Trigger hast just one state, it can either be triggered or not triggered, it doesn't discriminate between who's triggering it. A MultiTrigger on the other hand has a distinct state (triggered or not triggered) for each entity that is defined as being able to trigger said MultiTrigger.
     10[[BR]]This difference becomes significant, when for example you want a DistanceTrigger to trigger a QuestEffectBeacon to hand out a Quest to any Pawn that enters its range. With a simple DistanceTrigger (as opposed to the more complex DistanceMultiTrigger) the first Pawn to be in range would trigger it an receive the Quest, however if a second Pawn would enter the range, while the first Pawn still is in the range nothing would happen and even after the first Pawn left nothing would happen, since all the time the DistanceTrigger would just be triggered. In contrast with a DistanceMultiTrigger the first Pawn would enter the range and the DistanceMultiTrigger would have the state triggered for this exact Pawn (but for none else) and thus the pawn would receive the Quest and when the second Pawn enters the range the state of the DistanceMultiTrigger for that second Pawn would change to triggered and it would receive the Quest as well.
     11
     12== When to use MultiTriggers ==
     13
     14Consequentially you would use MultiTriggers (instead of Triggers), when it is important that the trigger has different states for each triggering entity and when that fact is essential in the concept of the object that reacts to the triggering. However you should not just use MultiTrigger instead of Trigger, when in doubt, because MultiTrigger produces significantly more overhead than Trigger due to the added complexity.
     15
     16== Detailed Description ==
     17
     18In more detail: A Trigger is an object that can either be active or inactive, with a specified behavior how to switch between the two. A MultiTrigger generalizes that behavior for multiple objects triggering the trigger. A MultiTrigger can be active or inactive for any object triggering it, with the state for each object being completely independent of the state for other objects. Each time a switch occurs an Event is fired with, as the originator a MultiTriggerContainer, containing a pointer to the MultiTrigger that caused the Event and a pointer to the object that caused the trigger to change it's activity. This way the entity that reacts to the MultiTrigger triggering receives the information it needs about the entity that triggered the MultiTrigger.
     19[[BR]][[BR]]
     20Also, just as with Triggers, MultiTriggers can be nested.
     21{{{
     22<MultiTrigger switch="true" delay="2">
     23    <DistanceMultiTrigger position="100,0,0" distance="80" />
     24    <EventTrigger ... />
     25</Trigger>
     26}}}
     27[[BR]]MultiTriggers also allow for additional complexity which can be added through the choice of the parameters explained (briefly) below. But first you must understand a small implementational detail. There is a distinction between the MultiTrigger being triggered (there is the state 'triggered' for that) and the MultiTrigger 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 triggered (or to the outside, active), while it in fact isn't. The standard behavior is, that the activity changes, when the MultiTrigger transits from being triggered to not being triggered or the other way around. So to the inside a MultiTrigger being active is synonymous to the MultiTrigger being triggered to the outside.
     28[[BR]][[BR]]
     29The parameters of the MultiTrigger are:
     30
     31=== delay ===
     32 
     33The delay is the time in seconds, that the trigger waits until it reacts (i.e. changes it's state) to the triggering condition being fulfilled. Internally this is handled by a state queue coupled with a counter for each state that is delayed and the state becomes active when the counter runs out. This allows the MultiTrigger to work even if the delay changes. However
     34if the delay changes it only affects newly arriving states not the ones already in the queue.
     35[[BR]]Default is 0.
     36
     37=== switch ===
     38
     39Switch is a boolean, if true the MultiTrigger is in switch-mode, meaning, that the activity changes only when the trigger is triggered, not when it is un-triggered. This means, that now the activity only changes, when the trigger changes from not being triggered to being triggered but not the other way around.
     40[[BR]]Default is false.
     41
     42=== stayactive ===
     43
     44Stay active is also a boolean, if true the MultiTrigger 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.
     45[[BR]]Default is false.
     46
     47=== activations ===
     48
     49Activations is the number of times the MultiTrigger can be activated until the trigger can't be triggered anymore.
     50[[BR]]Default is -1, which denotes infinity.
     51
     52=== invert ===
     53
     54Invert is a boolean, if true the trigger is in invert-mode, meaning, that if the triggering condition is fulfilled the MultiTrigger 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 MultiTrigger.
     55[[BR]]Default is false.
     56
     57=== simultaneousTriggerers ===
     58
     59The number of simultaneous triggerers limits the number of objects that are allowed to trigger the MultiTrigger at the same time. Or more precisely, the number of distinct objects the MultiTrigger has 'triggered' states for, at each point in time.
     60[[BR]]Default is -1, which denotes infinity.
     61
     62=== mode ===
     63
     64The mode describes how the MultiTrigger acts in relation to all the MultiTriggers (its children), that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only be triggered if at least one of the appended MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Note, that I wrote 'can only be active', that implies, that there is an additional condition to the activity of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the activity of a MultiTrigger is still coupled to the object that triggered it.
     65[[BR]]The default is 'and'.
     66
     67=== broadcast ===
     68
     69Broadcast is a boolean, if true the MutliTrigger is in broadcast-mode, meaning, that all trigger events that are caused by no originator (originator is NULL) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger.
     70[[BR]]Default is false.
     71
     72=== target ===
     73
     74The target describes the kind of objects that are allowed to trigger this MultiTrigger.
     75[[BR]]The default is 'Pawn'.
     76
     77== How to use MultiTriggers ==
     78
     79
     80
     81== Classtree ==