Various game fixes

This commit is contained in:
Beny 2019-05-05 03:51:27 +01:00
parent a692d2fbf0
commit b0cac91fb6
11 changed files with 156 additions and 177 deletions

View File

@ -25,28 +25,19 @@ import java.util.Map;
public abstract class Game implements Runnable public abstract class Game implements Runnable
{ {
public final Class<? extends GameTeam> gameTeamClazz; private final Class<? extends GameTeam> gameTeamClazz;
public final Class<? extends GamePlayer> gamePlayerClazz;
private final Class<? extends GamePlayer> gamePlayerClazz;
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>(); protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
protected final Room room; protected final Room room;
private final boolean countsAchievements;
protected final boolean countsAchievements; private int startTime;
private int endTime;
protected int startTime;
protected int pauseTime;
protected int endTime;
public boolean isRunning; public boolean isRunning;
@ -133,6 +124,7 @@ public abstract class Game implements Runnable
} }
} }
/*
boolean deleteGame = true; boolean deleteGame = true;
for (GameTeam team : this.teams.values()) for (GameTeam team : this.teams.values())
{ {
@ -147,6 +139,7 @@ public abstract class Game implements Runnable
{ {
this.room.deleteGame(this); this.room.deleteGame(this);
} }
*/
} }
@ -172,6 +165,8 @@ public abstract class Game implements Runnable
} }
public void onEnd() { public void onEnd() {
this.endTime = Emulator.getIntUnixTimestamp();
this.saveScores(); this.saveScores();
GameTeam winningTeam = null; GameTeam winningTeam = null;
@ -214,7 +209,6 @@ public abstract class Game implements Runnable
if (this.state.equals(GameState.RUNNING)) if (this.state.equals(GameState.RUNNING))
{ {
this.state = GameState.PAUSED; this.state = GameState.PAUSED;
this.pauseTime = Emulator.getIntUnixTimestamp();
} }
} }
@ -223,14 +217,12 @@ public abstract class Game implements Runnable
if (this.state.equals(GameState.PAUSED)) if (this.state.equals(GameState.PAUSED))
{ {
this.state = GameState.RUNNING; this.state = GameState.RUNNING;
this.endTime = Emulator.getIntUnixTimestamp() + (this.endTime - this.pauseTime);
} }
} }
public void stop() public void stop()
{ {
this.state = GameState.IDLE; this.state = GameState.IDLE;
this.endTime = Emulator.getIntUnixTimestamp();
boolean gamesActive = false; boolean gamesActive = false;
for(HabboItem timer : room.getFloorItems()) for(HabboItem timer : room.getFloorItems())
@ -302,27 +294,33 @@ public abstract class Game implements Runnable
} }
} }
public Room getRoom() public Room getRoom()
{ {
return this.room; return this.room;
} }
public int getStartTime() public int getStartTime()
{ {
return this.startTime; return this.startTime;
} }
public Class<? extends GameTeam> getGameTeamClass() {
public int getEndTime() return gameTeamClazz;
{
return this.endTime;
} }
public Class<? extends GamePlayer> getGamePlayerClass() {
return gamePlayerClazz;
}
public void addTime(int time) public THashMap<GameTeamColors, GameTeam> getTeams() {
{ return teams;
this.endTime += time; }
public boolean isCountsAchievements() {
return countsAchievements;
}
public GameState getState() {
return state;
} }
} }

View File

