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
ConstructorsConstructorDescriptionCreate an active entity.ActiveEntity(RPObject object)Create an active entity. -
Method Summary
Modifier and TypeMethodDescriptionvoidApply movement and process it's reactions.booleancanMoveTo(int x, int y)Predict if entity can move to a position.booleanPredict if entity can move to a position.voidfaceto(int x, int y)Face toward a specified point on the map.voidfaceToward(Entity entity)Face toward an entity.static voidGenerate the RPClass (compatible with manual init/order).Get the current facing direction.getDirectionToward(Entity entity)Get the direction toward an entity.getDirectionToward(Rectangle2D area)intGet the resistance this has on other entities (0-100).doublegetSpeed()Get the current speed.intRetrieves the amount of steps the entity has taken during the current session.protected voidhandleLeaveZone(int nx, int ny)protected voidprotected booleanhandlePortal(Portal portal)protected voidhandleSimpleCollision(int nx, int ny)a simple collision is from tiled collision layer or the edge of the map.booleanTells if entity can pass through collision tilesbooleanisFacingToward(Entity entity)Determine if this entity is facing toward another entity.booleanisGhost()Checks whether an entity is a ghost (non physically interactive).protected booleanDetermine if this entity has move at least a whole tile.protected booleanDetermine if zone changes are currently allowed via normal means (non-portal teleportation doesn't count).protected voidmove(int x, int y, int nx, int ny)voidonAdded(StendhalRPZone zone)Called when this object is added to a zone.protected voidonMoved(int oldX, int oldY, int newX, int newY)Notification of intra-zone position change.voidonRemoved(StendhalRPZone zone)Called when this object is removed from a zone.voidsetDirection(Direction dir)Set the facing direction.voidsetIgnoresCollision(boolean ignore)Set entity to ignore collision tilesvoidsetSpeed(double speed)Set the movement speed.voidstop()Stops entity's movement.booleanstopped()Checks if the entity is not moving.voidupdate()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, squaredDistanceMethods 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, writeToJsonMethods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlotsMethods 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, toAttributeStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
trueif 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:
trueif in ghost mode.
-
getResistance
public int getResistance()Get the resistance this has on other entities (0-100).- Overrides:
getResistancein 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:
trueif 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.0if 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:
trueif 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:
-