gizmoball.gameworld
Interface WorldState

All Known Implementing Classes:
BreakoutWorldState, GameWorldState, PinballWorldState, SimpleWorldState

public interface WorldState

An interface to represent the current state of the world. It includes only the things on the game side of the abstraction barrier, and not anything on the interface side (such as keypress triggers).

Specification Fields

Method Summary
 void addGameObject(GameObject g)
          Adds a GameObject to the current set of objects in the world, and adds it to balls or gizmos, as appropriate
 java.util.List<GameObject> getAllGameObjects()
          Returns the set of all game objects in the world at the moment.
 java.util.List<Ball> getBalls()
          Returns the set of all balls that are in the world.
 java.util.List<Gizmo> getGizmos()
          Returns the set of all gizmos in the world.
 java.util.List<Trigger> getTriggers(GameObject g)
          Returns the set of all triggers that are activated when a certain GameObject is triggered.
 void removeGameObject(GameObject g)
          Removes a GameObject from the current set of objects in the world, also removing it from balls or gizmos, as appropriate
 void update(GameObject oldObject, GameObject newObject)
          Replaces the old object with the new object.
 

Method Detail

getAllGameObjects

java.util.List<GameObject> getAllGameObjects()
Returns the set of all game objects in the world at the moment. This list will be immutable.

Returns:
all game objects (including balls and gizmos). If there are no objects, returns the empty list.

getBalls

java.util.List<Ball> getBalls()
Returns the set of all balls that are in the world. This list will be immutable.

Returns:
all balls in the world. If there are no balls, returns the empty list.

getGizmos

java.util.List<Gizmo> getGizmos()
Returns the set of all gizmos in the world. This list will be immutable.

Returns:
all gizmos in the world. If there are no gizmos, returns the empty list.

getTriggers

java.util.List<Trigger> getTriggers(GameObject g)
Returns the set of all triggers that are activated when a certain GameObject is triggered. This list will be immutable.

Returns:
the triggers corresponding to a GameObject. If there are no triggers, returns an empty list.

addGameObject

void addGameObject(GameObject g)
Adds a GameObject to the current set of objects in the world, and adds it to balls or gizmos, as appropriate

Effects:
adds g to the list of objects

removeGameObject

void removeGameObject(GameObject g)
Removes a GameObject from the current set of objects in the world, also removing it from balls or gizmos, as appropriate

Effects:
removes g from the list of objects

update

void update(GameObject oldObject,
            GameObject newObject)
Replaces the old object with the new object. If you get the old object, make a copy, make some changes, and want to put those changes back into the WorldState, this is how you do it. One important thing, is: pre(getTriggers(oldObject)) = post(getTriggers(newObject))

Requires:
oldObject is an object in this worldstate (importantly, that it hasn't been removed)
Effects:
replaces all references to oldObject with references to newObject