Class Creature
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
de.gurkenlabs.litiengine.entities.CombatEntity
de.gurkenlabs.litiengine.entities.Creature
- All Implemented Interfaces:
EntityRenderedListener, EntityRenderListener, ICollisionEntity, ICombatEntity, IEntity, IMobileEntity, Tweenable, EventListener
- Direct Known Subclasses:
ScriptedProjectile
The
Creature class extends the CombatEntity class and implements the IMobileEntity interface. It represents a creature
entity in the game with movement and combat capabilities.-
Nested Class Summary
Nested classes/interfaces inherited from interface IMobileEntity
IMobileEntity.EntityMovedListener -
Field Summary
Fields inherited from class CombatEntity
DEFAULT_HITPOINTSFields inherited from class Entity
ANY_MESSAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAbility(Ability ability) Adds an ability to this creature.booleanChecks whether a registered ability of the specified class can currently be cast.booleanChecks whether a registered ability with the specified name can currently be cast.<T extends Ability>
AbilityExecutionCasts a registered ability of the specified class.Casts a registered ability by name.createAbility(String name) Begins fluently building a newDynamicAbilityfor this creature.protected IEntityAnimationController<? extends Creature> Creates a new animation controller for the creature.protected IMovementControllerCreates a new movement controller for the creature.Gets all abilities currently registered on this creature.getAbility(Class<T> abilityClass) Gets the first ability of the specified class registered on this creature.getAbility(String name) Gets an ability registered on this creature by its name.intGets a value that defines how long it takes the entity to reach the full velocity (in ms).intGets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).Gets the facing direction of the creature based on its current angle.Gets the current spritesheet name of this instance.floatGets the entity's velocity in PIXELS per tick.float[]getTweenValues(TweenType tweenType) Gets one or many values from the target object associated to the given tween type.Gets the entity's velocity in PIXELS per Second.booleanhasAbility(Class<? extends Ability> abilityClass) Checks whether this creature has an ability of the specified class.booleanhasAbility(String name) Checks whether this creature has an ability with the specified name.booleanisIdle()Checks if the creature is idle.booleanisOnCooldown(Class<? extends Ability> abilityClass) Checks whether a registered ability of the specified class is currently on cooldown.booleanisOnCooldown(String name) Checks whether a registered ability with the specified name is currently on cooldown.booleanChecks if the creature's sprite is being scaled with the entity dimensions.movement()Gets the movement controller.voidonMoved(IMobileEntity.EntityMovedListener listener) Adds the specified entity moved listener to receive events when this entity was moved.voidremoveAbility(Ability ability) Removes an ability from this creature.voidremoveAbility(String name) Removes an ability with the specified name from this creature.voidRemoves the specified entity moved listener.voidsetAcceleration(int acceleration) Sets the acceleration for this entity.voidsetDeceleration(int deceleration) Sets the deceleration for this entity.voidsetFacingDirection(Direction facingDirection) Sets the facing direction of the creature.voidsetLocation(Point2D location) Sets the map location.voidsetScaling(boolean scaling) Sets whether the creature's sprite should be scaled with the entity dimensions.voidsetSpritesheetName(String spritesheetName) Sets the spritesheet name for this creature.voidsetTurnOnMove(boolean turn) Sets the turn on move parameter for this entity.voidsetTweenValues(TweenType tweenType, float[] newValues) This method is called in a Tween's update() method to set the new interpolated values.voidsetVelocity(float velocity) Sets the base value on the velocity attribute of this instance.toString()booleanGets the turn on move parameter for this entity.protected voidUpdates the animation controller for the creature.Methods inherited from class CombatEntity
addCombatEntityListener, die, fireDeathEvent, getAppliedEffects, getHitBox, getHitPoints, getTarget, getTeam, hit, hit, isDead, isFriendly, isIndestructible, isNeutral, onDeath, onHit, onResurrect, removeCombatEntityListener, removeListener, removeListener, removeListener, resurrect, setIndestructible, setTarget, setTeam, wasHitMethods inherited from class CollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, hasCollision, onCollision, refreshCollisionBox, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionType, setHeight, setSize, setWidthMethods inherited from class Entity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, canRender, detachControllers, getAngle, getBoundingBox, getCenter, getController, getControllers, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onActionPerformed, onMessage, onMessage, onRendered, perform, register, removeActionPerformedListener, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setYMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ICollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, hasCollision, onCollision, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionTypeMethods inherited from interface IEntity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, detachControllers, getAngle, getBoundingBox, getCenter, getController, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onActionPerformed, onMessage, onMessage, onRendered, perform, register, removeActionPerformedListener, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, renderWithLayer, scripts, sendMessage, setAngle, setController, setHeight, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setSize, setVisible, setWidth, setX, setYMethods inherited from interface IMobileEntity
getAcceleration, getDeceleration
-
Constructor Details
-
Creature
public Creature()Instantiates a newCreatureentity with default settings. -
Creature
Instantiates a newCreatureentity.- Parameters:
spritesheetName- The spritesheet name that identifies the sprites bound to this instance.- See Also:
-
-
Method Details
-
onMoved
Description copied from interface:IMobileEntityAdds the specified entity moved listener to receive events when this entity was moved.
In comparison to the
EntityTransformListener.locationChanged(IEntity)event, this provides some additional information about the movement (e.g. distance) and is only fired if the entity instance is currently loaded.- Specified by:
onMovedin interfaceIMobileEntity- Parameters:
listener- The listener to add.
-
removeMovedListener
Description copied from interface:IMobileEntityRemoves the specified entity moved listener.- Specified by:
removeMovedListenerin interfaceIMobileEntity- Parameters:
listener- The listener to remove.
-
getTweenValues
Description copied from interface:TweenableGets one or many values from the target object associated to the given tween type. It is used by the Tween Engine to determine starting values.- Specified by:
getTweenValuesin interfaceTweenable- Overrides:
getTweenValuesin classCombatEntity- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.- Returns:
- The array of current tween values.
-
setTweenValues
Description copied from interface:TweenableThis method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValuesin interfaceTweenable- Overrides:
setTweenValuesin classCombatEntity- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.newValues- The new values determined by the tween equation.
-
getAcceleration
public int getAcceleration()Description copied from interface:IMobileEntityGets a value that defines how long it takes the entity to reach the full velocity (in ms).- Specified by:
getAccelerationin interfaceIMobileEntity- Returns:
- the acceleration value
-
getDeceleration
public int getDeceleration()Description copied from interface:IMobileEntityGets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).- Specified by:
getDecelerationin interfaceIMobileEntity- Returns:
- the deceleration value
-
getFacingDirection
Gets the facing direction of the creature based on its current angle.- Returns:
- The direction the creature is facing.
-
movement
Description copied from interface:IMobileEntityGets the movement controller.- Specified by:
movementin interfaceIMobileEntity- Returns:
- the movement controller
-
getSpritesheetName
Gets the current spritesheet name of this instance. Overwriting this allows for a more sophisticated logic that determines the sprite to be used; e.g. This method could append certain properties of the creature (state, weapon, ...) to the default string.
The value of this method will be used e.g. by the
CreatureAnimationControllerto determine the animation that it should play.- Returns:
- The current spritesheet name of this instance.
-
getTickVelocity
public float getTickVelocity()Description copied from interface:IMobileEntityGets the entity's velocity in PIXELS per tick.- Specified by:
getTickVelocityin interfaceIMobileEntity- Returns:
- The velocity in pixel per tick.
-
getVelocity
Description copied from interface:IMobileEntityGets the entity's velocity in PIXELS per Second.- Specified by:
getVelocityin interfaceIMobileEntity- Returns:
- the velocity in pixel per second.
-
isScaling
public boolean isScaling()Checks if the creature's sprite is being scaled with the entity dimensions.- Returns:
- true if the sprite is being scaled, false otherwise.
-
isIdle
public boolean isIdle()Checks if the creature is idle.- Returns:
- true if the creature has not moved for a duration longer than the idle delay, false otherwise.
-
setAcceleration
public void setAcceleration(int acceleration) Description copied from interface:IMobileEntitySets the acceleration for this entity. Acceleration is a value that defines how long it takes the entity to reach the full velocity when starting to move (in ms). *- Specified by:
setAccelerationin interfaceIMobileEntity- Parameters:
acceleration- the new acceleration
-
setDeceleration
public void setDeceleration(int deceleration) Description copied from interface:IMobileEntitySets the deceleration for this entity. deceleration is a value that defines how long it takes the entity to stop when slowing down from movements (in ms).- Specified by:
setDecelerationin interfaceIMobileEntity- Parameters:
deceleration- the new deceleration
-
setFacingDirection
Sets the facing direction of the creature.- Parameters:
facingDirection- The direction to set the creature's facing angle to.
-
setLocation
Description copied from class:EntitySets the map location.- Specified by:
setLocationin interfaceIEntity- Overrides:
setLocationin classCollisionEntity- Parameters:
location- the new map location
-
setTurnOnMove
public void setTurnOnMove(boolean turn) Description copied from interface:IMobileEntitySets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.- Specified by:
setTurnOnMovein interfaceIMobileEntity- Parameters:
turn- the new turn on move parameter.
-
setSpritesheetName
Sets the spritesheet name for this creature.- Parameters:
spritesheetName- The name of the spritesheet to set.
-
setScaling
public void setScaling(boolean scaling) Sets whether the creature's sprite should be scaled with the entity dimensions.- Parameters:
scaling- true to scale the sprite, false otherwise.
-
setVelocity
public void setVelocity(float velocity) Description copied from interface:IMobileEntitySets the base value on the velocity attribute of this instance.- Specified by:
setVelocityin interfaceIMobileEntity- Parameters:
velocity- The velocity to be set.- See Also:
-
turnOnMove
public boolean turnOnMove()Description copied from interface:IMobileEntityGets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.- Specified by:
turnOnMovein interfaceIMobileEntity- Returns:
- true, if the entity will change its angle to the direction of the move destination when being moved
-
toString
-
updateAnimationController
protected void updateAnimationController()Updates the animation controller for the creature. This method creates a new animation controller and adds it to the creature's controllers. If the game world environment is loaded, the new controller is attached to the game loop. -
createAnimationController
Creates a new animation controller for the creature.- Returns:
- A new instance of
IEntityAnimationControllerfor the creature.
-
createMovementController
Creates a new movement controller for the creature.- Returns:
- A new instance of
IMovementControllerfor the creature.
-
getAbilities
Gets all abilities currently registered on this creature.- Returns:
- A collection of registered abilities.
-
getAbility
-
getAbility
Gets the first ability of the specified class registered on this creature.- Type Parameters:
T- The ability type.- Parameters:
abilityClass- The class of the ability.- Returns:
- An
Optionalcontaining the ability if found, or empty otherwise.
-
hasAbility
Checks whether this creature has an ability with the specified name.- Parameters:
name- The ability name.- Returns:
- true if the ability exists, false otherwise.
-
hasAbility
-
addAbility
Adds an ability to this creature.- Parameters:
ability- The ability to register.
-
removeAbility
Removes an ability from this creature.- Parameters:
ability- The ability to remove.
-
removeAbility
Removes an ability with the specified name from this creature.- Parameters:
name- The name of the ability to remove.
-
cast
Casts a registered ability by name.- Parameters:
name- The name of the ability to cast.- Returns:
- The
AbilityExecutionif cast successfully, or null otherwise.
-
cast
Casts a registered ability of the specified class.- Type Parameters:
T- The ability type.- Parameters:
abilityClass- The class of the ability to cast.- Returns:
- The
AbilityExecutionif cast successfully, or null otherwise.
-
canCast
Checks whether a registered ability with the specified name can currently be cast.- Parameters:
name- The name of the ability.- Returns:
- true if the ability exists and can be cast, false otherwise.
-
canCast
-
isOnCooldown
Checks whether a registered ability with the specified name is currently on cooldown.- Parameters:
name- The name of the ability.- Returns:
- true if the ability exists and is on cooldown, false otherwise.
-
isOnCooldown
-
createAbility
Begins fluently building a newDynamicAbilityfor this creature.- Parameters:
name- The name of the ability.- Returns:
- An
AbilityBuilderconfigured for this creature.
-