Package games.stendhal.server.entity
Class Entity
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
ActiveEntity
,AreaEntity
,ArrestWarrant
,Chest
,Earning
,ExpirationTracker
,Fire
,Gate
,Offer
,PassiveEntity
,PassiveEntityRespawnPoint
,Portal
,Sign
,UseableEntity
,WeatherEntity
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondescribe()
Describes the entity (if a players looks at it).static void
Get horizontal & vertical nodes immediately adjacent to entity's current X,Y coordinates.getArea()
Get the area this object currently occupies.getArea(double ex, double ey)
Returns the area used by this entity.gets the name of the mouse cursor ornull
.getDescriptionName(boolean definite)
Returns the name or something that can be used to identify the entity for the player.getEntitySlot(String name)
gets the named entity slotdouble
Get the entity height.getName()
gets the name of this entityint
Get the resistance this has on other entities (0-100).int
getResistance(Entity entity)
Get the resistance between this and another entity (0-100).getTitle()
Get the nicely formatted entity title/name.double
getWidth()
Get the entity width.int
getX()
Get the entity X coordinate.int
getY()
Get the entity Y coordinate.getZone()
Get the zone this entity is in.boolean
boolean
Check if the other Entity is near enough to be in sight on the client screen.boolean
isObstacle(Entity entity)
Determine if this is an obstacle for another entity.boolean
Checks whether the given entity is directly next to this entity.boolean
Checks whether the given entity is near this entity.void
Notifies the StendhalRPWorld that this entity's attributes have changed.void
onAdded(StendhalRPZone zone)
Called when this object is added to a zone.protected void
onMoved(int oldX, int oldY, int newX, int newY)
Notification of intra-zone position change.void
onRemoved(StendhalRPZone zone)
Called when this object is being removed from a zone.void
sets the name of the mouse cursorvoid
setDescription(String text)
void
setEntityClass(String clazz)
Set the entity class.void
setEntitySubclass(String subclazz)
Set the entity sub-class.void
The menu to display on the client in the format:void
setPosition(int x, int y)
Sets the entity position.void
setResistance(int resistance)
Set resistance this has with other entities.void
setSize(int width, int height)
Set the entity size.void
setVisibility(int visibility)
Set the entity's visibility.slotIterator(Slots slotTypes)
an iterator over slotsan Iterable over slotsdouble
squaredDistance(int x, int y)
This returns square of the distance from this entity to a specific point.double
squaredDistance(Entity other)
This returns square of the distance between this entity and the given one.boolean
stopped()
Is this entity not moving?void
update()
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
area
-
-
Constructor Details
-
Entity
-
Entity
public Entity()
-
-
Method Details
-
generateRPClass
public static void generateRPClass() -
update
public void update() -
hasDescription
public boolean hasDescription() -
setDescription
-
getDescription
-
getTitle
Get the nicely formatted entity title/name.- Returns:
- The title, or
null
if unknown.
-
getX
public int getX()Get the entity X coordinate.- Returns:
- The X coordinate.
-
getY
public int getY()Get the entity Y coordinate.- Returns:
- The Y coordinate.
-
getZone
Get the zone this entity is in.- Returns:
- A zone, or
null
if not in one.
-
stopped
public boolean stopped()Is this entity not moving?- Returns:
- true, if it stopped, false if it is moving
-
getResistance
public int getResistance()Get the resistance this has on other entities (0-100).- Returns:
- The amount of resistance, or 0 if in ghostmode.
-
getResistance
Get the resistance between this and another entity (0-100).- Parameters:
entity
- other entity to be evaluated- Returns:
- The amount of combined resistance.
-
isObstacle
Determine if this is an obstacle for another entity.- Parameters:
entity
- The entity to check against.- Returns:
true
if very high resistance.
-
squaredDistance
This returns square of the distance between this entity and the given one. We're calculating the square because the square root operation would be expensive. As long as we only need to compare distances, it doesn't matter if we compare the distances or the squares of the distances (the square operation is strictly monotonous for positive numbers).- Parameters:
other
- the entity to which the distance should be calculated- Returns:
- double representing the squared distance
-
squaredDistance
public final double squaredDistance(int x, int y)This returns square of the distance from this entity to a specific point. We're calculating the square because the square root operation would be expensive. As long as we only need to compare distances, it doesn't matter if we compare the distances or the squares of the distances (the square operation is strictly monotonous for positive numbers).- Parameters:
x
- The horizontal coordinate of the pointy
- The vertical coordinate of the point- Returns:
- double representing the squared distance
-
nextTo
Checks whether the given entity is directly next to this entity. This method may be optimized over using nextTo(entity, 0.25).- Parameters:
entity
- The entity- Returns:
true
if the entity is next to this.
-
nextTo
Checks whether the given entity is near this entity.- Parameters:
entity
- the entitystep
- The maximum distance- Returns:
- true iff the entity is at most step steps away
-
getAdjacentNodes
Get horizontal & vertical nodes immediately adjacent to entity's current X,Y coordinates. NOTE: This does not compensate for the entity's width & height, it is only meant to get the positions that the entity could potentially move to. -
getArea
Get the area this object currently occupies.- Returns:
- A rectangular area.
-
getArea
Returns the area used by this entity.- Parameters:
ex
- xey
- y- Returns:
- rectangle for the used area
-
onAdded
Called when this object is added to a zone.- Parameters:
zone
- The zone this was added to.
-
onMoved
protected void onMoved(int oldX, int oldY, int newX, int newY)Notification of intra-zone position change.- Parameters:
oldX
- The old X coordinate.oldY
- The old Y coordinate.newX
- The new X coordinate.newY
- The new Y coordinate.
-
onRemoved
Called when this object is being removed from a zone.- Parameters:
zone
- The zone this will be removed from.
-
notifyWorldAboutChanges
public void notifyWorldAboutChanges()Notifies the StendhalRPWorld that this entity's attributes have changed. -
describe
Describes the entity (if a players looks at it).- Returns:
- description from the players point of view
-
getDescriptionName
Returns the name or something that can be used to identify the entity for the player.- Parameters:
definite
- true for "the" and false for "a/an" in case the entity has no name- Returns:
- name
-
getHeight
public double getHeight()Get the entity height.- Returns:
- The height (in world units).
-
getWidth
public double getWidth()Get the entity width.- Returns:
- The width (in world units).
-
setEntityClass
Set the entity class.- Parameters:
clazz
- The class name.
-
setEntitySubclass
Set the entity sub-class.- Parameters:
subclazz
- The sub-class name.
-
setPosition
public final void setPosition(int x, int y)Sets the entity position.This calls
onMoved()
. Note: When placing during a zone change, this call should be done after being removed from the old zone, but before adding to the zone to prevent an erroneous position jump in the zone.- Parameters:
x
- The x position (in world units).y
- The y position (in world units).
-
getOrigin
- Returns:
- The initial position of the entity
-
setResistance
public final void setResistance(int resistance)Set resistance this has with other entities.- Parameters:
resistance
- The amount of resistance (0-100).
-
setSize
public void setSize(int width, int height)Set the entity size.- Parameters:
width
- The width (in world units).height
- The height (in world units).
-
getCursor
gets the name of the mouse cursor ornull
.- Returns:
- name of the mouse cursor or
null
.
-
setCursor
sets the name of the mouse cursor- Parameters:
cursor
- name of cursor
-
setVisibility
public final void setVisibility(int visibility)Set the entity's visibility.- Parameters:
visibility
- The visibility (0-100).
-
isInSight
Check if the other Entity is near enough to be in sight on the client screen.- Parameters:
other
-- Returns:
- true if near enough
-
getEntitySlot
gets the named entity slot- Parameters:
name
- name of entity slot- Returns:
- EntitySlot or
null
-
slotIterator
an iterator over slots- Parameters:
slotTypes
- slot types to include in the iteration- Returns:
- Iterator
-
slots
an Iterable over slots- Parameters:
slotTypes
- slot types to include in the iteration- Returns:
- Iterable
-
setMenu
The menu to display on the client in the format:Display Name 1|action1, Display Name 2|action2
- Parameters:
menu
- menu string
-
getName
gets the name of this entity
-