Class EntityAttributes
java.lang.Object
fr.r1r0r0.deltaengine.model.elements.entity.EntityAttributes
public final class EntityAttributes
extends java.lang.Object
All attributes of an Entity.
Used to get and store all Entity attributes, and define actions when these attributes are updated
-
Field Summary
Fields Modifier and Type Field Description private AI
attachedAI
private java.util.Map<Entity,Event>
collisionsEvents
private Coordinates<java.lang.Double>
coordinates
private java.util.Collection<AttributeListener<Coordinates<java.lang.Double>>>
coordinatesListeners
private Dimension
dimension
private java.util.Collection<AttributeListener<Dimension>>
dimensionListeners
private Direction
direction
private java.util.Collection<AttributeListener<Direction>>
directionListeners
private Dimension
hitBox
private java.util.Collection<AttributeListener<Dimension>>
hitBoxListeners
private java.lang.String
name
private double
speed
private java.util.Collection<AttributeListener<java.lang.Double>>
speedListeners
private Sprite
sprite
private java.util.Collection<AttributeListener<Sprite>>
spriteListeners
-
Constructor Summary
Constructors Constructor Description EntityAttributes(java.lang.String name, Coordinates<java.lang.Double> coordinates, Sprite sprite, Dimension dimension, Dimension hitBox, Direction direction, double speed)
Default constructor. -
Method Summary
Modifier and Type Method Description void
addCoordinatesListener(AttributeListener<Coordinates<java.lang.Double>> e)
Set a new listener to the Coordinates attribute.void
addDimensionListener(AttributeListener<Dimension> e)
Set a new listener to the Dimension attribute.void
addDirectionListener(AttributeListener<Direction> e)
Set a new listener to the Direction attribute.void
addSpeedListener(AttributeListener<java.lang.Double> e)
Set a new listener to the Speed attribute.void
addSpriteListener(AttributeListener<Sprite> e)
Set a new listener to the Sprite attribute.AI
getAttachedAI()
Get current AI of the entityjava.util.Map<Entity,Event>
getCollisionsEvents()
Get map of collisions event, to produce actions when entities collide each othersCoordinates<java.lang.Double>
getCoordinates()
Get current position of the entityDimension
getDimension()
Get current dimension of the entityDirection
getDirection()
Get current direction of the entityDimension
getHitBox()
Return the attribute hit-boxjava.lang.String
getName()
Returns name of the entitydouble
getSpeed()
Get current speed of the entitySprite
getSprite()
Get current sprite of the entityvoid
setAttachedAI(Entity entity, AI ai)
AI to attach to the entity.void
setCoordinates(Coordinates<java.lang.Double> coordinates)
Set new position of the entity and triggers all associated triggersvoid
setDimension(Dimension dimension)
Set new dimension for the entity and triggers all associated triggersvoid
setDirection(Direction direction)
Set new direction for the entity and triggers all associated triggersvoid
setHitBox(Dimension dimension)
Setter for the attribute hitBoxvoid
setSpeed(double speed)
Set new speed for the entity and triggers all associated triggersvoid
setSprite(Sprite sprite)
Set new sprite for the entity and triggers all associated triggersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
name
private final java.lang.String name -
coordinates
-
sprite
-
dimension
-
hitBox
-
direction
-
speed
private double speed -
attachedAI
-
collisionsEvents
-
coordinatesListeners
private final java.util.Collection<AttributeListener<Coordinates<java.lang.Double>>> coordinatesListeners -
spriteListeners
-
dimensionListeners
-
hitBoxListeners
-
directionListeners
-
speedListeners
-
-
Constructor Details
-
EntityAttributes
EntityAttributes(java.lang.String name, Coordinates<java.lang.Double> coordinates, Sprite sprite, Dimension dimension, Dimension hitBox, Direction direction, double speed)Default constructor. Inits all attributes of an Entity- Parameters:
name
- name of entitycoordinates
- initial coordinates of entitysprite
- initial sprite of entitydimension
- dimension of entityhitBox
- a hit-boxdirection
- initial direction of entityspeed
- initial speed of entity
-
-
Method Details
-
getName
public java.lang.String getName()Returns name of the entity- Returns:
- String name of the entity
-
getCoordinates
Get current position of the entity- Returns:
- Coordinates of the entity
-
setCoordinates
Set new position of the entity and triggers all associated triggers- Parameters:
coordinates
- Coordinates to set
-
getSprite
Get current sprite of the entity- Returns:
- Sprite of the entity
-
setSprite
Set new sprite for the entity and triggers all associated triggers- Parameters:
sprite
- Sprite new sprite to apply
-
getDimension
Get current dimension of the entity- Returns:
- Dimension of the entity
-
setDimension
Set new dimension for the entity and triggers all associated triggers- Parameters:
dimension
- new Dimension of the entity
-
getHitBox
Return the attribute hit-box- Returns:
- the attribute hit-box
-
setHitBox
Setter for the attribute hitBox- Parameters:
dimension
- a dimension
-
getDirection
Get current direction of the entity- Returns:
- Direction current direction of the entity
-
setDirection
Set new direction for the entity and triggers all associated triggers- Parameters:
direction
- new Direction to apply
-
getSpeed
public double getSpeed()Get current speed of the entity- Returns:
- double current speed
-
setSpeed
public void setSpeed(double speed)Set new speed for the entity and triggers all associated triggers- Parameters:
speed
- double new speed to apply
-
getAttachedAI
Get current AI of the entity- Returns:
- AI of the entity
-
setAttachedAI
AI to attach to the entity. Can be called once. Once AI is attached, it is impossible to remove or change it.- Parameters:
entity
- Entity concernedai
- AI to bind- Throws:
AIAlreadyAttachedException
- if an AI is already attached to this entity
-
getCollisionsEvents
Get map of collisions event, to produce actions when entities collide each others- Returns:
- Map of all registered collision events
-
addCoordinatesListener
Set a new listener to the Coordinates attribute. Listener will be executed when Coordinates are updated.- Parameters:
e
- listener to add
-
addSpriteListener
Set a new listener to the Sprite attribute. Listener will be executed when Sprite is updated.- Parameters:
e
- listener to add
-
addDimensionListener
Set a new listener to the Dimension attribute. Listener will be executed when Dimension is updated.- Parameters:
e
- listener to add
-
addDirectionListener
Set a new listener to the Direction attribute. Listener will be executed when Direction is updated.- Parameters:
e
- listener to add
-
addSpeedListener
Set a new listener to the Speed attribute. Listener will be executed when Speed is updated.- Parameters:
e
- listener to add
-