Make it easy for derived classes to start and stop the AI ticker if they need
to outside the normal circumstances. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@645 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -1048,14 +1048,9 @@ public class GameManager extends PlaceManager
|
|||||||
_startmsgs = null;
|
_startmsgs = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and register ourselves to receive AI ticks
|
// and potentially register ourselves to receive AI ticks
|
||||||
if (_AIs != null && needsAITick()) {
|
if (_AIs != null && needsAITick()) {
|
||||||
_aiTicker = new Interval(_omgr) {
|
startAITicker();
|
||||||
public void expired () {
|
|
||||||
tickAIs();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
_aiTicker.schedule(AI_TICK_DELAY, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// any players who have not claimed that they are ready should now be given le boote royale
|
// any players who have not claimed that they are ready should now be given le boote royale
|
||||||
@@ -1070,7 +1065,33 @@ public class GameManager extends PlaceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the {@link AIGameTicker} if we're registered as an AI game.
|
* Starts our AI ticker if it is not already started.
|
||||||
|
*/
|
||||||
|
protected void startAITicker ()
|
||||||
|
{
|
||||||
|
if (_aiTicker == null) {
|
||||||
|
_aiTicker = new Interval(_omgr) {
|
||||||
|
public void expired () {
|
||||||
|
tickAIs();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_aiTicker.schedule(AI_TICK_DELAY, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops our AI ticker if it's running.
|
||||||
|
*/
|
||||||
|
protected void stopAITicker ()
|
||||||
|
{
|
||||||
|
if (_aiTicker != null) {
|
||||||
|
_aiTicker.cancel();
|
||||||
|
_aiTicker = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the AI ticker if we're registered as an AI game.
|
||||||
*/
|
*/
|
||||||
protected void tickAIs ()
|
protected void tickAIs ()
|
||||||
{
|
{
|
||||||
@@ -1167,10 +1188,7 @@ public class GameManager extends PlaceManager
|
|||||||
protected void gameDidEnd ()
|
protected void gameDidEnd ()
|
||||||
{
|
{
|
||||||
// remove ourselves from the AI ticker, if applicable
|
// remove ourselves from the AI ticker, if applicable
|
||||||
if (_aiTicker != null) {
|
stopAITicker();
|
||||||
_aiTicker.cancel();
|
|
||||||
_aiTicker = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let our delegates do their business
|
// let our delegates do their business
|
||||||
applyToDelegates(new DelegateOp() {
|
applyToDelegates(new DelegateOp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user