bubolo
 All Classes Namespaces Functions Variables Enumerator
Public Member Functions | List of all members
bubolo.world.World Interface Reference
Inheritance diagram for bubolo.world.World:
bubolo.world.GameWorld

Public Member Functions

Entity getEntity (UUID id) throws GameLogicException
 
List< EntitygetEntities ()
 
public< T extends Entity > T addEntity (Class< T > c) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, UUID id) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, ControllerFactory controllerFactory) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, UUID id, ControllerFactory controllerFactory) throws GameLogicException
 
void removeEntity (Entity e)
 
void removeEntity (UUID id) throws GameLogicException
 
int getMapWidth ()
 
int getMapHeight ()
 
void update ()
 

Detailed Description

Provides access to game entities. This is the primary interface between the Model and other systems.

Author
BU CS673 - Clone Productions

Definition at line 15 of file World.java.

Member Function Documentation

public<T extends Entity> T bubolo.world.World.addEntity ( Class< T >  c) throws GameLogicException

Performs the following actions:

  1. A new Entity of the specified type is created.
  2. The new Entity is added to the World
  3. A new Sprite is created and added to the Sprites list.
  4. One or more Controllers are created and added to the Controllers list.
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implemented in bubolo.world.GameWorld.

public<T extends Entity> T bubolo.world.World.addEntity ( Class< T >  c,
UUID  id 
) throws GameLogicException
See Also
World::addEntity(Class)
Parameters
c
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
idthe UUID that will be used for the entity.
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implemented in bubolo.world.GameWorld.

public<T extends Entity> T bubolo.world.World.addEntity ( Class< T >  c,
ControllerFactory  controllerFactory 
) throws GameLogicException
See Also
World::addEntity(Class)
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
controllerFactoryan object that implements the ControllerFactory interface. This should be used to override the default controller settings. In other words, use a controller factory to set different controller(s) for an entity than the default.
Returns
reference to the new entity. Note that the entity has already been added to the World.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implemented in bubolo.world.GameWorld.

public<T extends Entity> T bubolo.world.World.addEntity ( Class< T >  c,
UUID  id,
ControllerFactory  controllerFactory 
) throws GameLogicException
See Also
World::addEntity(Class)
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
idthe UUID that will be used for the entity.
controllerFactoryan object that implements the ControllerFactory interface. This should be used to override the default controller settings. In other words, use a controller factory to set different controller(s) for an entity than the default.
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implemented in bubolo.world.GameWorld.

List<Entity> bubolo.world.World.getEntities ( )

Returns the list of all entities in the world. Ordering should not be assumed, and may change between calls.

Returns
the list of entities.

Implemented in bubolo.world.GameWorld.

Entity bubolo.world.World.getEntity ( UUID  id) throws GameLogicException

Returns an entity from a user id. Throws a GameLogicException if the entity is not found.

Parameters
idthe entity's unique id.
Returns
the requested entity.
Exceptions
GameLogicExceptionif the entity is not found.

Implemented in bubolo.world.GameWorld.

int bubolo.world.World.getMapHeight ( )

Returns the height of the game map.

Returns
the width of the game map.

Implemented in bubolo.world.GameWorld.

int bubolo.world.World.getMapWidth ( )

Returns the width of the game map.

Returns
the width of the game map.

Implemented in bubolo.world.GameWorld.

void bubolo.world.World.removeEntity ( Entity  e)

Removes an entity from the world. After this method is called, the specified entity will no longer be drawn or updated.

Parameters
ethe entity to remove.

Implemented in bubolo.world.GameWorld.

void bubolo.world.World.removeEntity ( UUID  id) throws GameLogicException

Removes an entity from the world. After this method is called, the specified entity will no longer be drawn or updated. Throws a GameLogicException if the entity is not found.

Parameters
idthe unique id of the entity to remove.
Exceptions
GameLogicExceptionif the entity is not found.

Implemented in bubolo.world.GameWorld.

void bubolo.world.World.update ( )

Updates the game world. Must be called once per game tick.

Implemented in bubolo.world.GameWorld.