Class MasterEngine

java.lang.Object
  |
  +--MasterEngine
All Implemented Interfaces:
IMasterEngine

public class MasterEngine
extends java.lang.Object
implements IMasterEngine

The master engine propagates changes to remote engines.


Constructor Summary
MasterEngine()
           
 
Method Summary
 int addBody(Body body)
          Add body to game, assigning it an unique id#.
 void addClient(REngine e)
           
 void bodyChanged(Body body)
          A body advertises unprojectable state changes with this method.
 Body getBody(int id)
           
 java.util.Timer getTimer()
           
 void removeBody(Body body)
           
 void removeBody(int id)
          Remove body by id provided for server bits.
 void removeClient(REngine e)
           
 void replaceBody(Body out, Body in)
           
 void replaceBody(int id, Body body)
          Replace body by id provided for server bits.
 boolean setAcceleration(int id, boolean start)
           
 boolean setFire(int id, boolean start)
           
 boolean setTurn(int id, int direction)
          Change rotation of a ship.
 void setWorld(World newWorld)
           
 java.util.ArrayList snapshotBodies()
          Get a shallow copy of the world's bodies in an ArrayList.
 void stop()
          Stopping cancels all activity of the master engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MasterEngine

public MasterEngine()
Method Detail

getTimer

public java.util.Timer getTimer()

getBody

public Body getBody(int id)

setWorld

public void setWorld(World newWorld)
Specified by:
setWorld in interface IMasterEngine

addBody

public int addBody(Body body)
Description copied from interface: IMasterEngine
Add body to game, assigning it an unique id#. Return the id.
Specified by:
addBody in interface IMasterEngine

removeBody

public void removeBody(Body body)

removeBody

public void removeBody(int id)
Remove body by id provided for server bits.

replaceBody

public void replaceBody(Body out,
                        Body in)

replaceBody

public void replaceBody(int id,
                        Body body)
Replace body by id provided for server bits.
Specified by:
replaceBody in interface IMasterEngine

addClient

public void addClient(REngine e)
Specified by:
addClient in interface IMasterEngine

removeClient

public void removeClient(REngine e)

setTurn

public boolean setTurn(int id,
                       int direction)
Description copied from interface: IMasterEngine
Change rotation of a ship.
Specified by:
setTurn in interface IMasterEngine
Following copied from interface: IMasterEngine
Parameters:
id - id# of body
direction - 1 turns left, 0 stops rotation, -1 turns right.
Returns:
Whether operation was successful.

setAcceleration

public boolean setAcceleration(int id,
                               boolean start)
Specified by:
setAcceleration in interface IMasterEngine

setFire

public boolean setFire(int id,
                       boolean start)
Specified by:
setFire in interface IMasterEngine

bodyChanged

public void bodyChanged(Body body)
A body advertises unprojectable state changes with this method.

snapshotBodies

public java.util.ArrayList snapshotBodies()
Get a shallow copy of the world's bodies in an ArrayList.

stop

public void stop()
Stopping cancels all activity of the master engine.