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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intEntity scripts are behavior orchestration and run after default movement controllers.Fields inherited from interface IUpdateable
DEFAULT_UPDATE_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionEntityScriptController(T entity, Collection<ScriptBinding> bindings) Creates a script controller for an entity. -
Method Summary
Modifier and TypeMethodDescriptionvoidattach()voiddetach()Returns the merged, ordered list of active script bindings for this entity.Returns only bindings explicitly configured on this entity.intDetermines this object's stable position in an update tick.booleanReturns whether script instances are currently attached to the entity.voidsetBindings(Collection<ScriptBinding> bindings) Replaces the ordered bindings and restarts this controller if it is active.voidsetDefaultBindings(Collection<ScriptBinding> bindings) Replaces inherited type-level bindings while retaining per-entity overrides.voidupdate()This method is called by the game loop on all objects that are attached to the loop.
-
Field Details
-
SCRIPT_UPDATE_PRIORITY
public static final int SCRIPT_UPDATE_PRIORITYEntity scripts are behavior orchestration and run after default movement controllers.- See Also:
-
-
Constructor Details
-
EntityScriptController
Creates a script controller for an entity.- Parameters:
entity- The entity to control.bindings- The initial explicit bindings, ornullfor none.
-
-
Method Details
-
attach
public void attach()- Specified by:
attachin interfaceIEntityController
-
detach
public void detach()- Specified by:
detachin interfaceIEntityController
-
update
public void update()Description copied from interface:IUpdateableThis 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 theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-
getUpdatePriority
public int getUpdatePriority()Description copied from interface:IUpdateableDetermines this object's stable position in an update tick. Objects with the same priority retain their registration order.- Specified by:
getUpdatePriorityin interfaceIUpdateable- Returns:
- the update priority; lower values run first
-
getEntity
- Specified by:
getEntityin interfaceIEntityController
-
getBindings
Returns the merged, ordered list of active script bindings for this entity.- Returns:
- The list of merged bindings.
-
getExplicitBindings
Returns only bindings explicitly configured on this entity.- Returns:
- The list of explicit bindings.
-
setBindings
Replaces the ordered bindings and restarts this controller if it is active.- Parameters:
bindings- The replacement bindings, ornullto clear them.
-
setDefaultBindings
Replaces inherited type-level bindings while retaining per-entity overrides.- Parameters:
bindings- The default bindings, ornullto clear them.
-
isAttached
public boolean isAttached()Returns whether script instances are currently attached to the entity.- Returns:
trueif scripts are attached.
-