User Tools

Site Tools


dragengine:modules:dragonscript:behavior_attachments

ECBehaviorAttachments

Behavior for element storing attached elements.

Provides list for ECBehaviorAttachToParent to register themselves at. This allows this behavior to manage attached elements in case of elements being added and removed from game worlds as well as finding specific attached elements. Does not support detaching elements. If the element is disposed all attached elements are disposed too. If you need dynamic attaching use ECBehaviorAttachSlot together with ECBehaviorAttachable.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix attachments. .

Events

This behavior has no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorAttachments.

Since DragonScript Module Version 1.0

Use Cases

  • Keep track of elements attached to actor.
  • Allow moving element together with attached elements to another game world.

Element Class Example

This example defines an element which can keep track of attached elements.

class MyElement extends BehaviorElementClass
  public var ECBehaviorAttachments attachments
  func new()
    attachments = ECBehaviorAttachments.new(this)
  end
end

Behavior Factory

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='ECBehaviorAttachments'>
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_attachments.txt · Last modified: 2025/03/12 15:05 by dragonlord