wyvern.lib.properties
Class Appearance

java.lang.Object
  extended bywyvern.lib.properties.Appearance
All Implemented Interfaces:
java.lang.Cloneable, Direction.Dirs, MutableProperty

public final class Appearance
extends java.lang.Object
implements java.lang.Cloneable, MutableProperty, Direction.Dirs

This property encapsulates an object's bitmap & category, and updates the bitmap number (a reference into the bitmap database) every time either is changed.

Version:
1.0, Jan 04, 1998
Author:
Steve Yegge

Field Summary
static int ACTIVE_LAYER
          Layer for airborne objects such as spells, missiles.
static int DYNAMIC_LAYER
          The default layer that objects are placed in if they have no special drawing properties.
static int FIXED_LAYER
          Layer for buildings, signs, and other fixed objects.
static int GROUND_LAYER
          Layer for the terrain.
static int INVISIBLE
          A value indicating that an object specifically desires to be invisible.
static int LIGHTING_LAYER
          Layer for lighting (actually, darkness) effects.
static int LIVING_LAYER
          Layer for living objects.
static int UNDERGROUND
          Put objects in this layer to hide them from view.
static int WEATHER_LAYER
          Layer for weather and atmospheric effects.
 
Fields inherited from interface wyvern.lib.Direction.Dirs
DOWN, E, EAST, ILLEGAL_DIR, N, NE, NONE, NORTH, NW, S, SE, SOUTH, SW, UP, W, WEST
 
Constructor Summary
Appearance()
          Constructs a new Appearance.
Appearance(GameObject obj)
          Constructs a new Appearance for the specified GameObject.
Appearance(java.lang.String cat, java.lang.String bmp, GameObject obj)
          Constructs a new Appearance.
 
Method Summary
 java.lang.Object createClone()
          Clones the property so that instances get their own copy.
 void cycleFrame()
          Moves to next frame in animation cycle.
 void destroy()
          Dismantles this Appearance object.
 boolean equals(java.lang.Object o)
          Returns true if the passed appearance matches this one well enough for them to pass as "equal".
 int getAlpha()
          Returns the alpha value for this appearance (1-100).
 java.lang.String getBitmap()
          Returns the underlying bitmap string for this property.
 java.lang.String getCategory()
          Returns the underlying bitmap category for this property.
 int getDirection()
          Returns the direction this object is facing.
 int getFrame()
          Returns the current animation frame number for the appearance.
 GameObject getGameObject()
          Returns the object we're the Appearance for.
 java.lang.String getImage()
          Returns the image (category + bmp)
 TileInfo getInfo()
          Returns the TileInfo for this category/bitmap, if any.
 int getLayer()
          Retrieves the drawing layer for this object.
 int getTile()
          Returns the underlying bitmap number for this property.
 int hashCode()
          Returns the hashcode for this object.
static java.lang.String layerToString(int layer)
          Returns a string representation of a layer constant.
 void resetNumber()
          Resets the bitmap number from the bitmap & category (and if present, direction and animation frame).
 void setAlpha(int alpha)
          Sets the alpha value for this appearance (1-100).
 void setBitmap(java.lang.String bitmap)
          Sets the underlying Bitmap string for this property.
 void setCategory(java.lang.String category)
          Sets the underlying category string for this object.
 void setDirection(int dir)
          Sets the direction for this object.
 void setFrame(int frame)
          Sets the current animation frame number for the appearance.
 void setGameObject(GameObject obj)
          Sets the object we negotiate with over the appearance.
 void setImage(java.lang.String image)
          Sets the image (relative path + filename) for this object.
 void setImage(java.lang.String category, java.lang.String bmp)
          Sets the image (relative path + filename) for this object.
 void setLayer(int layer)
          Sets the drawing layer for this object.
 java.lang.String toString()
          Prints out a String representation of this Appearance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDERGROUND

public static final int UNDERGROUND
Put objects in this layer to hide them from view.

See Also:
Constant Field Values

GROUND_LAYER

public static final int GROUND_LAYER
Layer for the terrain.

See Also:
Constant Field Values

FIXED_LAYER

public static final int FIXED_LAYER
Layer for buildings, signs, and other fixed objects. Roads are typically around -800.

See Also:
Constant Field Values

DYNAMIC_LAYER

public static final int DYNAMIC_LAYER
The default layer that objects are placed in if they have no special drawing properties. NOTE: if an object is normally placed in a nonzero layer, you can't override it to be in layer zero. You have to use layer -1 or 1 (or any nonzero integer). The problem is that most classes only set their default layer if they see the layer is zero; i.e. they assume zero means "not set". So generally speaking, in archetypes you should not set layer = 0.

See Also:
Constant Field Values

LIVING_LAYER

public static final int LIVING_LAYER
Layer for living objects.

See Also:
Constant Field Values

ACTIVE_LAYER

