mirror of
https://github.com/Quackster/Havana.git
synced 2025-07-03 05:07:46 +00:00
Cancel teleportation when moving between rooms by using navigator
This commit is contained in:
parent
f25f446232
commit
2ccae8c7ef
5 changed files with 25 additions and 0 deletions
|
@ -67,7 +67,9 @@ public class TeleportInteractor extends GenericTrigger {
|
||||||
var resolved = ItemManager.getInstance().resolveItem(pairId);
|
var resolved = ItemManager.getInstance().resolveItem(pairId);
|
||||||
|
|
||||||
Item pairedTeleporter = resolved != null ? resolved : targetTeleporter;
|
Item pairedTeleporter = resolved != null ? resolved : targetTeleporter;
|
||||||
|
|
||||||
roomUser.setAuthenticateTelporterId(pairedTeleporter.getDatabaseId());
|
roomUser.setAuthenticateTelporterId(pairedTeleporter.getDatabaseId());
|
||||||
|
roomUser.setAuthenticateTelporterRoomId(pairedTeleporter.getRoomId());
|
||||||
|
|
||||||
// Check if the user is inside the teleporter, if so, walk out. Useful if the user is stuck inside.
|
// Check if the user is inside the teleporter, if so, walk out. Useful if the user is stuck inside.
|
||||||
if (item.getPosition().equals(roomUser.getPosition()) && !RoomTile.isValidTile(room, player, item.getPosition().getSquareInFront())) {
|
if (item.getPosition().equals(roomUser.getPosition()) && !RoomTile.isValidTile(room, player, item.getPosition().getSquareInFront())) {
|
||||||
|
@ -124,6 +126,7 @@ public class TeleportInteractor extends GenericTrigger {
|
||||||
}
|
}
|
||||||
|
|
||||||
roomUser.setAuthenticateTelporterId(-1);
|
roomUser.setAuthenticateTelporterId(-1);
|
||||||
|
roomUser.setAuthenticateTelporterRoomId(-1);
|
||||||
|
|
||||||
pairedTeleporter.setCustomData(TELEPORTER_CLOSE);
|
pairedTeleporter.setCustomData(TELEPORTER_CLOSE);
|
||||||
pairedTeleporter.updateStatus();
|
pairedTeleporter.updateStatus();
|
||||||
|
@ -169,6 +172,7 @@ public class TeleportInteractor extends GenericTrigger {
|
||||||
GameScheduler.getInstance().getService().schedule(() -> {
|
GameScheduler.getInstance().getService().schedule(() -> {
|
||||||
if (roomUser.getRoom().getId() != room.getId()) {
|
if (roomUser.getRoom().getId() != room.getId()) {
|
||||||
roomUser.setAuthenticateTelporterId(-1);
|
roomUser.setAuthenticateTelporterId(-1);
|
||||||
|
roomUser.setAuthenticateTelporterRoomId(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*if (roomUser.getAuthenticateTelporterId() == -1) {
|
/*if (roomUser.getAuthenticateTelporterId() == -1) {
|
||||||
|
@ -186,6 +190,7 @@ public class TeleportInteractor extends GenericTrigger {
|
||||||
GameScheduler.getInstance().getService().schedule(() -> {
|
GameScheduler.getInstance().getService().schedule(() -> {
|
||||||
if (roomUser.getRoom().getId() != room.getId()) {
|
if (roomUser.getRoom().getId() != room.getId()) {
|
||||||
roomUser.setAuthenticateTelporterId(-1);
|
roomUser.setAuthenticateTelporterId(-1);
|
||||||
|
roomUser.setAuthenticateTelporterRoomId(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*if (roomUser.getAuthenticateTelporterId() == -1) {
|
/*if (roomUser.getAuthenticateTelporterId() == -1) {
|
||||||
|
@ -193,6 +198,7 @@ public class TeleportInteractor extends GenericTrigger {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
roomUser.setAuthenticateTelporterId(-1);
|
roomUser.setAuthenticateTelporterId(-1);
|
||||||
|
roomUser.setAuthenticateTelporterRoomId(-1);
|
||||||
|
|
||||||
if (pairedTeleporter.getRoomId() == item.getRoomId()) {
|
if (pairedTeleporter.getRoomId() == item.getRoomId()) {
|
||||||
pairedTeleporter.setCustomData(TELEPORTER_CLOSE);
|
pairedTeleporter.setCustomData(TELEPORTER_CLOSE);
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class RoomPlayer extends RoomEntity {
|
||||||
|
|
||||||
private int authenticateId;
|
private int authenticateId;
|
||||||
private long authenticateTelporterId;
|
private long authenticateTelporterId;
|
||||||
|
private long authenticateTelporterRoomId;
|
||||||
private int observingGameId;
|
private int observingGameId;
|
||||||
|
|
||||||
private boolean isTyping;
|
private boolean isTyping;
|
||||||
|
@ -60,6 +61,7 @@ public class RoomPlayer extends RoomEntity {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.authenticateId = -1;
|
this.authenticateId = -1;
|
||||||
this.authenticateTelporterId = -1;
|
this.authenticateTelporterId = -1;
|
||||||
|
this.authenticateTelporterRoomId = -1;
|
||||||
this.tradeItems = new CopyOnWriteArrayList<>();
|
this.tradeItems = new CopyOnWriteArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +225,7 @@ public class RoomPlayer extends RoomEntity {
|
||||||
// Remove authentications
|
// Remove authentications
|
||||||
this.authenticateId = -1;
|
this.authenticateId = -1;
|
||||||
this.authenticateTelporterId = -1;
|
this.authenticateTelporterId = -1;
|
||||||
|
this.authenticateTelporterRoomId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startObservingGame(int gameId) {
|
public void startObservingGame(int gameId) {
|
||||||
|
@ -409,4 +412,12 @@ public class RoomPlayer extends RoomEntity {
|
||||||
public void setLastLobbyRedirection(GameType lastLobbyRedirection) {
|
public void setLastLobbyRedirection(GameType lastLobbyRedirection) {
|
||||||
this.lastLobbyRedirection = lastLobbyRedirection;
|
this.lastLobbyRedirection = lastLobbyRedirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getAuthenticateTelporterRoomId() {
|
||||||
|
return authenticateTelporterRoomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthenticateTelporterRoomId(long authenticateTelporterRoomId) {
|
||||||
|
this.authenticateTelporterRoomId = authenticateTelporterRoomId;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -259,6 +259,7 @@ public class RoomEntityManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getRoomUser().setAuthenticateTelporterId(-1);
|
player.getRoomUser().setAuthenticateTelporterId(-1);
|
||||||
|
player.getRoomUser().setAuthenticateTelporterRoomId(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePlayer gamePlayer = player.getRoomUser().getGamePlayer();
|
GamePlayer gamePlayer = player.getRoomUser().getGamePlayer();
|
||||||
|
|
|
@ -276,6 +276,7 @@ public class RoomMapping {
|
||||||
if (p.getRoomUser().getPosition().equals(oldPosition) ||
|
if (p.getRoomUser().getPosition().equals(oldPosition) ||
|
||||||
p.getRoomUser().getAuthenticateTelporterId() == item.getVirtualId()) {
|
p.getRoomUser().getAuthenticateTelporterId() == item.getVirtualId()) {
|
||||||
p.getRoomUser().setAuthenticateTelporterId(-1);
|
p.getRoomUser().setAuthenticateTelporterId(-1);
|
||||||
|
p.getRoomUser().setAuthenticateTelporterRoomId(-1);
|
||||||
p.getRoomUser().setWalkingAllowed(true);
|
p.getRoomUser().setWalkingAllowed(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,12 @@ public class TRYFLAT implements MessageEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User switched rooms, cancel teleportation
|
||||||
|
if (player.getRoomUser().getAuthenticateTelporterRoomId() != roomId) {
|
||||||
|
player.getRoomUser().setAuthenticateTelporterId(-1);
|
||||||
|
player.getRoomUser().setAuthenticateTelporterRoomId(-1);
|
||||||
|
}
|
||||||
|
|
||||||
player.getRoomUser().setAuthenticateId(roomId);
|
player.getRoomUser().setAuthenticateId(roomId);
|
||||||
player.send(new FLAT_LETIN());
|
player.send(new FLAT_LETIN());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue