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

public class Entity extends Object implements RPObjectChangeListener, IEntity
  • Field Details

    • x

      protected double x
      The current x location of this entity.
    • y

      protected double y
      The current y location of this entity.
    • rpObject

      protected RPObject rpObject
      The arianne object associated with this game entity.
    • clazz

      protected String clazz
      The entity class.
    • name

      protected String name
      The entity name.
    • title

      protected String title
      The entity title.
    • type

      protected String type
      The entity type.
    • inAdd

      protected boolean inAdd
      Quick 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

      public void addChangeListener(EntityChangeListener<?> listener)
      Description copied from interface: IEntity
      Add a change listener.
      Specified by:
      addChangeListener in interface IEntity
      Parameters:
      listener - The listener.
    • addContentChangeListener

      public void addContentChangeListener(ContentChangeListener listener)
      Description copied from interface: IEntity
      Add a listener for content changes
      Specified by:
      addContentChangeListener in interface IEntity
    • removeContentChangeListener

      public void removeContentChangeListener(ContentChangeListener listener)
      Description copied from interface: IEntity
      Remove a content change listener.
      Specified by:
      removeContentChangeListener in interface IEntity
    • 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.
      Specified by:
      isUser in interface IEntity
      Returns:
      true if the entity is the user
    • getArea

      public Rectangle2D getArea()
      Description copied from interface: IEntity
      Get the area the entity occupies.
      Specified by:
      getArea in interface IEntity
      Returns:
      A rectange (in world coordinate units).
    • getVisibility

      public int getVisibility()
      Description copied from interface: IEntity
      Get the entity visibility.
      Specified by:
      getVisibility in interface IEntity
      Returns:
      The entity visibility (0 - 100).
    • getHeight

      public double getHeight()
      Description copied from interface: IEntity
      Get the entity height.
      Specified by:
      getHeight in interface IEntity
      Returns:
      The height.
    • getID

      public final RPObject.ID getID()
      Specified by:
      getID in interface IEntity
      Returns:
      the represented arianne object id.
    • getObjectID

      public final int getObjectID()
    • getEntityClass

      public String getEntityClass()
      Description copied from interface: IEntity
      Get the entity class.
      Specified by:
      getEntityClass in interface IEntity
      Returns:
      The entity class.
    • getName

      public String getName()
      Description copied from interface: IEntity
      Get the name.
      Specified by:
      getName in interface IEntity
      Returns:
      The name.
    • getEntitySubclass

      public String getEntitySubclass()
      Description copied from interface: IEntity
      Get the entity sub-class.
      Specified by:
      getEntitySubclass in interface IEntity
      Returns:
      The entity sub-class.
    • getTitle

      public String 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).
      Specified by:
      getTitle in interface IEntity
      Returns:
      The title, or null if unknown.
    • getType

      public String getType()
      Description copied from interface: IEntity
      Get the entity type.
      Specified by:
      getType in interface IEntity
      Returns:
      The type.
    • getX

      public double getX()
      Description copied from interface: IEntity
      Get the X coordinate.
      Specified by:
      getX in interface IEntity
      Returns:
      The X coordinate.
    • getY

      public double getY()
      Description copied from interface: IEntity
      Get the Y coordinate.
      Specified by:
      getY in interface IEntity
      Returns:
      The Y coordinate.
    • getRPObject

      public RPObject getRPObject()
      Description copied from interface: IEntity
      Get the RPObject this represents.
      Specified by:
      getRPObject in interface IEntity
      Returns:
      The RPObject.
    • getWidth

      public double getWidth()
      Description copied from interface: IEntity
      Get the entity width.
      Specified by:
      getWidth in interface IEntity
      Returns:
      The width.
    • isOnGround

      public boolean isOnGround()
      Description copied from interface: IEntity
      Determine if this entity is on the ground.
      Specified by:
      isOnGround in interface IEntity
      Returns:
      true if the entity is on the ground.
    • processPositioning

      protected void processPositioning(RPObject base, RPObject diff)
      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 interface IEntity
      Returns:
      The resistance.
    • getResistance

      public int getResistance(IEntity entity)
      Description copied from interface: IEntity
      Get the amount of resistance between this and another entity (0-100).
      Specified by:
      getResistance in interface IEntity
      Parameters:
      entity - The entity to check against.
      Returns:
      The effective resistance.
    • getSlot

      public RPSlot getSlot(String name)
      Description copied from interface: IEntity
      Gets the slot specified by name.
      Specified by:
      getSlot in interface IEntity
      Parameters:
      name - of the slot
      Returns:
      the specified slot or null if the entity does not have this slot
    • initialize

      public void initialize(RPObject object)
      Description copied from interface: IEntity
      Initialize this entity for an object.
      Specified by:
      initialize in interface IEntity
      Parameters:
      object - The object.
      See Also:
      IEntity.release()
    • isObstacle

      public boolean isObstacle(IEntity entity)
      Description copied from interface: IEntity
      Determine if this is an obstacle for another entity.
      Specified by:
      isObstacle in interface IEntity
      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 interface IEntity
      See Also:
      IEntity.initialize(RPObject)
    • removeChangeListener

      public void removeChangeListener(EntityChangeListener<?> listener)
      Description copied from interface: IEntity
      Remove a change listener.
      Specified by:
      removeChangeListener in interface IEntity
      Parameters:
      listener - The listener.
    • update

      public void update(int delta)
      Description copied from interface: IEntity
      Update cycle.
      Specified by:
      update in interface IEntity
      Parameters:
      delta - The time (in ms) since last call.
    • onAdded

      public final void onAdded(RPObject object)
      An object was added.
      Specified by:
      onAdded in interface RPObjectChangeListener
      Parameters:
      object - The object.
    • onChangedAdded

      public void onChangedAdded(RPObject object, RPObject changes)
      The object added/changed attribute(s).
      Specified by:
      onChangedAdded in interface RPObjectChangeListener
      Parameters:
      object - The base object.
      changes - The changes.
    • onChangedRemoved

      public void onChangedRemoved(RPObject object, RPObject changes)
      The object removed attribute(s).
      Specified by:
      onChangedRemoved in interface RPObjectChangeListener
      Parameters:
      object - The base object.
      changes - The changes.
    • onRemoved

      @Deprecated public final void onRemoved(RPObject object)
      Deprecated.
      Moving to different listener. Use release().
      An object was removed.
      Specified by:
      onRemoved in interface RPObjectChangeListener
      Parameters:
      object - The object.
    • onSlotAdded

      public void onSlotAdded(RPObject object, String slotName, RPObject sobject)
      A slot object was added.
      Specified by:
      onSlotAdded in interface RPObjectChangeListener
      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 interface RPObjectChangeListener
      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 interface RPObjectChangeListener
      Parameters:
      object - The base container object.
      slotName - The container's slot name.
      sobject - The slot object.
      schanges - The slot object changes.
    • onSlotRemoved

      public void onSlotRemoved(RPObject object, String slotName, RPObject sobject)
      A slot object was removed.
      Specified by:
      onSlotRemoved in interface RPObjectChangeListener
      Parameters:
      object - The container object.
      slotName - The slot name.
      sobject - The slot object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCursor

      public String getCursor()
      gets the name of the cursor to use for this entity
      Specified by:
      getCursor in interface IEntity
      Returns:
      name of cursor
    • getPath

      public List<String> getPath()
      Get identifier path for the entity.
      Specified by:
      getPath in interface IEntity
      Returns:
      List of object identifiers and slot names that make up the complete path to the entity