2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.items.interactions;
|
|
|
|
|
2020-01-27 14:36:08 +01:00
|
|
|
import com.eu.habbo.Emulator;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
|
|
|
import com.eu.habbo.habbohotel.items.Item;
|
2018-09-12 18:45:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.rooms.*;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
|
|
import com.eu.habbo.messages.ServerMessage;
|
|
|
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
|
|
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class InteractionPuzzleBox extends HabboItem {
|
|
|
|
public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException {
|
2018-07-06 15:30:00 +02:00
|
|
|
super(set, baseItem);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public InteractionPuzzleBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
2018-07-06 15:30:00 +02:00
|
|
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
|
|
|
if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation()))
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY());
|
|
|
|
client.getHabbo().getRoomUnit().lookAtPoint(boxLocation);
|
|
|
|
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
switch (client.getHabbo().getRoomUnit().getBodyRotation()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
case NORTH_EAST:
|
|
|
|
case NORTH_WEST:
|
|
|
|
case SOUTH_EAST:
|
|
|
|
case SOUTH_WEST:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getBodyRotation().getValue());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double offset = room.getStackHeight(tile.x, tile.y, false) - this.getZ();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue())))
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
HabboItem item = room.getTopItemAt(tile.x, tile.y);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) {
|
2018-07-06 15:30:00 +02:00
|
|
|
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose());
|
2020-01-27 14:36:08 +01:00
|
|
|
room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation));
|
2018-07-06 15:30:00 +02:00
|
|
|
this.needsUpdate(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void serializeExtradata(ServerMessage serverMessage) {
|
2018-07-06 15:30:00 +02:00
|
|
|
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
|
|
|
serverMessage.appendString(this.getExtradata());
|
|
|
|
|
|
|
|
super.serializeExtradata(serverMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isWalkable() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|