public static final int ACTIVE_LAYER
Layer for airborne objects such as spells, missiles.

See Also:
Constant Field Values

WEATHER_LAYER

public static final int WEATHER_LAYER
Layer for weather and atmospheric effects.

See Also:
Constant Field Values

LIGHTING_LAYER

public static final int LIGHTING_LAYER
Layer for lighting (actually, darkness) effects.

See Also:
Constant Field Values

INVISIBLE

public static final int INVISIBLE
A value indicating that an object specifically desires to be invisible. An object may have a reference in a map but not wish to be seen at that location. Simply returning -1 from GameObject.getTile() will cause some cameras to try to compute an appearance for the object by clipping its primary bitmap. Returning this value will prevent such mayhem.

See Also:
Constant Field Values
Constructor Detail

Appearance

public Appearance()
Constructs a new Appearance. The object the Appearance is "driving" may be set later via setGameObject().


Appearance

public Appearance(GameObject obj)
Constructs a new Appearance for the specified GameObject.


Appearance

public Appearance(java.lang.String cat,
                  java.lang.String bmp,
                  GameObject obj)
Constructs a new Appearance. This constructor calls resetNumber() to compute the correct directional bitmap, so the object's direction should be set before calling this constructor.

Method Detail

layerToString

public static java.lang.String layerToString(int layer)
Returns a string representation of a layer constant.

Parameters:
layer - the drawing layer
Returns:
a String name for the layer

getBitmap

public java.lang.String getBitmap()
Returns the underlying bitmap string for this property.

Returns:
the bitmap string associated with this Appearance

getCategory

public java.lang.String getCategory()
Returns the underlying bitmap category for this property.

Returns:
the BitmapCategory string associated with this property.

getTile

public int getTile()
Returns the underlying bitmap number for this property.

Returns:
the bitmap number associated with this property.

setBitmap

public void setBitmap(java.lang.String bitmap)
Sets the underlying Bitmap string for this property.

Parameters:
bitmap - the bitmap string to use for the object

setCategory

public void setCategory(java.lang.String category)
Sets the underlying category string for this object.

Parameters:
category - the database category to use for the object

setImage

public void setImage(java.lang.String category,
                     java.lang.String bmp)
Sets the image (relative path + filename) for this object.


setImage

public void setImage(java.lang.String image)
Sets the image (relative path + filename) for this object.

Parameters:
image - a relative image, such as "players/paladin_male", or "wiz/foobar/hof/bigdude"

getImage

public java.lang.String getImage()
Returns the image (category + bmp)


getLayer

public int getLayer()
Retrieves the drawing layer for this object.

Returns:
the drawing layer

setLayer

public void setLayer(int layer)
Sets the drawing layer for this object.

Parameters:
layer - the new layer

getAlpha

public int getAlpha()
Returns the alpha value for this appearance (1-100).

Returns:
the alpha value (1-100)

setAlpha

public void setAlpha(int alpha)
Sets the alpha value for this appearance (1-100).

Parameters:
alpha - the alpha value

setFrame

public void setFrame(int frame)
Sets the current animation frame number for the appearance. Use with caution: if the frame number is invalid, the object may become invisible.


getFrame

public int getFrame()
Returns the current animation frame number for the appearance.


setDirection

public void setDirection(int dir)
Sets the direction for this object. Direction is not applicable to all objects. Setting the direction on an object whose bitmap doesn't have different directions available will result in the object having no valid bitmap.

Parameters:
dir - a valid wyvern.lib.Direction constant, including Direction.NONE. Direction.ILLEGAL_DIR is not a valid parameter.

getDirection

public int getDirection()
Returns the direction this object is facing.


setGameObject

public void setGameObject(GameObject obj)
Sets the object we negotiate with over the appearance. This object is normally not consulted, unless it has properties that modify the behavior of the Appearance.


getGameObject

public GameObject getGameObject()
Returns the object we're the Appearance for.

Returns:
our associated game object. Might not be set, in which case we return null.

resetNumber

public void resetNumber()
Resets the bitmap number from the bitmap & category (and if present, direction and animation frame). Called automatically when you call setBitmap() or setCategory().


cycleFrame

public void cycleFrame()
Moves to next frame in animation cycle.


getInfo

public TileInfo getInfo()
Returns the TileInfo for this category/bitmap, if any.

Returns:
null if we don't have any info

toString

public java.lang.String toString()
Prints out a String representation of this Appearance.


createClone

public java.lang.Object createClone()
Clones the property so that instances get their own copy.

Specified by:
createClone in interface MutableProperty
Returns:
a shallow clone of the object

equals

public boolean equals(java.lang.Object o)
Returns true if the passed appearance matches this one well enough for them to pass as "equal".

Parameters:
o - another Appearance object

hashCode

public int hashCode()
Returns the hashcode for this object.


destroy

public void destroy()
Dismantles this Appearance object.