gecco.server.core
Class UnitType

java.lang.Object
  |
  +--gecco.server.core.UnitType

public class UnitType
extends Object

This class represents a unit type. A unit type encapsulates information that is common to all units of the same type, such as the image of the unit used at the clients, the event handler for units of this type, the class that implements the unit.

Author:
Henrik Bäärnhielm, Karl Hasselström, Henrik Hägerström

Constructor Summary
UnitType(String _name)
          Constructor for the UnitType object
 
Method Summary
 void addAction(String name, String description, String argumentType, String actionHandlerClassName)
          Adds an action to the unit type.
 String getActionArgumentType(String actionName)
          Gets the argument type of an action associated with this unit type.
 Class getActionClass(String actionName)
          Gets the class implementing a given class, associated with this unit type.
 ActionDefinition getActionDefinition(String actionName)
          Gets the ActionDefinition associated with a given action.
 Collection getActionDefinitions()
          Gets the definitions of all actions associated with this unit type.
 String getActionDescription(String actionName)
          Gets the description of an action associated with this unit type.
 Set getActionNames()
          Gets the names of all actions associated with this unit type.
 double getDoubleProperty(String name)
          Gets the DoubleProperty attribute of the Unit object
 EventHandler getEventHandler()
          Gets the EventHandler attribute of the UnitType object
 byte[] getImageData()
          Gets the ImageData attribute of the UnitType object
 int getIntProperty(String name)
          Gets the IntProperty attribute of the Unit object
 String getName()
          Gets the Name attribute of the UnitType object
 TypedProperties getProperties()
          Gets the Properties attribute of the Unit object
 Object getProperty(String name)
          Gets the Property attribute of the Unit object
 String getPropertyType(String name)
          Gets the PropertyType attribute of the UnitType object
 int getRange()
          Gets the visibility range
 double getRangeSquare()
          Gets the square of the visibility range.
 String getStringProperty(String name)
          Gets the StringProperty attribute of the Unit object
 Class getUnitClass()
          Gets the UnitClass attribute of the UnitType object
 int[] getVisionStart()
          Gets the VisionStart attribute of the UnitType object
 int[] getVisionStop()
          Gets the VisionStop attribute of the UnitType object
 boolean isActionInstantaneous(String actionName)
          Determines if a given action associated with this unit type is instantaneous.
 void setEventHandler(String evtHandlerClassName)
          Sets the EventHandler attribute of the UnitType object
 void setImageData(byte[] _imageData)
          Sets the ImageData attribute of the UnitType object
 void setProperty(String name, double value)
          Sets the DoubleProperty attribute of the UnitType object
 void setProperty(String name, int value)
          Sets the IntProperty attribute of the UnitType object
 void setProperty(String name, String value)
          Sets the StringProperty attribute of the UnitType object
 void setRange(int _range)
          Sets the visibility range of the unit type.
 void setUnitClass(String unitClassName)
          Sets the class that implements units of this type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitType

public UnitType(String _name)
Constructor for the UnitType object
Parameters:
_name - The name of the unit type.
Method Detail

setImageData

public void setImageData(byte[] _imageData)
Sets the ImageData attribute of the UnitType object
Parameters:
_imageData - The new ImageData value

setRange

public void setRange(int _range)
Sets the visibility range of the unit type.
Parameters:
_range - The new range

setEventHandler

public void setEventHandler(String evtHandlerClassName)
Sets the EventHandler attribute of the UnitType object
Parameters:
evtHandlerClassName - The new EventHandler class name.

setUnitClass

public void setUnitClass(String unitClassName)
Sets the class that implements units of this type.
Parameters:
unitClassName - The name of the class.

setProperty

public void setProperty(String name,
                        double value)
Sets the DoubleProperty attribute of the UnitType object
Parameters:
name - The new DoubleProperty name
value - The new DoubleProperty value

setProperty

public void setProperty(String name,
                        int value)
Sets the IntProperty attribute of the UnitType object
Parameters:
name - The new IntProperty name
value - The new IntProperty value

setProperty

public void setProperty(String name,
                        String value)
Sets the StringProperty attribute of the UnitType object
Parameters:
name - The new IntProperty name
value - The new IntProperty value

getName

public String getName()
Gets the Name attribute of the UnitType object
Returns:
The Name value

getImageData

public byte[] getImageData()
Gets the ImageData attribute of the UnitType object
Returns:
The ImageData value

getRange

public int getRange()
Gets the visibility range
Returns:
The visibility range

getRangeSquare

public double getRangeSquare()
Gets the square of the visibility range.
Returns:
The square of the range.

getVisionStart

public int[] getVisionStart()
Gets the VisionStart attribute of the UnitType object
Returns:
The VisionStart value

getVisionStop

public int[] getVisionStop()
Gets the VisionStop attribute of the UnitType object
Returns:
The VisionStop value

getEventHandler

public EventHandler getEventHandler()
Gets the EventHandler attribute of the UnitType object
Returns:
The EventHandler value

getUnitClass

public Class getUnitClass()
Gets the UnitClass attribute of the UnitType object
Returns:
The UnitClass value

getActionNames

public Set getActionNames()
Gets the names of all actions associated with this unit type.
Returns:
The set of names of actions.

getActionDefinitions

public Collection getActionDefinitions()
Gets the definitions of all actions associated with this unit type.
Returns:
The collection of action definitions.

getActionDefinition

public ActionDefinition getActionDefinition(String actionName)
Gets the ActionDefinition associated with a given action.
Parameters:
actionName - The name of the action.
Returns:
The ActionDefinition.

isActionInstantaneous

public boolean isActionInstantaneous(String actionName)
Determines if a given action associated with this unit type is instantaneous. The action MUST be associated with this unit type.
Parameters:
actionName - The name of the action.
Returns:
true if the given action is instantaneous, false otherwise.

getActionClass

public Class getActionClass(String actionName)
Gets the class implementing a given class, associated with this unit type.
Parameters:
actionName - The name of the action.
Returns:
The class of the Action.

getActionDescription

public String getActionDescription(String actionName)
Gets the description of an action associated with this unit type.
Parameters:
actionName - The name of the action.
Returns:
The description of the action.

getActionArgumentType

public String getActionArgumentType(String actionName)
Gets the argument type of an action associated with this unit type.
Parameters:
actionName - The name of the action.
Returns:
The argument type of the action.

getProperties

public TypedProperties getProperties()
Gets the Properties attribute of the Unit object
Returns:
The Properties value

getProperty

public Object getProperty(String name)
Gets the Property attribute of the Unit object
Parameters:
name - Description of Parameter
Returns:
The Property value

getPropertyType

public String getPropertyType(String name)
Gets the PropertyType attribute of the UnitType object
Parameters:
name - Description of Parameter
Returns:
The PropertyType value

getDoubleProperty

public double getDoubleProperty(String name)
Gets the DoubleProperty attribute of the Unit object
Parameters:
name - Description of Parameter
Returns:
The DoubleProperty value

getIntProperty

public int getIntProperty(String name)
Gets the IntProperty attribute of the Unit object
Parameters:
name - Description of Parameter
Returns:
The IntProperty value

getStringProperty

public String getStringProperty(String name)
Gets the StringProperty attribute of the Unit object
Parameters:
name - Description of Parameter
Returns:
The StringProperty value

addAction

public void addAction(String name,
                      String description,
                      String argumentType,
                      String actionHandlerClassName)
Adds an action to the unit type.
Parameters:
name - The name of the action.
description - The description of the action.
argumentType - The argument type of the action.
actionHandlerClassName - The name of the class that implements the action.