Package games.stendhal.server.entity
Class ActiveEntity
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.ActiveEntity
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
Block
,GuidedEntity
An entity that has speed and direction.
-
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
ConstructorDescriptionCreate an active entity.ActiveEntity(RPObject object)
Create an active entity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply movement and process it's reactions.boolean
canMoveTo(int x, int y)
Predict if entity can move to a position.boolean
Predict if entity can move to a position.void
faceto(int x, int y)
Face toward a specified point on the map.void
faceToward(Entity entity)
Face toward an entity.static void
Generate the RPClass (compatible with manual init/order).Get the current facing direction.getDirectionToward(Entity entity)
Get the direction toward an entity.getDirectionToward(Rectangle2D area)
int
Get the resistance this has on other entities (0-100).double
getSpeed()
Get the current speed.int
Retrieves the amount of steps the entity has taken during the current session.protected void
handleLeaveZone(int nx, int ny)
protected void
protected boolean
handlePortal(Portal portal)
protected void
handleSimpleCollision(int nx, int ny)
a simple collision is from tiled collision layer or the edge of the map.boolean
Tells if entity can pass through collision tilesboolean
isFacingToward(Entity entity)
Determine if this entity is facing toward another entity.boolean
isGhost()
Checks whether an entity is a ghost (non physically interactive).protected boolean
Determine if this entity has move at least a whole tile.protected boolean
Determine if zone changes are currently allowed via normal means (non-portal teleportation doesn't count).protected void
move(int x, int y, int nx, int ny)
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 removed from a zone.void
setDirection(Direction dir)
Set the facing direction.void
setIgnoresCollision(boolean ignore)
Set entity to ignore collision tilesvoid
setSpeed(double speed)
Set the movement speed.void
stop()
Stops entity's movement.boolean
stopped()
Checks if the entity is not moving.void
update()
Methods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getDescriptionName, getEntitySlot, getHeight, getName, getOrigin, getResistance, getTitle, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance
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
-
Constructor Details
-
ActiveEntity
public ActiveEntity()Create an active entity. -
ActiveEntity
Create an active entity.- Parameters:
object
- The source object.
-
-
Method Details
-
move
protected void move(int x, int y, int nx, int ny) -
handlePortal
-
handleLeaveZone
protected void handleLeaveZone(int nx, int ny) -
generateRPClass
public static void generateRPClass()Generate the RPClass (compatible with manual init/order). NOTE: This MUST be called during environment initialization. -
isZoneChangeAllowed
protected boolean isZoneChangeAllowed()Determine if zone changes are currently allowed via normal means (non-portal teleportation doesn't count).- Returns:
true
if the entity can change zones.
-
onAdded
Called when this object is added to a zone. -
onRemoved
Called when this object is removed from a zone. -
update
public void update() -
isGhost
public boolean isGhost()Checks whether an entity is a ghost (non physically interactive).- Returns:
true
if in ghost mode.
-
getResistance
public int getResistance()Get the resistance this has on other entities (0-100).- Overrides:
getResistance
in classEntity
- Returns:
- The amount of resistance, or 0 if in ghostmode.
-
faceto
public final void faceto(int x, int y)Face toward a specified point on the map.- Parameters:
x
- Horizontal coordinate of positiony
- Vertical coordinate of position
-
faceToward
Face toward an entity.- Parameters:
entity
- The entity to face toward
-
getDirection
Get the current facing direction.- Returns:
- The facing direction
-
getDirectionToward
Get the direction toward an entity.- Parameters:
entity
- The target entity- Returns:
- A facing direction
-
getDirectionToward
-
isFacingToward
Determine if this entity is facing toward another entity.- Parameters:
entity
- The target entity- Returns:
true
if facing other entity
-
setDirection
Set the facing direction.- Parameters:
dir
- Direction to face toward
-
applyMovement
public void applyMovement()Apply movement and process it's reactions. -
getSpeed
public double getSpeed()Get the current speed.- Returns:
- The current speed, or
0.0
if stopped.
-
getStepsTaken
public int getStepsTaken()Retrieves the amount of steps the entity has taken during the current session.- Returns:
- Steps taken
-
isMoveCompleted
protected boolean isMoveCompleted()Determine if this entity has move at least a whole tile.- Returns:
true
if moved a whole tile
-
onMoved
protected void onMoved(int oldX, int oldY, int newX, int newY)Notification of intra-zone position change. -
setSpeed
public void setSpeed(double speed)Set the movement speed.- Parameters:
speed
- New speed.
-
stop
public void stop()Stops entity's movement. -
stopped
public boolean stopped()Checks if the entity is not moving. -
handleObjectCollision
protected void handleObjectCollision() -
handleSimpleCollision
protected void handleSimpleCollision(int nx, int ny)a simple collision is from tiled collision layer or the edge of the map.- Parameters:
ny
-nx
-
-
ignoresCollision
public boolean ignoresCollision()Tells if entity can pass through collision tiles- Returns:
- ignoreCollision
-
setIgnoresCollision
public void setIgnoresCollision(boolean ignore)Set entity to ignore collision tiles- Parameters:
ignore
-
-
canMoveTo
public boolean canMoveTo(int x, int y)Predict if entity can move to a position.- Parameters:
x
-y
-- Returns:
-
canMoveTo
Predict if entity can move to a position.- Parameters:
pos
-- Returns:
-