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 IUpdateable
TODO: 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 class
Trigger.TriggerActivation
Field Summary
Constructor Summary
Constructors Constructor Description Trigger(Trigger.TriggerActivation activation, java.lang.String message)
Instantiates a newTrigger
entity.Trigger(Trigger.TriggerActivation activation, java.lang.String message, boolean isOneTime)
Instantiates a newTrigger
entity.Trigger(Trigger.TriggerActivation activation, java.lang.String message, boolean isOneTime, int cooldown)
Initializes a new instance of theTrigger
class.Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message)
Instantiates a newTrigger
entity.Trigger(Trigger.TriggerActivation activation, java.lang.String name, java.lang.String message, boolean isOneTime)
Instantiates a newTrigger
entity.Method Summary
Modifier and Type Method Description void
addActivatedListener(TriggerActivatedListener listener)
void
addActivatingCondition(TriggerActivatingCondition condition)
void
addActivator(int mapId)
void
addActivator(IEntity activator)
void
addDeactivatedListener(TriggerDeactivatedListener listener)
void
addTarget(int mapId)
void
addTarget(IEntity target)
void
addTriggerListener(TriggerListener listener)
boolean
canTrigger(ICollisionEntity entity)
Checks whether the specified entity can interact with this trigger.Trigger.TriggerActivation
getActivationType()
java.util.List<java.lang.Integer>
getActivators()
int
getCooldown()
java.lang.String
getMessage()
java.util.List<java.lang.Integer>
getTargets()
boolean
interact(IEntity sender)
boolean
isActivated()
boolean
isOneTimeTrigger()
void
removeActivatedListener(TriggerActivatedListener listener)
void
removeActivatingCondition(TriggerActivatingCondition condition)
void
removeDeactivatedListener(TriggerDeactivatedListener listener)
void
removeTriggerListener(TriggerListener listener)
void
setCooldown(int cooldown)
void
setHeight(double height)
void
setMessage(java.lang.String message)
void
setSize(double width, double height)
void
setWidth(double width)
void
update()
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, setTweenValues
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 newTrigger
entity.- 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 newTrigger
entity.- 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 newTrigger
entity.- 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 newTrigger
entity.- 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 theTrigger
class.- 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:
setHeight
in interfaceIEntity
- Overrides:
setHeight
in classCollisionEntity
setWidth
public void setWidth(double width)- Specified by:
setWidth
in interfaceIEntity
- Overrides:
setWidth
in classCollisionEntity
setSize
public void setSize(double width, double height)- Specified by:
setSize
in interfaceIEntity
- Overrides:
setSize
in classCollisionEntity
setCooldown
public void setCooldown(int cooldown)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 theClientConfiguration
.- Specified by:
update
in interfaceIUpdateable
- See Also:
ClientConfiguration.setMaxFps(int)