Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorLookedAt
Behavior element behavior adding support to track if actors look at element.
This behavior tracks if actors are looking at the element. If actors start looking at the element they are added to the list and listeners are notified. If the actors stop looking at the element they are removed from the list and listeners are notified. The actors can be an NPC or the player.
The behavior itself is passive. It requires to be triggered by the actor elements. The ECBehaviorLookAt behavior provides this functionality.
This behavior can be used only once on an element. The behavior always has identifier empty string.
Element class properties have the prefix lookedAt.
.
This behavior does not required other behaviors to be present.
This behavior does not support optional behaviors.
This behavior does support element class to be persistable (setPersistable).
This behavior supports adding listeners. These events can be received:
Actors starts looking at object.
Actors stops looking at object.
Since DragonScript Module Version 1.1
class ExampleElementClass extends BehaviorElementClass public var ECBehaviorLookedAt lookedAt public func new() super("ExampleElement") // add looked at behavior. by itself this does nothing yet. add listeners to the // behavior to react to looking-at changes. this is typically done by other // behaviors to provide their functionality lookedAt = ECBehaviorLookedAt.new(this) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorLookedAt'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> </elementClass>