Added leavePlace() for games where you are sometimes not in any "place" at
all. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3638 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -188,6 +188,23 @@ public class LocationDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issues a request to leave our current location.
|
||||||
|
*
|
||||||
|
* @return true if we were able to leave, false if we are in the
|
||||||
|
* middle of moving somewhere and can't yet leave.
|
||||||
|
*/
|
||||||
|
public boolean leavePlace ()
|
||||||
|
{
|
||||||
|
if (_pendingPlaceId != -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lservice.leavePlace(_ctx.getClient());
|
||||||
|
didLeavePlace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can be called by cooperating directors that need to coopt the
|
* This can be called by cooperating directors that need to coopt the
|
||||||
* moving process to extend it in some way or other. In such
|
* moving process to extend it in some way or other. In such
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: LocationService.java,v 1.9 2004/08/27 02:12:33 mdb Exp $
|
// $Id$
|
||||||
//
|
//
|
||||||
// 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
|
||||||
@@ -57,4 +57,9 @@ public interface LocationService extends InvocationService
|
|||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
public void moveTo (Client client, int placeId, MoveListener listener);
|
public void moveTo (Client client, int placeId, MoveListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that we leave our current place and move to nowhere land.
|
||||||
|
*/
|
||||||
|
public void leavePlace (Client client);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,19 @@ public class LocationMarshaller extends InvocationMarshaller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The method id used to dispatch {@link #leavePlace} requests. */
|
||||||
|
public static final int LEAVE_PLACE = 1;
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public void leavePlace (Client arg1)
|
||||||
|
{
|
||||||
|
sendRequest(arg1, LEAVE_PLACE, new Object[] {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** The method id used to dispatch {@link #moveTo} requests. */
|
/** The method id used to dispatch {@link #moveTo} requests. */
|
||||||
public static final int MOVE_TO = 1;
|
public static final int MOVE_TO = 2;
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void moveTo (Client arg1, int arg2, LocationService.MoveListener arg3)
|
public void moveTo (Client arg1, int arg2, LocationService.MoveListener arg3)
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ public class LocationDispatcher extends InvocationDispatcher
|
|||||||
throws InvocationException
|
throws InvocationException
|
||||||
{
|
{
|
||||||
switch (methodId) {
|
switch (methodId) {
|
||||||
|
case LocationMarshaller.LEAVE_PLACE:
|
||||||
|
((LocationProvider)provider).leavePlace(
|
||||||
|
source
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
case LocationMarshaller.MOVE_TO:
|
case LocationMarshaller.MOVE_TO:
|
||||||
((LocationProvider)provider).moveTo(
|
((LocationProvider)provider).moveTo(
|
||||||
source,
|
source,
|
||||||
|
|||||||
@@ -75,6 +75,15 @@ public class LocationProvider
|
|||||||
listener.moveSucceeded(moveTo((BodyObject)caller, placeId));
|
listener.moveSucceeded(moveTo((BodyObject)caller, placeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that we leave our current place and move to nowhere land.
|
||||||
|
*/
|
||||||
|
public void leavePlace (ClientObject caller)
|
||||||
|
throws InvocationException
|
||||||
|
{
|
||||||
|
leaveOccupiedPlace((BodyObject)caller);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the specified body from whatever location they currently
|
* Moves the specified body from whatever location they currently
|
||||||
* occupy to the location identified by the supplied place id.
|
* occupy to the location identified by the supplied place id.
|
||||||
|
|||||||
Reference in New Issue
Block a user