Class EntityScript<T extends IEntity>
java.lang.Object
de.gurkenlabs.litiengine.scripting.AbstractScript<T>
de.gurkenlabs.litiengine.scripting.EntityScript<T>
- Type Parameters:
T- The required entity host type.
- All Implemented Interfaces:
ScriptInstance
- Direct Known Subclasses:
CreatureScript
Base class for scripts attached to an entity.
-
Field Summary
Fields inherited from class AbstractScript
globals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidattached()Called after the context is installed and the script becomes active.protected final voiddetached()Called before context-owned resources are released.voiddie()Marks the host combat entity as dead.intReturns current health / hitpoints (or 0 if not a combat entity).intReturns maximum health / hitpoints (or 0 if not a combat entity).booleanisDead()Checks if the host entity is dead (if it is a combat entity).protected voidCalled when an entity action is performed on the attached entity.protected voidCalled when the attached collision entity collides with another collision entity.protected voidonCollision(CollisionEvent event) Called when the attached collision entity collides with another collision entity.protected voidonDeath()Called when the attached combat entity dies.protected voidonDeath(ICombatEntity entity, EntityHitEvent hitEvent) Called when the attached combat entity dies.protected voidonHit()Called when the attached combat entity is hit.protected voidonHit(EntityHitEvent event) Called when the attached combat entity is hit.protected voidonInteract(IEntity source) Called when another entity interacts with the attached entity.protected voidonLoaded()Called from the entity's loaded event after its environment is available.protected voidonMessage(EntityMessageEvent event) Called for messages delivered to the attached entity.protected voidCalled when a text message is received by the attached entity.protected voidCalled when the entity controller is detached or the entity is removed.voidremove()Removes this entity from its current environment.voidResurrects the host combat entity.voidsendMessage(IEntity receiver, String message) Sends a message from this entity to a target receiver entity.voidsendMessage(String message) Sends a message from this entity to all of its listeners.Methods inherited from class AbstractScript
attach, camera, context, detach, environment, globals, host, input, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheel, onRender, render, spawn, spawn, spawn, spawn, spawnCreature, spawnCreature, spawner, spawnProp, spawnProp, uiMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ScriptInstance
update
-
Constructor Details
-
EntityScript
public EntityScript()
-
-
Method Details
-
attached
Description copied from class:AbstractScriptCalled after the context is installed and the script becomes active.- Overrides:
attachedin classAbstractScript<T extends IEntity>- Throws:
Exception- if initialization fails.
-
detached
Description copied from class:AbstractScriptCalled before context-owned resources are released.- Overrides:
detachedin classAbstractScript<T extends IEntity>- Throws:
Exception- if cleanup fails.
-
onLoaded
-
onUnloaded
-
onMessage
Called for messages delivered to the attached entity.- Parameters:
event- The message event.- Throws:
Exception- if handling fails.
-
onMessage
-
onHit
Called when the attached combat entity is hit.- Parameters:
event- The hit event.- Throws:
Exception- if handling fails.
-
onHit
-
onDeath
Called when the attached combat entity dies.- Parameters:
entity- The entity that died.hitEvent- The final hit, ornullwhen no hit caused the death.- Throws:
Exception- if handling fails.
-
onDeath
-
onCollision
Called when the attached collision entity collides with another collision entity.- Parameters:
event- The collision details.- Throws:
Exception- if handling fails.
-
onCollision
-
onInteract
-
onAction
-
sendMessage
Sends a message from this entity to all of its listeners.- Parameters:
message- The message text.
-
sendMessage
-
remove
public void remove()Removes this entity from its current environment. -
isDead
public boolean isDead()Checks if the host entity is dead (if it is a combat entity).- Returns:
trueif the host is a dead combat entity.
-
die
public void die()Marks the host combat entity as dead. -
resurrect
public void resurrect()Resurrects the host combat entity. -
getHealth
public int getHealth()Returns current health / hitpoints (or 0 if not a combat entity).- Returns:
- The current hit points, or zero for non-combat hosts.
-
getMaxHealth
public int getMaxHealth()Returns maximum health / hitpoints (or 0 if not a combat entity).- Returns:
- The maximum hit points, or zero for non-combat hosts.
-