mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Trigger onWalkOff when moving a furni from under a RoomUnit
This commit is contained in:
parent
be7fc16935
commit
76f5bd1810
@ -50,6 +50,23 @@ public class InteractionDefault extends HabboItem
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
||||
{
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
|
||||
for (RoomUnit unit : room.getRoomUnits()) {
|
||||
if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // If the unit was previously on the furni...
|
||||
if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore...
|
||||
|
||||
try {
|
||||
this.onWalkOff(unit, room, new Object[]{}); // the unit walked off!
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ public class InteractionWater extends InteractionDefault
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
||||
{
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
|
||||
this.recalculate(room);
|
||||
}
|
||||
|
||||
|
@ -5696,5 +5696,27 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public THashSet<RoomUnit> getRoomUnits() {
|
||||
THashSet<RoomUnit> units = new THashSet<>();
|
||||
|
||||
for (Habbo habbo : this.currentHabbos.values()) {
|
||||
if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) {
|
||||
units.add(habbo.getRoomUnit());
|
||||
}
|
||||
}
|
||||
|
||||
for (Pet pet : this.currentPets.valueCollection()) {
|
||||
if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) {
|
||||
units.add(pet.getRoomUnit());
|
||||
}
|
||||
}
|
||||
|
||||
for (Bot bot : this.currentBots.valueCollection()) {
|
||||
if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) {
|
||||
units.add(bot.getRoomUnit());
|
||||
}
|
||||
}
|
||||
|
||||
return units;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.eu.habbo.habbohotel.rooms;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -233,4 +235,8 @@ public class RoomTile
|
||||
return this.units.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) {
|
||||
return (unit.getX() >= this.x && unit.getX() < this.x + item.getLength()) && (unit.getY() >= this.y && unit.getY() < this.y + item.getWidth());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user