net.sf.tankbattles.simulation.mission
Class AbstractMissionSimulator

java.lang.Object
  extended by net.sf.tankbattles.simulation.mission.AbstractMissionSimulator
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
DeathMatch

public abstract class AbstractMissionSimulator
extends java.lang.Object
implements java.lang.Runnable

Super class for the mission simulators, which check for mission goals. Runs in a separate thread and locks on the same object as the OpenGL and each tank threads for sensible operations. Each concrete subclass has to implement the update() method, checking for mission acomplishment.

Author:
erickpassos

Constructor Summary
AbstractMissionSimulator()
           
 
Method Summary
static AbstractMissionSimulator createInstance(Mission mission, java.lang.Object lock)
          Factory method for concrete instance based on the given configuration.
 Mission getMission()
           
 boolean isFinished()
           
 void run()
          Main thread loop for testing the mission acomplishment.
abstract  void update()
          Called at each loop iteration inside the run method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMissionSimulator

public AbstractMissionSimulator()
Method Detail

createInstance

public static final AbstractMissionSimulator createInstance(Mission mission,
                                                            java.lang.Object lock)
Factory method for concrete instance based on the given configuration.

Parameters:
mission - configuration object.
lock - for concurrency sensible operation
Returns:
the newly created mission simulator object.

getMission

public Mission getMission()

isFinished

public boolean isFinished()

run

public final void run()
Main thread loop for testing the mission acomplishment. Sleeps the thead for some time between each loop iteration to be nice with the other threads. The update polymorfic call is locked on the same object as the render (OpenGL) thread.

Specified by:
run in interface java.lang.Runnable

update

public abstract void update()
Called at each loop iteration inside the run method. Must be implemented by the concrete class and check for mission acomplishment.