@ -175,7 +175,7 @@ public class BattleBanzaiGame extends Game
timer.setRunning(false); timer.setRunning(false);
} }
InteractionGameTimer.endGames(room); InteractionGameTimer.endGames(room, true);
} }
} }
catch (Exception e) catch (Exception e)
@ -267,22 +267,6 @@ public class BattleBanzaiGame extends Game
} }
} }
public void addPositionToGate(GameTeamColors teamColor)
{
for (InteractionBattleBanzaiGate gate : this.room.getRoomSpecialTypes().getBattleBanzaiGates().values())
{
if (gate.teamColor != teamColor)
continue;
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
continue;
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
this.room.updateItemState(gate);
break;
}
}
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
{ {

View File

@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
public class BattleBanzaiGameTeam extends GameTeam public class BattleBanzaiGameTeam extends GameTeam
{ {
@ -24,14 +26,17 @@ public class BattleBanzaiGameTeam extends GameTeam
public void removeMember(GamePlayer gamePlayer) public void removeMember(GamePlayer gamePlayer)
{ {
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame()); Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
if(game instanceof BattleBanzaiGame) Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
{
((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor());
}
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true); gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
super.removeMember(gamePlayer); super.removeMember(gamePlayer);
if(room != null && room.getRoomSpecialTypes() != null) {
for (InteractionGameGate gate : room.getRoomSpecialTypes().getBattleBanzaiGates().values()) {
gate.updateState(game, 5);
}
}
} }
} }

View File

@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTeleport;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
@ -64,23 +65,6 @@ public class FreezeGame extends Game
t.initialise(); t.initialise();
} }
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
{
for (Habbo habbo : this.room.getHabbos())
{
if (this.getTeamForHabbo(habbo) == null)
{
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
{
if (item instanceof InteractionFreezeTile)
{
this.room.teleportHabboToItem(habbo, this.room.getRoomSpecialTypes().getRandomFreezeExitTile());
}
}
}
}
}
this.start(); this.start();
} }
@ -96,22 +80,6 @@ public class FreezeGame extends Game
} }
} }
public synchronized void placebackHelmet(GameTeamColors teamColor)
{
for (InteractionFreezeGate gate : this.room.getRoomSpecialTypes().getFreezeGates().values())
{
if (gate.teamColor != teamColor)
continue;
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
continue;
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
this.room.updateItemState(gate);
break;
}
}
public void throwBall(Habbo habbo, InteractionFreezeTile item) public void throwBall(Habbo habbo, InteractionFreezeTile item)
{ {
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass()) if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
@ -259,6 +227,24 @@ public class FreezeGame extends Game
super.start(); super.start();
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
{
for (Habbo habbo : this.room.getHabbos())
{
if (this.getTeamForHabbo(habbo) == null)
{
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
{
if (item instanceof InteractionFreezeTile)
{
HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY()));
}
}
}
}
}
this.refreshGates(); this.refreshGates();
this.setFreezeTileState("1"); this.setFreezeTileState("1");

View File

@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
public class FreezeGameTeam extends GameTeam public class FreezeGameTeam extends GameTeam
{ {
@ -16,15 +18,18 @@ public class FreezeGameTeam extends GameTeam
public void removeMember(GamePlayer gamePlayer) public void removeMember(GamePlayer gamePlayer)
{ {
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
if(game instanceof FreezeGame) Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
{
((FreezeGame) game).placebackHelmet(gamePlayer.getTeamColor());
}
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true); gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
super.removeMember(gamePlayer); super.removeMember(gamePlayer);
if(room != null && room.getRoomSpecialTypes() != null) {
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
gate.updateState(game, 5);
}
}
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions.games; package com.eu.habbo.habbohotel.items.interactions.games;
import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
@ -14,11 +15,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException
{ {
super(set, baseItem, teamColor); super(set, baseItem, teamColor);
this.setExtradata("0");
} }
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
{ {
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
this.setExtradata("0");
} }
@Override @Override
@ -41,4 +44,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
super.serializeExtradata(serverMessage); super.serializeExtradata(serverMessage);
} }
public void updateState(Game game, int maxPlayers) {
int memberCount = game.getTeam(this.teamColor).getMembers().size();
if(memberCount > maxPlayers) {
memberCount = maxPlayers;
}
this.setExtradata(memberCount + "");
game.getRoom().updateItem(this);
}
} }

View File

@ -59,6 +59,9 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
super.run(); super.run();
} }
if(this.getRoomId() == 0)
return;
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if(room == null || !this.isRunning || this.isPaused) if(room == null || !this.isRunning || this.isPaused)
@ -89,16 +92,26 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
} }
public static void endGames(Room room) { public static void endGames(Room room) {
endGames(room, false);
}
public static void endGames(Room room, boolean overrideTriggerWired) {
boolean triggerWired = false;
//end existing games //end existing games
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = InteractionGameTimer.getOrCreateGame(room, gameClass); Game game = InteractionGameTimer.getOrCreateGame(room, gameClass);
if (!game.state.equals(GameState.IDLE)) { if (!game.state.equals(GameState.IDLE)) {
triggerWired = true;
game.onEnd(); game.onEnd();
game.stop(); game.stop();
} }
} }
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[] { }); if(triggerWired) {
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
} }
@Override @Override
@ -151,27 +164,12 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
// if wired triggered it // if wired triggered it
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning) if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning)
{ {
boolean gamesActive = false; endGamesIfLastTimer(room);
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values())
{
if(timer.isRunning())
gamesActive = true;
}
if(gamesActive) {
//stop existing games
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass);
if(game.isRunning) {
game.stop();
}
}
}
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass); Game game = getOrCreateGame(room, gameClass);
if(!game.isRunning) { if(!game.isRunning) {
game.start(); game.initialise();
} }
} }
@ -196,13 +194,18 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
switch (state) switch (state)
{ {
case 1: case 1:
if(this.isRunning) { if(this.isRunning) {
this.isPaused = !this.isPaused; this.isPaused = !this.isPaused;
boolean allPaused = this.isPaused;
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
if(!timer.isPaused)
allPaused = false;
}
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass); Game game = getOrCreateGame(room, gameClass);
if(this.isPaused) { if(allPaused) {
game.pause(); game.pause();
} }
else { else {
@ -211,24 +214,26 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
} }
if(!this.isPaused) { if(!this.isPaused) {
this.isRunning = true;
timeNow = this.baseTime;
room.updateItem(this);
Emulator.getThreading().run(this); Emulator.getThreading().run(this);
} }
} }
if(!this.isRunning) { if(!this.isRunning) {
endGamesIfLastTimer(room);
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass); Game game = getOrCreateGame(room, gameClass);
game.initialise(); game.initialise();
} }
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { }); WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { });
Emulator.getThreading().run(this);
}
if(!this.isRunning) {
timeNow = this.baseTime;
this.isRunning = true; this.isRunning = true;
timeNow = this.baseTime;
room.updateItem(this); room.updateItem(this);
Emulator.getThreading().run(this);
} }
break; break;

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameState;
import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.GameTeamColors;
@ -9,6 +10,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -67,18 +69,11 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate
} }
else else
{ {
if(this.getExtradata().isEmpty())
{
this.setExtradata("0");
}
int value = Integer.valueOf(this.getExtradata()) + 1;
this.setExtradata(value + "");
room.updateItem(this);
game.addHabbo(room.getHabbo(roomUnit), this.teamColor); game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
} }
updateState(game, 5);
super.onWalkOn(roomUnit, room, objects); super.onWalkOn(roomUnit, room, objects);
} }
} }

