WorldArea

Methods
16
Fields
None

Getting one

WorldArea.new(…)
player:tile():toWorldArea()
client:createMenuEntry(…):getActor():getWorldArea()

Methods

MethodReturnsDescription
getX()numberThe western-most x.
getY()numberThe southern-most y.
getWidth()numberWidth in tiles.
getHeight()numberHeight in tiles.
getPlane()numberThe plane.
contains(WorldPoint)booleanWhether the tile is in the area, on its plane.
contains2D(WorldPoint)booleanWhether the tile is in the area, whatever its plane.
distanceTo(WorldArea)number(WorldArea, WorldArea) -> number: The shortest Chebyshev distance to other, or 2147483647 across planes.
distanceTo(WorldPoint)number
distanceTo2D(WorldArea)number(WorldArea, WorldArea) -> number: The shortest Chebyshev distance to other, ignoring planes.
distanceTo2D(WorldPoint)number
isInMeleeDistance(WorldArea)boolean(WorldArea, WorldArea) -> boolean: Whether other touches this area's edge from outside, cardinally (a diagonal neighbour is not in mele…
isInMeleeDistance(WorldPoint)boolean
intersectsWith(WorldArea)booleanWhether the areas share a tile, on the same plane.
toWorldPoint()WorldPointThe south-west corner.
toWorldPointList(){WorldPoint}Every tile, column by column (x outer, y inner), as a 1-based array.
hasLineOfSightTo(WorldView, WorldArea)boolean(WorldArea, WorldView, WorldArea) -> boolean: Whether some edge tile of this area sees some edge tile of other across wv's line-of-si…
hasLineOfSightTo(WorldView, WorldPoint)boolean
canTravelInDirection(WorldView, number, number)boolean(WorldArea, WorldView, number, number) -> boolean: Whether the whole area can step one tile in the direction of dx, dy (each taken by…
canTravelInDirection(WorldView, number, number, (WorldPoint) -> boolean)boolean
new(number, number, number, number, number)WorldArea(number, number, number, number, number) -> WorldArea: The area width by height from the south-west corner x, y.
new(WorldPoint, number, number)WorldArea

Returned by

MethodReturnsDescription
Actor.getWorldAreaWorldAreaThe world area the actor covers: its world location and size (an NPC's composition size, 1 for a player).
WorldAreaClass.newWorldArea(number, number, number, number, number) -> WorldArea: The area width by height from the south-west corner x, y.
WorldPoint.toWorldAreaWorldAreaThe 1x1 area of this tile.

Method details

distanceTo

distanceTo: ((WorldArea, WorldArea) -> number) & ((WorldArea, WorldPoint) -> number)

(WorldArea, WorldArea) -> number: The shortest Chebyshev distance to other, or 2147483647 across planes.

(WorldArea, WorldPoint) -> number: The shortest Chebyshev distance to the tile, or 2147483647 across planes.

distanceTo2D

distanceTo2D: ((WorldArea, WorldArea) -> number) & ((WorldArea, WorldPoint) -> number)

(WorldArea, WorldArea) -> number: The shortest Chebyshev distance to other, ignoring planes.

(WorldArea, WorldPoint) -> number: The shortest Chebyshev distance to the tile, ignoring planes.

isInMeleeDistance

isInMeleeDistance: ((WorldArea, WorldArea) -> boolean) & ((WorldArea, WorldPoint) -> boolean)

(WorldArea, WorldArea) -> boolean: Whether other touches this area's edge from outside, cardinally (a diagonal neighbour is not in melee distance).

(WorldArea, WorldPoint) -> boolean: Whether the tile touches this area's edge from outside, cardinally.

hasLineOfSightTo

hasLineOfSightTo: ((WorldArea, WorldView, WorldArea) -> boolean) & ((WorldArea, WorldView, WorldPoint) -> boolean)

(WorldArea, WorldView, WorldArea) -> boolean: Whether some edge tile of this area sees some edge tile of other across wv's line-of-sight collision flags. false across planes, off wv's plane, or where an end tile is outside the scene or has no tile; an area never sees one it overlaps. Not necessarily symmetric.

(WorldArea, WorldView, WorldPoint) -> boolean: hasLineOfSightTo(wv, other:toWorldArea()): whether this area sees the tile.

canTravelInDirection

canTravelInDirection: ((WorldArea, WorldView, number, number) -> boolean) & ((WorldArea, WorldView, number, number, (WorldPoint) -> boolean) -> boolean)

(WorldArea, WorldView, number, number) -> boolean: Whether the whole area can step one tile in the direction of dx, dy (each taken by its sign) under wv's movement collision flags. Other actors are not obstacles. Raises NullPointerException when the area's corner is outside the scene, and ArrayIndexOutOfBoundsException when the step leaves the collision map.

(WorldArea, WorldView, number, number, (WorldPoint) -> boolean) -> boolean: As canTravelInDirection(wv, dx, dy), also refusing the tiles extraCondition(tile) answers false for (an NPC's actor collision, say). It is asked tile by tile as the walk goes (the x edge, the y edge, then the diagonal), stopping at the first refusal, and must return a boolean; an error it raises ends the walk and is raised from this call unchanged.

new

new: ((number, number, number, number, number) -> WorldArea) & ((WorldPoint, number, number) -> WorldArea)

(number, number, number, number, number) -> WorldArea: The area width by height from the south-west corner x, y.

(WorldPoint, number, number) -> WorldArea: The area width by height from the south-west corner location, on its plane.