Class Land.Portal
raft.kilavuz.runtime
java.lang.Object
  raft.kilavuz.runtime.Land.Portal
All Implemented Interfaces:
Enclosing class:

public class Land.Portal
extends Object
implements Serializable, AStar.Transition
line of (generally) border cells which leads to same sector with same action.

Field Summary
short
action
action required to pass through this portal.
direction
orientation of this portal.
static boolean
DISABLED
constant to indicate portal is disabled
static boolean
ENABLED
constant to indicate portal is enabled
int
id
id of this portal.
boolean
regular
if this portal is regular.
Fields inherited from interface raft.kilavuz.runtime.AStar.Transition
INFINITE_COST
Method Summary
fromNode()
returns the node this transition originates from
short
getAction()
returns the action required to pass through this portal
getCenter()
returns center point of this portal
float
getCost(PathContext context)
returns cost for passing through this portal.
getExplicitCost()
returns explicit cost or null if not set
getLand()
returns enclosing land instance
getUserObject()
returns user defined object
boolean
isEnabled()
returns enabled status of this portal
void
setEnabled(boolean enabled)
set enabled status of this portal.
void
setExplicitCost(Float cost)
explicitly sets cost of passing through this portal.
void
setUserObject(Object userObject)
sets user defined object.
toNode()
returns the node this transition leads to
toString()
returns string representation of this portal
Field Detail
ENABLED
public static final boolean ENABLED
constant to indicate portal is enabled

DISABLED
public static final boolean DISABLED
constant to indicate portal is disabled

id
public final int id
id of this portal. same with the corresponding portal in Grid

regular
public final boolean regular
if this portal is regular. a regular portal is a portal which is created during flood fill and leads to an adjacent sector

direction
public final Direction direction
orientation of this portal. null for non regular portals

action
public final short action
action required to pass through this portal. Land.ACTION_NONE for regular portals which can be passed by simple movement.
See Also:
Method Detail
getAction
public short getAction()
returns the action required to pass through this portal
See Also:

setEnabled
public void setEnabled(boolean enabled)
set enabled status of this portal. a portal is enabled by default. it may be disabled for special purposes

isEnabled
public boolean isEnabled()
returns enabled status of this portal

fromNode
public Land.Sector fromNode()
Description copied from interface: AStar.Transition
returns the node this transition originates from
Specified by:

toNode
public Land.Sector toNode()
Description copied from interface: AStar.Transition
returns the node this transition leads to
Specified by:

getCost
public float getCost(PathContext context)
returns cost for passing through this portal. precedence is as follows:
  • if this portal is not enabled INFINITE_COST is returned
  • if an explicit cost is set, it is returned
  • if this is a regular portal and unit size in context is more than this portal's length INFINITE_COST is returned
  • otherwise euclidian distance (in grid space) betweens centers of owner and destination is returned.

note, specifiying a unit size more than 1 may lead to undesirable side effects especially in enviroments with lots of small sectors/portals. instead of specifying unitSize create different lands for with different unit sizes. see the tutorial for a discussion.

Specified by:
Parameters:
context - more information about pathfinding enviroment.
See Also:

setUserObject
public void setUserObject(Object userObject)
sets user defined object. use when you want to store additional information about this portal. note given object is also serialized when Land is serialized
Parameters:
userObject - user object, null to clear user object
See Also:

getUserObject
public Object getUserObject()
returns user defined object
See Also:

getLand
public Land getLand()
returns enclosing land instance

getCenter
public Land.Point getCenter()
returns center point of this portal

setExplicitCost
public void setExplicitCost(Float cost)
explicitly sets cost of passing through this portal. if an explicit cost is set, it has precedence over regular cost calculation. setting to null removes explicit cost information. explicit cost set on Grid.Portal is transferred to Land.Portal when the land is created

getExplicitCost
public Float getExplicitCost()
returns explicit cost or null if not set

toString
public String toString()
returns string representation of this portal
Overrides:
toString in class Object
Java API documentation generated with DocFlex/Doclet v1.5.2
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc. If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com