Revert "Revert "Merge branch 'bot-rollers' into 'dev'""

This reverts commit db345025e7
This commit is contained in:
Beny 2019-05-12 22:09:16 -04:00
parent 3e57cfe336
commit a6c3626a96

View File

@ -1565,35 +1565,21 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
List<Integer> rollerFurniIds = new ArrayList<>(); List<Integer> rollerFurniIds = new ArrayList<>();
List<Integer> rolledUnitIds = new ArrayList<>(); List<Integer> rolledUnitIds = new ArrayList<>();
this.roomSpecialTypes.getRollers().forEachValue(new TObjectProcedure<InteractionRoller>()
{
@Override
public boolean execute(InteractionRoller roller)
{
//if(Double.compare(roller.getZ(), this.layout.getHeightAtSquare(roller.getX(), roller.getY())) != 0)
this.roomSpecialTypes.getRollers().forEachValue(roller -> {
//}
HabboItem newRoller = null; HabboItem newRoller = null;
THashSet<Habbo> habbosOnRoller = Room.this.getHabbosAt(roller.getX(), roller.getY()); THashSet<Habbo> habbosOnRoller = Room.this.getHabbosAt(roller.getX(), roller.getY());
THashSet<Bot> botsOnRoller = Room.this.getBotsAt(Room.this.layout.getTile(roller.getX(), roller.getY()));
THashSet<HabboItem> itemsOnRoller = new THashSet<>(); THashSet<HabboItem> itemsOnRoller = new THashSet<>();
RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY()); RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY());
itemsOnRoller.addAll(this.getItemsAt(rollerTile));
for(HabboItem item : getItemsAt(rollerTile))
{
if(item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) {
itemsOnRoller.add(item);
}
}
itemsOnRoller.remove(roller); itemsOnRoller.remove(roller);
if (habbosOnRoller.isEmpty()) if (habbosOnRoller.isEmpty() && itemsOnRoller.isEmpty() && botsOnRoller.isEmpty())
{ {
if (itemsOnRoller.isEmpty())
return true; return true;
} }
@ -1602,6 +1588,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
if (tileInFront == null) if (tileInFront == null)
return true; return true;
if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y)) if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y))
return true; return true;
@ -1615,13 +1602,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
return true; return true;
THashSet<HabboItem> itemsNewTile = new THashSet<>(); THashSet<HabboItem> itemsNewTile = new THashSet<>();
itemsNewTile.addAll(getItemsAt(tileInFront));
for(HabboItem item : getItemsAt(tileInFront))
{
itemsNewTile.add(item);
}
itemsNewTile.removeAll(itemsOnRoller); itemsNewTile.removeAll(itemsOnRoller);
List<HabboItem> toRemove = new ArrayList<>(); List<HabboItem> toRemove = new ArrayList<>();
for (HabboItem item : itemsOnRoller) for (HabboItem item : itemsOnRoller)
{ {
@ -1736,6 +1719,46 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
break; break;
} }
for (Bot bot: botsOnRoller)
{
if (rolledUnitIds.contains(bot.getRoomUnit().getId())) continue;
rolledUnitIds.add(bot.getRoomUnit().getId());
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
if (!bot.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
{
RoomTile tile = tileInFront.copy();
tile.setStackHeight(bot.getRoomUnit().getZ() + zOffset);
updatedUnit.remove(bot.getRoomUnit());
messages.add(new RoomUnitOnRollerComposer(bot.getRoomUnit(), roller, bot.getRoomUnit().getCurrentLocation(), bot.getRoomUnit().getZ(), tile, tile.getStackHeight(), room));
if (itemsOnRoller.isEmpty())
{
HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y);
if (item != null && itemsNewTile.contains(item))
{
try
{
item.onWalkOn(bot.getRoomUnit(), room, null);
} catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
}
}
if (bot.getRoomUnit().hasStatus(RoomUnitStatus.SIT))
bot.getRoomUnit().sitUpdate = true;
break;
}
} }
if (!messages.isEmpty()) if (!messages.isEmpty())
@ -1802,7 +1825,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
} }
return true; return true;
}
}); });