EigenMeat.EigenMaze
Class EntityFactory

java.lang.Object
  extended byEigenMeat.EigenMaze.EntityFactory

public class EntityFactory
extends java.lang.Object

An EntityFactory will store lists of different types of entities loaded by the SoftLoader. Entities are stored as clonable prototypes - any entity that is to be soft-loadable should follow the pattern of the already defined types and have a prototype pattern subclass that implements Clonable for creation (these are package private and thus have no Javadoc). Entities saved in this class must have a getName() method (as part of the Prototype subclass).

Entities are created from this class by cloning. An instance of the fully initialized entity is saved here, and when a new copy of that type of entity is to be created, it is cloned and added to the engine.


Constructor Summary
EntityFactory()
           
 
Method Summary
 void addEntityType(Entity e)
          Add a new entity to be created.
 void addType(Projectile p)
          Add a new Projectile type to be created.
 void addType(Ship s)
          Add a new Ship type to be created.
 Entity create(java.lang.String name)
          Create a new entity based on the entity stored under the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityFactory

public EntityFactory()
Method Detail

addEntityType

public void addEntityType(Entity e)
Add a new entity to be created. The class of the entity passed will be identified and the entity will be added only if its class is supported (currently Ship and Projectile classes only).


addType

public void addType(Ship s)
Add a new Ship type to be created.


addType

public void addType(Projectile p)
Add a new Projectile type to be created.


create

public Entity create(java.lang.String name)
Create a new entity based on the entity stored under the given name.

Parameters:
name - the name of the entity type to be created.
Returns:
a clone of the entity stored here; or null if the name does not match.