mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Merge branch 'moving-furni-walkoff-fix' into 'dev'
Make onWalkOff trigger when a furni is moved from under a room unit See merge request morningstar/Arcturus-Community!38
This commit is contained in:
commit
019b8c1cf6
@ -50,6 +50,23 @@ public class InteractionDefault extends HabboItem
|
|||||||
return true;
|
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
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ public class InteractionWater extends InteractionDefault
|
|||||||
@Override
|
@Override
|
||||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
||||||
{
|
{
|
||||||
|
super.onMove(room, oldLocation, newLocation);
|
||||||
|
|
||||||
this.recalculate(room);
|
this.recalculate(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5702,5 +5702,27 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
return FurnitureMovementError.NONE;
|
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;
|
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 gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -233,4 +235,8 @@ public class RoomTile
|
|||||||
return this.units.size() > 0;
|
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