The way we were postponing gameDidStart() and gameDidEnd() until after the

action cleared was ungood. It really only worked for the delegates. Now we
do it in a way that works for the controllers themselves and the delegates.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3189 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-10-29 16:32:10 +00:00
parent 14c3a0515a
commit 78e7fd6837
@@ -1,5 +1,5 @@
// //
// $Id: PuzzleController.java,v 1.18 2004/10/28 19:20:04 mdb Exp $ // $Id: PuzzleController.java,v 1.19 2004/10/29 16:32:10 mdb Exp $
// //
// Narya library - tools for developing networked games // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -343,37 +343,47 @@ public abstract class PuzzleController extends GameController
} }
// documentation inherited // documentation inherited
protected void gameDidStart () public void attributeChanged (AttributeChangedEvent event)
{ {
// we have to postpone all game starting activity until the // deal with game state changes
// current action has ended; only after all the animations have if (event.getName().equals(PuzzleObject.STATE)) {
// been completed will everything be in a state fit for starting switch (event.getIntValue()) {
// back up again case PuzzleObject.IN_PLAY:
fireWhenActionCleared(new ClearPender() { // we have to postpone all game starting activity until the
public int actionCleared () { // current action has ended; only after all the animations have
// do the standard game did start business // been completed will everything be in a state fit for
PuzzleController.super.gameDidStart(); // starting back up again
// we don't always start the action immediately fireWhenActionCleared(new ClearPender() {
return startActionImmediately() ? public int actionCleared () {
RESTART_ACTION : NO_RESTART_ACTION; // do the standard game did start business
} gameDidStart();
}); // we don't always start the action immediately
} return startActionImmediately() ?
RESTART_ACTION : NO_RESTART_ACTION;
}
});
break;
// documentation inherited case PuzzleObject.GAME_OVER:
protected void gameDidEnd () // similarly we haev to postpone game ending activity until
{ // the current action has ended
// clean up and clear out // clean up and clear out
clearAction(); clearAction();
// wait until the action is cleared before we roll down to our
// delegates and do all that business
fireWhenActionCleared(new ClearPender() {
public int actionCleared () {
gameDidEnd();
return CARE_NOT;
}
});
break;
// wait until the action is cleared before we roll down to our default:
// delegates and do all that business super.attributeChanged(event);
fireWhenActionCleared(new ClearPender() { break;
public int actionCleared () {
PuzzleController.super.gameDidEnd();
return CARE_NOT;
} }
}); }
} }
// documentation inherited // documentation inherited