Class EntityScriptController<T extends IEntity>

All Implemented Interfaces:
IEntityController, IUpdateable

public final class EntityScriptController<T extends IEntity> extends Object implements IEntityController

Owns the script bindings of an entity and maps them onto the regular entity-controller lifecycle.

The controller is attached by the environment before IEntity.loaded(Environment) is fired. Script instances are therefore created from the entity's loaded event, after its current environment is available.

  • Field Details

    • SCRIPT_UPDATE_PRIORITY

      public static final int SCRIPT_UPDATE_PRIORITY
      Entity scripts are behavior orchestration and run after default movement controllers.
      See Also:
  • Constructor Details

    • EntityScriptController

      public EntityScriptController(T entity, Collection<ScriptBinding> bindings)
      Creates a script controller for an entity.
      Parameters:
      entity - The entity to control.
      bindings - The initial explicit bindings, or null for none.
  • Method Details

    • attach

      public void attach()
      Specified by:
      attach in interface IEntityController
    • detach

      public void detach()
      Specified by:
      detach in interface IEntityController
    • update

      public void update()
      Description copied from interface: IUpdateable
      This method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using the ClientConfiguration.
      Specified by:
      update in interface IUpdateable
      See Also:
    • getUpdatePriority

      public int getUpdatePriority()
      Description copied from interface: IUpdateable
      Determines this object's stable position in an update tick. Objects with the same priority retain their registration order.
      Specified by:
      getUpdatePriority in interface IUpdateable
      Returns:
      the update priority; lower values run first
    • getEntity

      public T getEntity()
      Specified by:
      getEntity in interface IEntityController
    • getBindings

      public List<ScriptBinding> getBindings()
      Returns the merged, ordered list of active script bindings for this entity.
      Returns:
      The list of merged bindings.
    • getExplicitBindings

      public List<ScriptBinding> getExplicitBindings()
      Returns only bindings explicitly configured on this entity.
      Returns:
      The list of explicit bindings.
    • setBindings

      public void setBindings(Collection<ScriptBinding> bindings)
      Replaces the ordered bindings and restarts this controller if it is active.
      Parameters:
      bindings - The replacement bindings, or null to clear them.
    • setDefaultBindings

      public void setDefaultBindings(Collection<ScriptBinding> bindings)
      Replaces inherited type-level bindings while retaining per-entity overrides.
      Parameters:
      bindings - The default bindings, or null to clear them.
    • isAttached

      public boolean isAttached()
      Returns whether script instances are currently attached to the entity.
      Returns:
      true if scripts are attached.