2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.items.interactions;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.items.Item;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.Room;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
2018-12-22 11:39:00 +01:00
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
|
|
import gnu.trove.set.hash.THashSet;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
public class InteractionWaterItem extends InteractionDefault
|
|
|
|
{
|
|
|
|
public InteractionWaterItem(ResultSet set, Item baseItem) throws SQLException
|
|
|
|
{
|
|
|
|
super(set, baseItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
public InteractionWaterItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
|
|
|
|
{
|
|
|
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPlace(Room room)
|
|
|
|
{
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPickUp(Room room)
|
|
|
|
{
|
|
|
|
this.setExtradata("0");
|
|
|
|
this.needsUpdate(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
|
|
|
{
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void update()
|
|
|
|
{
|
|
|
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
|
|
|
|
|
|
|
if(room == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Rectangle rectangle = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
|
|
|
|
|
2018-12-22 11:39:00 +01:00
|
|
|
boolean foundWater = true;
|
|
|
|
for(short x = (short)rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2018-12-22 11:39:00 +01:00
|
|
|
for(short y = (short)rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2018-12-22 11:39:00 +01:00
|
|
|
boolean tile = false;
|
|
|
|
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(x, y));
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
for(HabboItem item : items)
|
|
|
|
{
|
2018-12-22 11:39:00 +01:00
|
|
|
if (item instanceof InteractionWater)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2018-12-22 11:39:00 +01:00
|
|
|
tile = true;
|
|
|
|
break;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
2018-12-22 11:39:00 +01:00
|
|
|
|
|
|
|
if (!tile)
|
|
|
|
{
|
|
|
|
foundWater = false;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-22 11:39:00 +01:00
|
|
|
if (foundWater)
|
|
|
|
{
|
|
|
|
this.setExtradata("1");
|
|
|
|
this.needsUpdate(true);
|
|
|
|
room.updateItem(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
this.setExtradata("0");
|
2018-12-22 11:39:00 +01:00
|
|
|
this.needsUpdate(true);
|
2018-07-06 15:30:00 +02:00
|
|
|
room.updateItem(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean allowWiredResetState()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-22 11:39:00 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canToggle(Habbo habbo, Room room)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|