Class DefaultScriptBehaviorController<T extends IEntity>

Type Parameters:
T - the type of controlled entity
All Implemented Interfaces:
IBehaviorController, IEntityController, IUpdateable

public class DefaultScriptBehaviorController<T extends IEntity> extends Object implements IBehaviorController

A default behavior controller that loads and manages entity scripts internally.

This controller encapsulates script bindings and delegates execution to an internal EntityScriptController, allowing entity behavior to be driven dynamically by runtime scripts.

  • Constructor Details

    • DefaultScriptBehaviorController

      public DefaultScriptBehaviorController(T entity)
    • DefaultScriptBehaviorController

      public DefaultScriptBehaviorController(T entity, String... scriptIds)
    • DefaultScriptBehaviorController

      public DefaultScriptBehaviorController(T entity, Collection<ScriptBinding> bindings)
  • Method Details

    • getEntity

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

      public EntityScriptController<T> getScriptController()
      Returns the internal EntityScriptController managing the script instances.
      Returns:
      the script controller
    • loadScript

      public void loadScript(String scriptId)
      Loads a script by its definition ID with default parameters.
      Parameters:
      scriptId - the script definition ID to load
    • loadScript

      public void loadScript(ScriptBinding binding)
      Loads a script with specific bindings and configuration parameters.
      Parameters:
      binding - the script binding to load
    • loadScripts

      public void loadScripts(Collection<ScriptBinding> bindings)
      Loads multiple script bindings.
      Parameters:
      bindings - the script bindings to load
    • unloadScript

      public void unloadScript(String scriptId)
      Unloads a script by its definition ID.
      Parameters:
      scriptId - the script definition ID to unload
    • unloadAllScripts

      public void unloadAllScripts()
      Unloads all scripts currently loaded by this behavior controller.
    • getLoadedScripts

      public List<ScriptBinding> getLoadedScripts()
      Returns an unmodifiable list of script bindings currently loaded by this controller.
      Returns:
      the loaded script bindings
    • attach

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

      public void detach()
      Specified by:
      detach in interface IBehaviorController
      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:
    • updateBehavior

      protected void updateBehavior() throws Exception
      Throws:
      Exception