View File

@ -66,18 +66,11 @@ public class InteractionFreezeGate extends InteractionGameGate
} }
else else
{ {
if(this.getExtradata().isEmpty())
{
this.setExtradata("0");
}
int value = Integer.valueOf(this.getExtradata()) + 1;
this.setExtradata(value + "");
room.updateItem(this);
game.addHabbo(room.getHabbo(roomUnit), this.teamColor); game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
} }
updateState(game, 5);
super.onWalkOn(roomUnit, room, objects); super.onWalkOn(roomUnit, room, objects);
} }
} }

View File

@ -94,11 +94,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect
} }
List<Bot> bots = room.getBots(this.botName); List<Bot> bots = room.getBots(this.botName);
int now = Emulator.getIntUnixTimestamp();
for(Bot bot : bots) for(Bot bot : bots)
{ {
if (now - bot.getChatTimestamp() < bot.getChatDelay()) continue;
if(this.mode == 1) if(this.mode == 1)
bot.shout(message); bot.shout(message);
else else

View File

@ -119,6 +119,50 @@ public class WiredEffectTeleport extends InteractionWiredEffect
return true; return true;
} }
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
Room room = roomUnit.getRoom();
// makes a temporary effect
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY);
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED)
{
RoomTile alternativeTile = null;
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile);
Collections.reverse(optionalTiles);
for (RoomTile optionalTile : optionalTiles)
{
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED)
{
alternativeTile = optionalTile;
}
}
if(alternativeTile != null) {
tile = alternativeTile;
}
}
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0) , roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
HabboItem topItem = room.getTopItemAt(tile.x, tile.y);
if(topItem != null) {
Emulator.getThreading().run(new Runnable() {
@Override
public void run() {
try {
topItem.onWalkOn(roomUnit, room, new Object[] { });
} catch (Exception e) {
}
}
}, WiredHandler.TELEPORT_DELAY);
}
}
@Override @Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{ {
@ -146,52 +190,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect
tryCount++; tryCount++;
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size()); HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
int currentEffect = roomUnit.getEffectId(); teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
// makes a temporary effect
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), 2000);
final WiredEffectTeleport teleportWired = this;
RoomTile targetTile = room.getLayout().getTile(item.getX(), item.getY());
boolean foundTile = false;
if (targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED)
{
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(targetTile, item.getRotation() + 3);
Collections.reverse(optionalTiles);
for (RoomTile tile : optionalTiles)
{
if (tile.state != RoomTileState.INVALID && tile.state != RoomTileState.BLOCKED)
{
targetTile = tile;
foundTile = true;
}
}
}
else
{
foundTile = true;
}
if (!foundTile)
{
continue;
}
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, targetTile.x, targetTile.y, targetTile.getStackHeight() + (targetTile.state == RoomTileState.SIT ? -0.5 : 0) , currentEffect), WiredHandler.TELEPORT_DELAY);
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
try
{
item.onWalkOn(roomUnit, room, new Object[]{teleportWired});
}
catch (Exception e)
{}
}
}, WiredHandler.TELEPORT_DELAY);
break; break;
} }