Class Trigger
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
de.gurkenlabs.litiengine.entities.Trigger
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,ICollisionEntity,IEntity,IUpdateable,Tweenable,java.util.EventListener
public class Trigger
extends CollisionEntity
implements IUpdateableTODO: Triggers should be able to call entity actions (similar to the current message approach)
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTrigger.TriggerActivationField Summary
Constructor Summary
Constructors Constructor Description Trigger(Trigger.TriggerActivation activation, java.lang.String message)Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, java.lang.String message, boolean isOneTime)Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, java.lang.String message, boolean isOneTime, int cooldown)Initializes a new instance of theTriggerclass.Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message)Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message, boolean isOneTime)Instantiates a newTriggerentity.Method Summary
Modifier and Type Method Description voidaddActivatedListener(TriggerActivatedListener listener)voidaddActivatingCondition(TriggerActivatingCondition condition)voidaddActivator(int mapId)voidaddActivator(IEntity activator)voidaddDeactivatedListener(TriggerDeactivatedListener listener)voidaddTarget(int mapId)voidaddTarget(IEntity target)voidaddTriggerListener(TriggerListener listener)booleancanTrigger(ICollisionEntity entity)Checks whether the specified entity can interact with this trigger.Trigger.TriggerActivationgetActivationType()java.util.List<java.lang.Integer>getActivators()intgetCooldown()java.lang.StringgetMessage()java.util.List<java.lang.Integer>getTargets()booleaninteract(IEntity sender)booleanisActivated()booleanisOneTimeTrigger()voidremoveActivatedListener(TriggerActivatedListener listener)voidremoveActivatingCondition(TriggerActivatingCondition condition)voidremoveDeactivatedListener(TriggerDeactivatedListener listener)voidremoveTriggerListener(TriggerListener listener)voidsetCooldown(int cooldown)voidsetHeight(double height)voidsetMessage(java.lang.String message)voidsetSize(double width, double height)voidsetWidth(double width)voidupdate()This method is called by the game loop on all objects that are attached to the loop.Methods inherited from class de.gurkenlabs.litiengine.entities.CollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, getTweenValues, hasCollision, onCollision, refreshCollisionBox, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionType, setLocation, setTweenValuesMethods inherited from class de.gurkenlabs.litiengine.entities.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, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.gurkenlabs.litiengine.entities.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, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY
Constructor Details
Trigger
Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.
Trigger
public Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message)Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.name- The name of this trigger.message- The message that gets sent by this trigger upon activation.
Trigger
Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.
Trigger
public Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message, boolean isOneTime)Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.name- The name of this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.
Trigger
public Trigger(Trigger.TriggerActivation activation, java.lang.String message, boolean isOneTime, int cooldown)Initializes a new instance of theTriggerclass.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.cooldown- The cooldown that needs to be respected between two activation events.
Method Details
addTriggerListener
removeTriggerListener
addActivatedListener
removeActivatedListener
addActivatingCondition
removeActivatingCondition
addDeactivatedListener
removeDeactivatedListener
addActivator
public void addActivator(int mapId)addActivator
addTarget
public void addTarget(int mapId)addTarget
getActivationType
getActivators
public java.util.List<java.lang.Integer> getActivators()getMessage
public java.lang.String getMessage()getTargets
public java.util.List<java.lang.Integer> getTargets()getCooldown
public int getCooldown()canTrigger
Checks whether the specified entity can interact with this trigger.- Parameters:
entity- The entity.- Returns:
- True if the entity can interact with the trigger; otherwise false.
isOneTimeTrigger
public boolean isOneTimeTrigger()isActivated
public boolean isActivated()interact
setMessage
public void setMessage(java.lang.String message)setHeight
public void setHeight(double height)- Specified by:
setHeightin interfaceIEntity- Overrides:
setHeightin classCollisionEntity
setWidth
public void setWidth(double width)- Specified by:
setWidthin interfaceIEntity- Overrides:
setWidthin classCollisionEntity
setSize
public void setSize(double width, double height)- Specified by:
setSizein interfaceIEntity- Overrides:
setSizein classCollisionEntity
setCooldown
public void setCooldown(int cooldown)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:
ClientConfiguration.setMaxFps(int)
