Package games.stendhal.client.entity
Class Entity
java.lang.Object
games.stendhal.client.entity.Entity
- All Implemented Interfaces:
IEntity
,RPObjectChangeListener
- Direct Known Subclasses:
ActiveEntity
,Blood
,Chest
,Corpse
,Fire
,GameBoard
,GrainField
,InvisibleEntity
,Item
,PlantGrower
,Sign
,Spell
,StatefulEntity
,Wall
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The entity class.protected boolean
Quick work-around to prevent fireMovementEvent() from calling in onChangedAdded() from other initialize() hack.protected String
The entity name.protected RPObject
The arianne object associated with this game entity.protected String
The entity title.protected String
The entity type.protected double
The current x location of this entity.protected double
The current y location of this entity.Fields inherited from interface games.stendhal.client.entity.IEntity
PROP_ANIMATED, PROP_CLASS, PROP_NAME, PROP_POSITION, PROP_SIZE, PROP_STATE, PROP_TITLE, PROP_VISIBILITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener(EntityChangeListener<?> listener)
Add a change listener.void
addContentChangeListener(ContentChangeListener listener)
Add a listener for content changesvoid
fireChange(games.stendhal.client.entity.Property property)
Fire change to all registered listeners.getArea()
Get the area the entity occupies.gets the name of the cursor to use for this entityGet the entity class.Get the entity sub-class.double
Get the entity height.getID()
getName()
Get the name.int
getPath()
Get identifier path for the entity.int
Get the resistance this has on other entities (0-100).int
getResistance(IEntity entity)
Get the amount of resistance between this and another entity (0-100).Get the RPObject this represents.Gets the slot specified by name.getTitle()
Get the nicely formatted entity title.getType()
Get the entity type.int
Get the entity visibility.double
getWidth()
Get the entity width.double
getX()
Get the X coordinate.double
getY()
Get the Y coordinate.void
initialize(RPObject object)
Initialize this entity for an object.boolean
isObstacle(IEntity entity)
Determine if this is an obstacle for another entity.boolean
Determine if this entity is on the ground.boolean
isUser()
Check if the entity is the user.void
An object was added.void
onChangedAdded(RPObject object, RPObject changes)
The object added/changed attribute(s).void
onChangedRemoved(RPObject object, RPObject changes)
The object removed attribute(s).protected void
onPosition(double x, double y)
When the entity's position changed.void
Deprecated.Moving to different listener.void
onSlotAdded(RPObject object, String slotName, RPObject sobject)
A slot object was added.void
onSlotChangedAdded(RPObject object, String slotName, RPObject sobject, RPObject schanges)
A slot object added/changed attribute(s).void
onSlotChangedRemoved(RPObject object, String slotName, RPObject sobject, RPObject schanges)
A slot object removed attribute(s).void
onSlotRemoved(RPObject object, String slotName, RPObject sobject)
A slot object was removed.protected void
processPositioning(RPObject base, RPObject diff)
Process attribute changes that may affect positioning.void
release()
Release this entity.void
removeChangeListener(EntityChangeListener<?> listener)
Remove a change listener.void
removeContentChangeListener(ContentChangeListener listener)
Remove a content change listener.toString()
void
update(int delta)
Update cycle.
-
Field Details
-
x
protected double xThe current x location of this entity. -
y
protected double yThe current y location of this entity. -
rpObject
The arianne object associated with this game entity. -
clazz
The entity class. -
name
The entity name. -
title
The entity title. -
type
The entity type. -
inAdd
protected boolean inAddQuick work-around to prevent fireMovementEvent() from calling in onChangedAdded() from other initialize() hack. TODO: get rid off inAdd variable.
-
-
Constructor Details
-
Entity
public Entity()
-
-
Method Details
-
addChangeListener
Description copied from interface:IEntity
Add a change listener.- Specified by:
addChangeListener
in interfaceIEntity
- Parameters:
listener
- The listener.
-
addContentChangeListener
Description copied from interface:IEntity
Add a listener for content changes- Specified by:
addContentChangeListener
in interfaceIEntity
-
removeContentChangeListener
Description copied from interface:IEntity
Remove a content change listener.- Specified by:
removeContentChangeListener
in interfaceIEntity
-
fireChange
public void fireChange(games.stendhal.client.entity.Property property)Fire change to all registered listeners.- Parameters:
property
- The changed property.
-
isUser
public boolean isUser()Description copied from interface:IEntity
Check if the entity is the user. -
getArea
Description copied from interface:IEntity
Get the area the entity occupies. -
getVisibility
public int getVisibility()Description copied from interface:IEntity
Get the entity visibility.- Specified by:
getVisibility
in interfaceIEntity
- Returns:
- The entity visibility (0 - 100).
-
getHeight
public double getHeight()Description copied from interface:IEntity
Get the entity height. -
getID
-
getObjectID
public final int getObjectID() -
getEntityClass
Description copied from interface:IEntity
Get the entity class.- Specified by:
getEntityClass
in interfaceIEntity
- Returns:
- The entity class.
-
getName
Description copied from interface:IEntity
Get the name. -
getEntitySubclass
Description copied from interface:IEntity
Get the entity sub-class.- Specified by:
getEntitySubclass
in interfaceIEntity
- Returns:
- The entity sub-class.
-
getTitle
Description copied from interface:IEntity
Get the nicely formatted entity title. This searches the follow attribute order: title, name (w/o underscore), type (w/o underscore). -
getType
Description copied from interface:IEntity
Get the entity type. -
getX
public double getX()Description copied from interface:IEntity
Get the X coordinate. -
getY
public double getY()Description copied from interface:IEntity
Get the Y coordinate. -
getRPObject
Description copied from interface:IEntity
Get the RPObject this represents.- Specified by:
getRPObject
in interfaceIEntity
- Returns:
- The RPObject.
-
getWidth
public double getWidth()Description copied from interface:IEntity
Get the entity width. -
isOnGround
public boolean isOnGround()Description copied from interface:IEntity
Determine if this entity is on the ground.- Specified by:
isOnGround
in interfaceIEntity
- Returns:
true
if the entity is on the ground.
-
processPositioning
Process attribute changes that may affect positioning. This is needed because different entities may want to process coordinate changes more gracefully.- Parameters:
base
- The previous values.diff
- The changes.
-
onPosition
protected void onPosition(double x, double y)When the entity's position changed.- Parameters:
x
- The new X coordinate.y
- The new Y coordinate.
-
getResistance
public int getResistance()Description copied from interface:IEntity
Get the resistance this has on other entities (0-100).- Specified by:
getResistance
in interfaceIEntity
- Returns:
- The resistance.
-
getResistance
Description copied from interface:IEntity
Get the amount of resistance between this and another entity (0-100).- Specified by:
getResistance
in interfaceIEntity
- Parameters:
entity
- The entity to check against.- Returns:
- The effective resistance.
-
getSlot
Description copied from interface:IEntity
Gets the slot specified by name. -
initialize
Description copied from interface:IEntity
Initialize this entity for an object.- Specified by:
initialize
in interfaceIEntity
- Parameters:
object
- The object.- See Also:
IEntity.release()
-
isObstacle
Description copied from interface:IEntity
Determine if this is an obstacle for another entity.- Specified by:
isObstacle
in interfaceIEntity
- Parameters:
entity
- The entity to check against.- Returns:
true
the entity can not enter this entity's area.
-
release
public void release()Description copied from interface:IEntity
Release this entity. This should clean anything that isn't automatically released (such as unregister callbacks, cancel external operations, etc).- Specified by:
release
in interfaceIEntity
- See Also:
IEntity.initialize(RPObject)
-
removeChangeListener
Description copied from interface:IEntity
Remove a change listener.- Specified by:
removeChangeListener
in interfaceIEntity
- Parameters:
listener
- The listener.
-
update
public void update(int delta)Description copied from interface:IEntity
Update cycle. -
onAdded
An object was added.- Specified by:
onAdded
in interfaceRPObjectChangeListener
- Parameters:
object
- The object.
-
onChangedAdded
The object added/changed attribute(s).- Specified by:
onChangedAdded
in interfaceRPObjectChangeListener
- Parameters:
object
- The base object.changes
- The changes.
-
onChangedRemoved
The object removed attribute(s).- Specified by:
onChangedRemoved
in interfaceRPObjectChangeListener
- Parameters:
object
- The base object.changes
- The changes.
-
onRemoved
Deprecated.Moving to different listener. Userelease()
.An object was removed.- Specified by:
onRemoved
in interfaceRPObjectChangeListener
- Parameters:
object
- The object.
-
onSlotAdded
A slot object was added.- Specified by:
onSlotAdded
in interfaceRPObjectChangeListener
- Parameters:
object
- The container object.slotName
- The slot name.sobject
- The slot object.
-
onSlotChangedAdded
public void onSlotChangedAdded(RPObject object, String slotName, RPObject sobject, RPObject schanges)A slot object added/changed attribute(s).- Specified by:
onSlotChangedAdded
in interfaceRPObjectChangeListener
- Parameters:
object
- The base container object.slotName
- The container's slot name.sobject
- The slot object.schanges
- The slot object changes.
-
onSlotChangedRemoved
public void onSlotChangedRemoved(RPObject object, String slotName, RPObject sobject, RPObject schanges)A slot object removed attribute(s).- Specified by:
onSlotChangedRemoved
in interfaceRPObjectChangeListener
- Parameters:
object
- The base container object.slotName
- The container's slot name.sobject
- The slot object.schanges
- The slot object changes.
-
onSlotRemoved
A slot object was removed.- Specified by:
onSlotRemoved
in interfaceRPObjectChangeListener
- Parameters:
object
- The container object.slotName
- The slot name.sobject
- The slot object.
-
toString
-
getCursor
gets the name of the cursor to use for this entity -
getPath
Get identifier path for the entity.
-