2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.rooms;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
2020-01-27 20:56:59 +01:00
|
|
|
import com.eu.habbo.habbohotel.bots.Bot;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.items.Item;
|
2020-02-05 18:35:25 +01:00
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionHabboClubGate;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
|
2019-05-01 00:57:40 +02:00
|
|
|
import com.eu.habbo.habbohotel.pets.Pet;
|
2019-05-04 08:21:43 +02:00
|
|
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.users.DanceType;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
2019-08-04 16:23:04 +02:00
|
|
|
import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
|
|
|
import com.eu.habbo.plugin.Event;
|
|
|
|
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
|
|
|
|
import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent;
|
|
|
|
import com.eu.habbo.plugin.events.users.UserIdleEvent;
|
|
|
|
import com.eu.habbo.plugin.events.users.UserTakeStepEvent;
|
|
|
|
import com.eu.habbo.threading.runnables.RoomUnitKick;
|
|
|
|
import com.eu.habbo.util.pathfinding.Rotation;
|
|
|
|
import gnu.trove.map.TMap;
|
|
|
|
import gnu.trove.map.hash.THashMap;
|
2019-05-12 09:59:01 +02:00
|
|
|
import gnu.trove.set.hash.THashSet;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2020-02-05 18:35:25 +01:00
|
|
|
import java.util.*;
|
2018-09-12 18:45:00 +02:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2020-02-05 23:56:40 +01:00
|
|
|
import java.util.concurrent.ScheduledFuture;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class RoomUnit {
|
|
|
|
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
|
|
|
private final THashMap<String, Object> cacheable;
|
|
|
|
public boolean canRotate = true;
|
|
|
|
public boolean animateWalk = false;
|
|
|
|
public boolean cmdTeleport = false;
|
|
|
|
public boolean cmdSit = false;
|
|
|
|
public boolean cmdLay = false;
|
|
|
|
public boolean sitUpdate = false;
|
|
|
|
public boolean isTeleporting = false;
|
|
|
|
public boolean isKicked;
|
|
|
|
public int kickCount = 0;
|
2018-07-06 15:30:00 +02:00
|
|
|
private int id;
|
|
|
|
private RoomTile startLocation;
|
|
|
|
private RoomTile previousLocation;
|
2018-10-07 00:28:00 +02:00
|
|
|
private double previousLocationZ;
|
2018-07-06 15:30:00 +02:00
|
|
|
private RoomTile currentLocation;
|
|
|
|
private RoomTile goalLocation;
|
|
|
|
private double z;
|
|
|
|
private int tilesWalked;
|
|
|
|
private boolean inRoom;
|
|
|
|
private boolean canWalk;
|
|
|
|
private boolean fastWalk = false;
|
2018-09-28 21:25:00 +02:00
|
|
|
private boolean statusUpdate = false;
|
|
|
|
private boolean invisible = false;
|
2019-05-04 12:15:45 +02:00
|
|
|
private boolean lastCycleStatus = false;
|
2019-05-15 23:54:07 +02:00
|
|
|
private boolean canLeaveRoomByDoor = true;
|
2018-07-06 15:30:00 +02:00
|
|
|
private RoomUserRotation bodyRotation = RoomUserRotation.NORTH;
|
|
|
|
private RoomUserRotation headRotation = RoomUserRotation.NORTH;
|
|
|
|
private DanceType danceType;
|
|
|
|
private RoomUnitType roomUnitType;
|
|
|
|
private Deque<RoomTile> path = new LinkedList<>();
|
|
|
|
private int handItem;
|
|
|
|
private long handItemTimestamp;
|
|
|
|
private int walkTimeOut;
|
|
|
|
private int effectId;
|
2019-03-18 02:22:00 +01:00
|
|
|
private int effectEndTimestamp;
|
2020-02-05 23:56:40 +01:00
|
|
|
private ScheduledFuture moveBlockingTask;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
private int idleTimer;
|
|
|
|
private Room room;
|
|
|
|
private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
|
2019-05-12 09:59:01 +02:00
|
|
|
private THashSet<Integer> overridableTiles;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public RoomUnit() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.id = 0;
|
|
|
|
this.inRoom = false;
|
|
|
|
this.canWalk = true;
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status = new ConcurrentHashMap<>();
|
2018-09-28 21:25:00 +02:00
|
|
|
this.cacheable = new THashMap<>();
|
2018-07-06 15:30:00 +02:00
|
|
|
this.roomUnitType = RoomUnitType.UNKNOWN;
|
|
|
|
this.danceType = DanceType.NONE;
|
|
|
|
this.handItem = 0;
|
|
|
|
this.handItemTimestamp = 0;
|
|
|
|
this.walkTimeOut = Emulator.getIntUnixTimestamp();
|
|
|
|
this.effectId = 0;
|
|
|
|
this.isKicked = false;
|
2019-05-12 09:59:01 +02:00
|
|
|
this.overridableTiles = new THashSet<>();
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void clearWalking() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.goalLocation = null;
|
|
|
|
this.startLocation = this.currentLocation;
|
|
|
|
this.inRoom = false;
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.clear();
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
this.cacheable.clear();
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void stopWalking() {
|
|
|
|
synchronized (this.status) {
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
2018-07-06 15:30:00 +02:00
|
|
|
this.setGoalLocation(this.currentLocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean cycle(Room room) {
|
|
|
|
try {
|
2019-05-04 12:15:45 +02:00
|
|
|
Habbo rider = null;
|
2019-05-26 20:14:53 +02:00
|
|
|
if (this.getRoomUnitType() == RoomUnitType.PET) {
|
2019-05-04 12:15:45 +02:00
|
|
|
Pet pet = room.getPet(this);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (pet instanceof RideablePet) {
|
2019-05-04 12:15:45 +02:00
|
|
|
rider = ((RideablePet) pet).getRider();
|
|
|
|
}
|
|
|
|
}
|
2019-05-01 00:57:40 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (rider != null) {
|
2019-05-04 12:15:45 +02:00
|
|
|
// copy things from rider
|
2019-05-26 20:14:53 +02:00
|
|
|
if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) {
|
2019-05-04 12:15:45 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) {
|
2019-05-04 12:15:45 +02:00
|
|
|
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().x + "," + rider.getRoomUnit().getCurrentLocation().y + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
|
|
|
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
|
|
|
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
|
|
|
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
|
|
|
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
2019-05-01 00:57:40 +02:00
|
|
|
}
|
2019-05-04 12:15:45 +02:00
|
|
|
|
|
|
|
return this.statusUpdate;
|
2019-05-01 00:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-05-04 12:15:45 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!this.isWalking() && !this.isKicked) {
|
|
|
|
if (this.status.remove(RoomUnitStatus.MOVE) == null) {
|
2019-05-01 00:57:40 +02:00
|
|
|
Habbo habboT = room.getHabbo(this);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habboT != null) {
|
2019-05-01 00:57:40 +02:00
|
|
|
habboT.getHabboInfo().getRiding().getRoomUnit().status.remove(RoomUnitStatus.MOVE);
|
|
|
|
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
if (this.status.remove(RoomUnitStatus.SIT) != null) this.statusUpdate = true;
|
|
|
|
if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true;
|
|
|
|
if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (Map.Entry<RoomUnitStatus, String> set : this.status.entrySet()) {
|
|
|
|
if (set.getKey().removeWhenWalking) {
|
2019-03-18 02:22:00 +01:00
|
|
|
this.status.remove(set.getKey());
|
2018-09-12 18:45:00 +02:00
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.path == null || this.path.isEmpty())
|
|
|
|
return true;
|
|
|
|
|
2019-05-04 04:06:12 +02:00
|
|
|
boolean canfastwalk = true;
|
|
|
|
Habbo habboT = room.getHabbo(this);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habboT != null) {
|
|
|
|
if (habboT.getHabboInfo().getRiding() != null)
|
2019-05-04 04:06:12 +02:00
|
|
|
canfastwalk = false;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
RoomTile next = this.path.poll();
|
2019-05-12 09:59:01 +02:00
|
|
|
boolean overrideChecks = next != null && this.canOverrideTile(next);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (this.path.isEmpty()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.sitUpdate = true;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (next != null && next.hasUnits() && !overrideChecks) {
|
2019-05-04 12:15:45 +02:00
|
|
|
return false;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
|
2020-02-06 00:06:49 +01:00
|
|
|
|
|
|
|
if (peekPath == null) peekPath = new LinkedList<>();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (peekPath.size() >= 3) {
|
2019-05-27 12:39:50 +02:00
|
|
|
if (path.isEmpty()) return true;
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
path.pop();
|
|
|
|
//peekPath.pop(); //Start
|
2018-07-06 15:30:00 +02:00
|
|
|
peekPath.removeLast(); //End
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (peekPath.peek() != next) {
|
2018-07-06 15:30:00 +02:00
|
|
|
next = peekPath.poll();
|
2019-05-26 20:14:53 +02:00
|
|
|
for (int i = 0; i < peekPath.size(); i++) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.path.addFirst(peekPath.removeLast());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (canfastwalk && this.fastWalk) {
|
|
|
|
if (this.path.size() > 1) {
|
2019-05-12 09:59:01 +02:00
|
|
|
next = this.path.poll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
if (next == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Habbo habbo = room.getHabbo(this);
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
this.status.remove(RoomUnitStatus.DEAD);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
|
|
|
if (this.isIdle()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
|
|
|
Emulator.getPluginManager().fireEvent(event);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
if (!event.idle) {
|
2018-07-06 15:30:00 +02:00
|
|
|
room.unIdle(habbo);
|
|
|
|
this.idleTimer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getX(), this.getY()), next);
|
|
|
|
Emulator.getPluginManager().fireEvent(e);
|
|
|
|
|
|
|
|
if (e.isCancelled())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HabboItem item = room.getTopItemAt(next.x, next.y);
|
|
|
|
|
|
|
|
//if(!(this.path.size() == 0 && canSitNextTile))
|
|
|
|
{
|
2019-06-09 01:13:23 +02:00
|
|
|
if (!room.tileWalkable(next)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.room = room;
|
|
|
|
this.findPath();
|
|
|
|
|
2019-06-09 01:13:23 +02:00
|
|
|
if (this.path.isEmpty()) {
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
2019-06-09 01:13:23 +02:00
|
|
|
next = (RoomTile)this.path.pop();
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean canSitNextTile = room.canSitAt(next.x, next.y);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (canSitNextTile) {
|
2018-07-06 15:30:00 +02:00
|
|
|
HabboItem lowestChair = room.getLowestChair(next);
|
|
|
|
|
|
|
|
if (lowestChair != null)
|
|
|
|
item = lowestChair;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) {
|
|
|
|
if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT) {
|
2018-12-22 11:39:00 +01:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
double zHeight = 0.0D;
|
|
|
|
|
2019-05-04 12:15:45 +02:00
|
|
|
/*if (((habbo != null && habbo.getHabboInfo().getRiding() != null) || isRiding) && next.equals(this.goalLocation) && (next.state == RoomTileState.SIT || next.state == RoomTileState.LAY)) {
|
2019-05-01 00:57:40 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
|
|
|
return false;
|
2019-05-04 12:15:45 +02:00
|
|
|
}*/
|
2019-05-01 00:57:40 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
|
|
|
if (habbo.getHabboInfo().getRiding() != null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
zHeight += 1.0D;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY());
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habboItem != null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
if (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.x, next.y))
|
2018-12-22 11:39:00 +01:00
|
|
|
habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next});
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.tilesWalked++;
|
|
|
|
|
|
|
|
RoomUserRotation oldRotation = this.getBodyRotation();
|
|
|
|
this.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (item != null) {
|
|
|
|
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
|
|
|
|
if (item.canWalkOn(this, room, null)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
item.onWalkOn(this, room, null);
|
2019-08-04 16:23:04 +02:00
|
|
|
} else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.setRotation(oldRotation);
|
|
|
|
this.tilesWalked--;
|
|
|
|
this.setGoalLocation(this.currentLocation);
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
2018-07-06 15:30:00 +02:00
|
|
|
room.sendComposer(new RoomUserStatusComposer(this).compose());
|
2019-08-04 16:23:04 +02:00
|
|
|
|
|
|
|
if (item instanceof InteractionHabboClubGate && habbo != null) {
|
|
|
|
habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-07-06 15:30:00 +02:00
|
|
|
item.onWalk(this, room, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
zHeight += item.getZ();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) {
|
2019-05-12 09:59:01 +02:00
|
|
|
zHeight += Item.getCurrentHeight(item);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-07-06 15:30:00 +02:00
|
|
|
zHeight += room.getLayout().getHeightAtSquare(next.x, next.y);
|
|
|
|
}
|
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
|
|
|
|
this.setPreviousLocation(this.getCurrentLocation());
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
|
|
|
if (habbo.getHabboInfo().getRiding() != null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (ridingUnit != null) {
|
2019-05-04 08:21:43 +02:00
|
|
|
ridingUnit.setPreviousLocationZ(this.getZ());
|
2019-05-01 00:57:40 +02:00
|
|
|
this.setZ(zHeight - 1.0);
|
|
|
|
ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]);
|
|
|
|
ridingUnit.setPreviousLocation(this.getCurrentLocation());
|
|
|
|
ridingUnit.setGoalLocation(this.getGoal());
|
2018-09-12 18:45:00 +02:00
|
|
|
ridingUnit.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + (zHeight - 1.0));
|
2019-05-01 00:57:40 +02:00
|
|
|
room.sendComposer(new RoomUserStatusComposer(ridingUnit).compose());
|
2019-05-04 08:21:43 +02:00
|
|
|
//ridingUnit.setZ(zHeight - 1.0);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//room.sendComposer(new RoomUserStatusComposer(this).compose());
|
|
|
|
|
|
|
|
this.setZ(zHeight);
|
2018-09-28 21:25:00 +02:00
|
|
|
this.setCurrentLocation(room.getLayout().getTile(next.x, next.y));
|
2018-07-06 15:30:00 +02:00
|
|
|
this.resetIdleTimer();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
2019-06-03 21:34:09 +02:00
|
|
|
HabboItem topItem = room.getTopItemAt(next.x, next.y);
|
2019-05-28 19:28:44 +02:00
|
|
|
|
|
|
|
boolean isAtDoor = next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY();
|
|
|
|
boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick");
|
|
|
|
boolean invalidated = topItem != null && topItem.invalidatesToRoomKick();
|
|
|
|
|
|
|
|
if (this.canLeaveRoomByDoor && isAtDoor && publicRoomKicks && !invalidated) {
|
2018-07-06 15:30:00 +02:00
|
|
|
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (Exception e) {
|
2018-07-06 15:30:00 +02:00
|
|
|
Emulator.getLogging().logErrorLine(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2019-05-26 20:14:53 +02:00
|
|
|
|
|
|
|
public int getId() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.id;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setId(int id) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public RoomTile getCurrentLocation() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.currentLocation;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setCurrentLocation(RoomTile location) {
|
|
|
|
if (location != null) {
|
|
|
|
if (this.currentLocation != null) {
|
|
|
|
this.currentLocation.removeUnit(this);
|
|
|
|
}
|
|
|
|
this.currentLocation = location;
|
|
|
|
location.addUnit(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public short getX() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.currentLocation.x;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public short getY() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.currentLocation.y;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public double getZ() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.z;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setZ(double z) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.z = z;
|
2020-01-27 20:56:59 +01:00
|
|
|
|
|
|
|
if (this.room != null) {
|
|
|
|
Bot bot = this.room.getBot(this);
|
|
|
|
if (bot != null) {
|
|
|
|
bot.needsUpdate(true);
|
|
|
|
}
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isInRoom() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.inRoom;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setInRoom(boolean inRoom) {
|
|
|
|
this.inRoom = inRoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomUnitType getRoomUnitType() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.roomUnitType;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setRoomUnitType(RoomUnitType roomUnitType) {
|
|
|
|
this.roomUnitType = roomUnitType;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setRotation(RoomUserRotation rotation) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.bodyRotation = rotation;
|
|
|
|
this.headRotation = rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomUserRotation getBodyRotation() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.bodyRotation;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setBodyRotation(RoomUserRotation bodyRotation) {
|
|
|
|
this.bodyRotation = bodyRotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomUserRotation getHeadRotation() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.headRotation;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setHeadRotation(RoomUserRotation headRotation) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.headRotation = headRotation;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public DanceType getDanceType() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.danceType;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDanceType(DanceType danceType) {
|
|
|
|
this.danceType = danceType;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setCanWalk(boolean value) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.canWalk = value;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean canWalk() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.canWalk;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isFastWalk() {
|
|
|
|
return this.fastWalk;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setFastWalk(boolean fastWalk) {
|
|
|
|
this.fastWalk = fastWalk;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public RoomTile getStartLocation() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.startLocation;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int tilesWalked() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.tilesWalked;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public RoomTile getGoal() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.goalLocation;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setGoalLocation(RoomTile goalLocation) {
|
|
|
|
if (goalLocation != null) {
|
2019-06-09 01:13:23 +02:00
|
|
|
// if (goalLocation.state != RoomTileState.INVALID) {
|
2018-09-28 21:25:00 +02:00
|
|
|
this.setGoalLocation(goalLocation, false);
|
|
|
|
}
|
2019-06-09 01:13:23 +02:00
|
|
|
//}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setGoalLocation(RoomTile goalLocation, boolean noReset) {
|
2019-06-09 01:13:23 +02:00
|
|
|
if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false))
|
|
|
|
{
|
2018-07-06 15:30:00 +02:00
|
|
|
Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation);
|
|
|
|
Emulator.getPluginManager().fireEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-09 01:13:23 +02:00
|
|
|
/// Set start location
|
2018-07-06 15:30:00 +02:00
|
|
|
this.startLocation = this.currentLocation;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (goalLocation != null && !noReset) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.goalLocation = goalLocation;
|
2019-06-09 01:13:23 +02:00
|
|
|
this.findPath(); ///< Quadral: this is where we start formulating a path
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!this.path.isEmpty()) {
|
2018-09-28 21:25:00 +02:00
|
|
|
this.tilesWalked = 0;
|
|
|
|
this.cmdSit = false;
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-09-28 21:25:00 +02:00
|
|
|
this.goalLocation = this.currentLocation;
|
2019-06-09 01:13:23 +02:00
|
|
|
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setLocation(RoomTile location) {
|
|
|
|
if (location != null) {
|
|
|
|
this.startLocation = location;
|
2019-05-12 09:59:01 +02:00
|
|
|
setPreviousLocation(location);
|
|
|
|
setCurrentLocation(location);
|
2019-05-26 20:14:53 +02:00
|
|
|
this.goalLocation = location;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public RoomTile getPreviousLocation() {
|
|
|
|
return this.previousLocation;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setPreviousLocation(RoomTile previousLocation) {
|
|
|
|
this.previousLocation = previousLocation;
|
|
|
|
this.previousLocationZ = this.z;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public double getPreviousLocationZ() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.previousLocationZ;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setPreviousLocationZ(double z) {
|
2018-10-07 00:28:00 +02:00
|
|
|
this.previousLocationZ = z;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setPathFinderRoom(Room room) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
2019-06-09 01:13:23 +02:00
|
|
|
public void findPath()
|
|
|
|
{
|
2020-02-06 00:06:49 +01:00
|
|
|
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) {
|
|
|
|
Deque<RoomTile> path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
|
|
|
if (path != null) this.path = path;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isAtGoal() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.currentLocation.equals(this.goalLocation);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isWalking() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return !this.isAtGoal() && this.canWalk;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getStatus(RoomUnitStatus key) {
|
2018-09-12 18:45:00 +02:00
|
|
|
return this.status.get(key);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public ConcurrentHashMap<RoomUnitStatus, String> getStatusMap() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.status;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void removeStatus(RoomUnitStatus key) {
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.remove(key);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setStatus(RoomUnitStatus key, String value) {
|
|
|
|
if (key != null && value != null) {
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean hasStatus(RoomUnitStatus key) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.status.containsKey(key);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void clearStatus() {
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.clear();
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void statusUpdate(boolean update) {
|
2018-09-28 21:25:00 +02:00
|
|
|
this.statusUpdate = update;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean needsStatusUpdate() {
|
2018-09-28 21:25:00 +02:00
|
|
|
return this.statusUpdate;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public TMap<String, Object> getCacheable() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.cacheable;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getHandItem() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.handItem;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setHandItem(int handItem) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.handItem = handItem;
|
|
|
|
this.handItemTimestamp = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public long getHandItemTimestamp() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.handItemTimestamp;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getEffectId() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.effectId;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setEffectId(int effectId, int endTimestamp) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.effectId = effectId;
|
2019-03-18 02:22:00 +01:00
|
|
|
this.effectEndTimestamp = endTimestamp;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getEffectEndTimestamp() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.effectEndTimestamp;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getWalkTimeOut() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.walkTimeOut;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setWalkTimeOut(int walkTimeOut) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.walkTimeOut = walkTimeOut;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void increaseIdleTimer() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.idleTimer++;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isIdle() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.idleTimer > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds.
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getIdleTimer() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.idleTimer;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void resetIdleTimer() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.idleTimer = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setIdle() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.idleTimer = Room.IDLE_CYCLES + 1;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void lookAtPoint(RoomTile location) {
|
2018-12-22 11:39:00 +01:00
|
|
|
if (!this.canRotate) return;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location);
|
|
|
|
Emulator.getPluginManager().fireEvent(lookAtPointEvent);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (lookAtPointEvent.isCancelled())
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (this.status.containsKey(RoomUnitStatus.LAY)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!this.status.containsKey(RoomUnitStatus.SIT)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomUserRotation rotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.headRotation = rotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public Deque<RoomTile> getPath() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.path;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setPath(Deque<RoomTile> path) {
|
|
|
|
this.path = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomRightLevels getRightsLevel() {
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.rightsLevel;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setRightsLevel(RoomRightLevels rightsLevel) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.rightsLevel = rightsLevel;
|
|
|
|
}
|
2018-09-28 21:25:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isInvisible() {
|
|
|
|
return this.invisible;
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setInvisible(boolean invisible) {
|
|
|
|
this.invisible = invisible;
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
2019-05-04 11:22:20 +02:00
|
|
|
|
|
|
|
public Room getRoom() {
|
|
|
|
return room;
|
|
|
|
}
|
2019-05-12 09:59:01 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setRoom(Room room) {
|
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
public boolean canOverrideTile(RoomTile tile) {
|
2019-05-26 18:31:14 +02:00
|
|
|
if (tile == null || room == null || room.getLayout() == null) return false;
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
|
|
|
return this.overridableTiles.contains(tileIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addOverrideTile(RoomTile tile) {
|
|
|
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!this.overridableTiles.contains(tileIndex)) {
|
2019-05-12 09:59:01 +02:00
|
|
|
this.overridableTiles.add(tileIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeOverrideTile(RoomTile tile) {
|
|
|
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
|
|
|
this.overridableTiles.remove(tileIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearOverrideTiles() {
|
|
|
|
this.overridableTiles.clear();
|
|
|
|
}
|
2019-05-15 23:54:07 +02:00
|
|
|
|
|
|
|
public boolean canLeaveRoomByDoor() {
|
|
|
|
return canLeaveRoomByDoor;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) {
|
|
|
|
this.canLeaveRoomByDoor = canLeaveRoomByDoor;
|
|
|
|
}
|
2019-06-16 12:52:27 +02:00
|
|
|
|
|
|
|
public boolean canForcePosture() {
|
|
|
|
if (this.room == null) return false;
|
|
|
|
|
|
|
|
HabboItem topItem = this.room.getTopItemAt(this.getX(), this.getY());
|
|
|
|
|
|
|
|
return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
|
|
|
|
}
|
2020-02-05 18:35:25 +01:00
|
|
|
|
|
|
|
public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) {
|
|
|
|
RoomTile baseTile = room.getLayout().getTile(x, y);
|
|
|
|
|
|
|
|
if (baseTile == null) return null;
|
|
|
|
|
|
|
|
List<Integer> rotations = new ArrayList<>();
|
|
|
|
rotations.add(RoomUserRotation.SOUTH.getValue());
|
|
|
|
rotations.add(RoomUserRotation.NORTH.getValue());
|
|
|
|
rotations.add(RoomUserRotation.EAST.getValue());
|
|
|
|
rotations.add(RoomUserRotation.WEST.getValue());
|
|
|
|
|
|
|
|
if (diagonal) {
|
|
|
|
rotations.add(RoomUserRotation.NORTH_EAST.getValue());
|
|
|
|
rotations.add(RoomUserRotation.NORTH_WEST.getValue());
|
|
|
|
rotations.add(RoomUserRotation.SOUTH_EAST.getValue());
|
|
|
|
rotations.add(RoomUserRotation.SOUTH_WEST.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rotations.stream()
|
|
|
|
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
|
|
|
.filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y))
|
|
|
|
.min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null);
|
|
|
|
}
|
2020-02-05 23:56:40 +01:00
|
|
|
|
|
|
|
public ScheduledFuture getMoveBlockingTask() {
|
|
|
|
return moveBlockingTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
|
|
|
|
this.moveBlockingTask = moveBlockingTask;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|