From 82cfc90465c6e85bc0b73a55ea00e7a70438d67f Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 24 Mar 2009 09:30:49 -0400 Subject: Engine: Allowed LoopUntilCollisionMoveEvent to be cancelled --- .../gamestate/mapview/event/EventHandler.java | 1 - .../gamestate/mapview/event/SpecialEvent.java | 2 +- .../specialmove/LoopUntilCollisionMoveEvent.java | 22 ++++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java index 9cb67ba..0255952 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java @@ -6,7 +6,6 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event; import com.fourisland.fourpuzzle.PuzzleApplication; -import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; import com.fourisland.fourpuzzle.util.ResourceNotFoundException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 2daefab..2970056 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java @@ -163,7 +163,7 @@ public class SpecialEvent { /** * Waits until all previously called MoveEvent()s have finished * - * @throws InterruptedException + * @throws InterruptedException */ public void MoveEventWait() throws InterruptedException { diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java index daceffd..f299145 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/LoopUntilCollisionMoveEvent.java @@ -32,14 +32,24 @@ public class LoopUntilCollisionMoveEvent implements MoveEvent { { loc = new Point(); - while ((loc == null) || (!loc.equals(ev.getLocation()))) - { - loc.setLocation(ev.getLocation()); - - for (MoveEvent move : moves) + try { + while ((loc == null) || (!loc.equals(ev.getLocation()))) { - move.doAction(ev); + loc.setLocation(ev.getLocation()); + + for (MoveEvent move : moves) + { + move.doAction(ev); + + if (Thread.currentThread().isInterrupted()) + { + throw new InterruptedException(); + } + } } + } catch (InterruptedException ex) { + /* The special event has been cancelled; Propogate the interrupt to + * the MoveEventThread */ } } -- cgit 1.4.1