mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Make user walk to correct tile on beds
This commit is contained in:
parent
944115d12c
commit
9554b969c6
@ -2,13 +2,16 @@ package com.eu.habbo.messages.incoming.rooms.users;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
|
||||
import com.eu.habbo.plugin.events.users.UserIdleEvent;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
public class RoomUserWalkEvent extends MessageHandler {
|
||||
@Override
|
||||
@ -37,6 +40,7 @@ public class RoomUserWalkEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
roomUnit = habbo.getRoomUnit();
|
||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||
|
||||
try {
|
||||
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
|
||||
@ -47,7 +51,7 @@ public class RoomUserWalkEvent extends MessageHandler {
|
||||
if (x == roomUnit.getX() && y == roomUnit.getY())
|
||||
return;
|
||||
|
||||
if (habbo.getHabboInfo().getCurrentRoom() == null || habbo.getHabboInfo().getCurrentRoom().getLayout() == null)
|
||||
if (room == null || room.getLayout() == null)
|
||||
return;
|
||||
|
||||
if (roomUnit.isIdle()) {
|
||||
@ -62,25 +66,47 @@ public class RoomUserWalkEvent extends MessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y);
|
||||
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
||||
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
|
||||
if (habbo.getHabboInfo().getCurrentRoom().getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
|
||||
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
|
||||
return;
|
||||
}
|
||||
if (tile.isWalkable() || habbo.getHabboInfo().getCurrentRoom().canSitOrLayAt(tile.x, tile.y)) {
|
||||
if (room.canLayAt(tile.x, tile.y)) {
|
||||
HabboItem bed = room.getTopItemAt(tile.x, tile.y);
|
||||
|
||||
if (bed != null && bed.getBaseItem().allowLay()) {
|
||||
RoomTile pillow = room.getLayout().getTile(bed.getX(), bed.getY());
|
||||
switch (bed.getRotation()) {
|
||||
case 0:
|
||||
case 4:
|
||||
pillow = room.getLayout().getTile((short)x, bed.getY());
|
||||
break;
|
||||
case 2:
|
||||
case 8:
|
||||
pillow = room.getLayout().getTile(bed.getX(), (short)y);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pillow != null && room.canLayAt(pillow.x, pillow.y)) {
|
||||
roomUnit.setGoalLocation(pillow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
|
||||
roomUnit.setGoalLocation(tile);
|
||||
}
|
||||
} else {
|
||||
RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y);
|
||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, habbo.getHabboInfo().getCurrentRoom()).compose());
|
||||
RoomTile t = room.getLayout().getTile((short) x, (short) y);
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose());
|
||||
|
||||
if (habbo.getHabboInfo().getRiding() != null) {
|
||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, habbo.getHabboInfo().getCurrentRoom()).compose());
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user