Merge branch 'bot-rollers' into 'dev'

Make bots roll on rollers and clean up code

See merge request morningstar/Arcturus-Community!25
This commit is contained in:
Harmonic 2019-05-12 13:07:38 -04:00
commit b9c1528996

View File

@ -1570,35 +1570,21 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
List<Integer> rollerFurniIds = 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;
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<>();
RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY());
for(HabboItem item : getItemsAt(rollerTile))
{
if(item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) {
itemsOnRoller.add(item);
}
}
itemsOnRoller.addAll(this.getItemsAt(rollerTile));
itemsOnRoller.remove(roller);
if (habbosOnRoller.isEmpty())
if (habbosOnRoller.isEmpty() && itemsOnRoller.isEmpty() && botsOnRoller.isEmpty())
{
if (itemsOnRoller.isEmpty())
return true;
}
@ -1607,6 +1593,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
if (tileInFront == null)
return true;
if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y))
return true;
@ -1620,13 +1607,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
return true;
THashSet<HabboItem> itemsNewTile = new THashSet<>();
for(HabboItem item : getItemsAt(tileInFront))
{
itemsNewTile.add(item);
}
itemsNewTile.addAll(getItemsAt(tileInFront));
itemsNewTile.removeAll(itemsOnRoller);
List<HabboItem> toRemove = new ArrayList<>();
for (HabboItem item : itemsOnRoller)
{
@ -1741,6 +1724,46 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
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())
@ -1807,7 +1830,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
}
return true;
}
});