2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.rooms;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.items.Item;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport;
|
|
|
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
|
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;
|
|
|
|
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
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
import java.awt.geom.RectangularShape;
|
2018-09-28 21:25:00 +02:00
|
|
|
import java.util.Deque;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.Map;
|
2018-09-12 18:45:00 +02:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
public class RoomUnit
|
|
|
|
{
|
|
|
|
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;
|
2018-12-22 11:39:00 +01:00
|
|
|
public boolean canRotate = true;
|
2018-07-06 15:30:00 +02:00
|
|
|
private boolean fastWalk = false;
|
|
|
|
public boolean animateWalk = false;
|
|
|
|
public boolean cmdTeleport = false;
|
|
|
|
public boolean cmdSit = false;
|
|
|
|
public boolean cmdLay = false;
|
|
|
|
public boolean sitUpdate = false;
|
|
|
|
public boolean isTeleporting = false;
|
2019-03-18 02:22:00 +01:00
|
|
|
public boolean isKicked;
|
2018-10-07 00:28:00 +02:00
|
|
|
public int kickCount = 0;
|
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
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
2018-07-06 15:30:00 +02:00
|
|
|
private final THashMap<String, Object> cacheable;
|
|
|
|
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;
|
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
|
|
|
|
|
|
|
public RoomUnit()
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
public void clearWalking()
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean cycle(Room room)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-05-04 12:15:45 +02:00
|
|
|
Habbo rider = null;
|
|
|
|
if(this.getRoomUnitType() == RoomUnitType.PET) {
|
|
|
|
Pet pet = room.getPet(this);
|
2019-05-04 08:21:43 +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-04 12:15:45 +02:00
|
|
|
if(rider != null) {
|
|
|
|
// copy things from rider
|
|
|
|
if(this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) {
|
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) {
|
|
|
|
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-03-18 02:22:00 +01:00
|
|
|
if (!this.isWalking() && !this.isKicked)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2018-09-12 18:45:00 +02:00
|
|
|
if (this.status.remove(RoomUnitStatus.MOVE) == null)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2019-05-01 00:57:40 +02:00
|
|
|
Habbo habboT = room.getHabbo(this);
|
|
|
|
if(habboT != null) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
for (Map.Entry<RoomUnitStatus, String> set : this.status.entrySet())
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
if (set.getKey().removeWhenWalking)
|
2018-09-12 18:45:00 +02:00
|
|
|
{
|
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);
|
|
|
|
if(habboT != null) {
|
|
|
|
if(habboT.getHabboInfo().getRiding() != null)
|
|
|
|
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
|
|
|
|
|
|
|
if (this.path.isEmpty())
|
|
|
|
{
|
|
|
|
this.sitUpdate = true;
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
if (next != null && next.hasUnits() && !overrideChecks)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
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);
|
2018-07-06 15:30:00 +02:00
|
|
|
if (peekPath.size() >= 3)
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
path.pop();
|
|
|
|
//peekPath.pop(); //Start
|
2018-07-06 15:30:00 +02:00
|
|
|
peekPath.removeLast(); //End
|
|
|
|
|
|
|
|
if (peekPath.peek() != next)
|
|
|
|
{
|
|
|
|
next = peekPath.poll();
|
|
|
|
for (int i = 0; i < peekPath.size(); i++)
|
|
|
|
{
|
|
|
|
this.path.addFirst(peekPath.removeLast());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
if (canfastwalk && this.fastWalk)
|
|
|
|
{
|
|
|
|
if(this.path.size() > 1) {
|
|
|
|
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
|
|
|
|
|
|
|
if (habbo != null)
|
|
|
|
{
|
|
|
|
if (this.isIdle())
|
|
|
|
{
|
|
|
|
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
|
|
|
Emulator.getPluginManager().fireEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled())
|
|
|
|
{
|
|
|
|
if (!event.idle)
|
|
|
|
{
|
|
|
|
room.unIdle(habbo);
|
|
|
|
this.idleTimer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false))
|
|
|
|
{
|
|
|
|
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-05-12 09:59:01 +02:00
|
|
|
if (!room.tileWalkable(next.x, next.y) && !overrideChecks)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
|
|
|
this.room = room;
|
|
|
|
this.findPath();
|
|
|
|
|
|
|
|
if (!this.path.isEmpty())
|
|
|
|
{
|
|
|
|
next = this.path.pop();
|
|
|
|
item = room.getTopItemAt(next.x, next.y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-12 18:45:00 +02:00
|
|
|
this.status.remove(RoomUnitStatus.MOVE);
|
2018-07-06 15:30:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean canSitNextTile = room.canSitAt(next.x, next.y);
|
|
|
|
|
|
|
|
if (canSitNextTile)
|
|
|
|
{
|
|
|
|
HabboItem lowestChair = room.getLowestChair(next);
|
|
|
|
|
|
|
|
if (lowestChair != null)
|
|
|
|
item = lowestChair;
|
|
|
|
}
|
|
|
|
|
2019-05-12 09:59:01 +02:00
|
|
|
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks)
|
2018-12-22 11:39:00 +01:00
|
|
|
{
|
|
|
|
if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
if (habbo != null)
|
|
|
|
{
|
|
|
|
if (habbo.getHabboInfo().getRiding() != null)
|
|
|
|
{
|
|
|
|
zHeight += 1.0D;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY());
|
|
|
|
if (habboItem != null)
|
|
|
|
{
|
|
|
|
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)]);
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
item.onWalkOn(this, room, null);
|
|
|
|
}
|
|
|
|
else if (item instanceof InteractionGuildGate)
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item.onWalk(this, room, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
zHeight += item.getZ();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
2018-07-06 15:30:00 +02:00
|
|
|
if (habbo != null)
|
|
|
|
{
|
|
|
|
if (habbo.getHabboInfo().getRiding() != null)
|
|
|
|
{
|
|
|
|
RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
if (habbo != null)
|
|
|
|
{
|
2019-05-15 23:54:07 +02:00
|
|
|
if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick")))
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
|
|
|
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Emulator.getLogging().logErrorLine(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public int getId()
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.id;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(int id)
|
|
|
|
{
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomTile getCurrentLocation()
|
|
|
|
{
|
|
|
|
return this.currentLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public short getX()
|
|
|
|
{
|
|
|
|
return this.currentLocation.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
public short getY()
|
|
|
|
{
|
|
|
|
return this.currentLocation.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getZ()
|
|
|
|
{
|
|
|
|
return this.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setZ(double z)
|
|
|
|
{
|
|
|
|
this.z = z;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
public boolean isInRoom()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRotation(RoomUserRotation rotation)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
public void setHeadRotation(RoomUserRotation headRotation)
|
|
|
|
{
|
|
|
|
this.headRotation = headRotation;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
public DanceType getDanceType()
|
|
|
|
{
|
|
|
|
return this.danceType;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDanceType(DanceType danceType) {
|
|
|
|
this.danceType = danceType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCanWalk(boolean value)
|
|
|
|
{
|
|
|
|
this.canWalk = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canWalk()
|
|
|
|
{
|
|
|
|
return this.canWalk;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFastWalk(boolean fastWalk)
|
|
|
|
{
|
|
|
|
this.fastWalk = fastWalk;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isFastWalk()
|
|
|
|
{
|
|
|
|
return this.fastWalk;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomTile getStartLocation()
|
|
|
|
{
|
|
|
|
return this.startLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int tilesWalked()
|
|
|
|
{
|
|
|
|
return this.tilesWalked;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomTile getGoal()
|
|
|
|
{
|
|
|
|
return this.goalLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGoalLocation(RoomTile goalLocation)
|
|
|
|
{
|
2018-09-28 21:25:00 +02:00
|
|
|
if (goalLocation != null)
|
2018-09-12 18:45:00 +02:00
|
|
|
{
|
2018-11-17 14:28:00 +01:00
|
|
|
if (goalLocation.state != RoomTileState.INVALID)
|
2018-09-28 21:25:00 +02:00
|
|
|
{
|
|
|
|
this.setGoalLocation(goalLocation, false);
|
|
|
|
}
|
2018-09-12 18:45:00 +02:00
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setGoalLocation(RoomTile goalLocation, boolean noReset)
|
|
|
|
{
|
|
|
|
if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false))
|
|
|
|
{
|
|
|
|
Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation);
|
|
|
|
Emulator.getPluginManager().fireEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.startLocation = this.currentLocation;
|
|
|
|
|
|
|
|
if (goalLocation != null && !noReset)
|
|
|
|
{
|
|
|
|
this.goalLocation = goalLocation;
|
|
|
|
this.findPath();
|
2018-09-28 21:25:00 +02:00
|
|
|
if (!this.path.isEmpty())
|
|
|
|
{
|
|
|
|
this.tilesWalked = 0;
|
|
|
|
this.cmdSit = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.goalLocation = this.currentLocation;
|
|
|
|
}
|
2018-07-06 15:30:00 +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);
|
2018-07-06 15:30:00 +02:00
|
|
|
this.goalLocation = location;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentLocation(RoomTile location)
|
|
|
|
{
|
|
|
|
if (location != null)
|
|
|
|
{
|
2019-05-12 09:59:01 +02:00
|
|
|
if(this.currentLocation != null) {
|
|
|
|
this.currentLocation.removeUnit(this);
|
|
|
|
}
|
|
|
|
this.currentLocation = location;
|
|
|
|
location.addUnit(this);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public RoomTile getPreviousLocation()
|
|
|
|
{
|
|
|
|
return this.previousLocation;
|
|
|
|
}
|
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
public double getPreviousLocationZ()
|
|
|
|
{
|
|
|
|
return this.previousLocationZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPreviousLocationZ(double z)
|
|
|
|
{
|
|
|
|
this.previousLocationZ = z;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
public void setPreviousLocation(RoomTile previousLocation)
|
|
|
|
{
|
|
|
|
this.previousLocation = previousLocation;
|
2018-10-07 00:28:00 +02:00
|
|
|
this.previousLocationZ = this.z;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setPathFinderRoom(Room room)
|
|
|
|
{
|
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void findPath()
|
|
|
|
{
|
2019-05-12 09:59:01 +02: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)))
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
2019-05-12 09:59:01 +02:00
|
|
|
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-28 21:25:00 +02:00
|
|
|
public void setPath(Deque<RoomTile> path)
|
|
|
|
{
|
|
|
|
this.path = path;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
public boolean isAtGoal()
|
|
|
|
{
|
|
|
|
return this.currentLocation.equals(this.goalLocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isWalking()
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
return !this.isAtGoal() && this.canWalk;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
public String getStatus(RoomUnitStatus key)
|
|
|
|
{
|
|
|
|
return this.status.get(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ConcurrentHashMap<RoomUnitStatus, String> getStatusMap()
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
|
|
|
return this.status;
|
|
|
|
}
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
public void removeStatus(RoomUnitStatus key)
|
|
|
|
{
|
|
|
|
this.status.remove(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatus(RoomUnitStatus key, String value)
|
|
|
|
{
|
|
|
|
if (key != null && value != null)
|
|
|
|
{
|
|
|
|
this.status.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasStatus(RoomUnitStatus key)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
|
|
|
return this.status.containsKey(key);
|
|
|
|
}
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
public void clearStatus()
|
|
|
|
{
|
|
|
|
this.status.clear();
|
|
|
|
}
|
|
|
|
|
2018-09-28 21:25:00 +02:00
|
|
|
public void statusUpdate(boolean update)
|
|
|
|
{
|
|
|
|
this.statusUpdate = update;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean needsStatusUpdate()
|
|
|
|
{
|
|
|
|
return this.statusUpdate;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
public TMap<String, Object> getCacheable()
|
|
|
|
{
|
|
|
|
return this.cacheable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getHandItem()
|
|
|
|
{
|
|
|
|
return this.handItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHandItem(int handItem)
|
|
|
|
{
|
|
|
|
this.handItem = handItem;
|
|
|
|
this.handItemTimestamp = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getHandItemTimestamp()
|
|
|
|
{
|
|
|
|
return this.handItemTimestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEffectId()
|
|
|
|
{
|
|
|
|
return this.effectId;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEffectEndTimestamp()
|
|
|
|
{
|
|
|
|
return this.effectEndTimestamp;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getWalkTimeOut()
|
|
|
|
{
|
|
|
|
return this.walkTimeOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setWalkTimeOut(int walkTimeOut)
|
|
|
|
{
|
|
|
|
this.walkTimeOut = walkTimeOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void increaseIdleTimer()
|
|
|
|
{
|
|
|
|
this.idleTimer++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isIdle()
|
|
|
|
{
|
|
|
|
return this.idleTimer > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds.
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getIdleTimer()
|
|
|
|
{
|
|
|
|
return this.idleTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetIdleTimer()
|
|
|
|
{
|
|
|
|
this.idleTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIdle()
|
|
|
|
{
|
|
|
|
this.idleTimer = Room.IDLE_CYCLES + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void lookAtPoint(RoomTile location)
|
|
|
|
{
|
2018-12-22 11:39:00 +01:00
|
|
|
if (!this.canRotate) return;
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
if(Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false))
|
|
|
|
{
|
|
|
|
Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location);
|
|
|
|
Emulator.getPluginManager().fireEvent(lookAtPointEvent);
|
|
|
|
|
|
|
|
if(lookAtPointEvent.isCancelled())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-12 18:45:00 +02:00
|
|
|
if (this.status.containsKey(RoomUnitStatus.LAY))
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-12 18:45:00 +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)]);
|
|
|
|
|
|
|
|
if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1)
|
|
|
|
{
|
|
|
|
this.headRotation = rotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Deque<RoomTile> getPath()
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.path;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public RoomRightLevels getRightsLevel()
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
return this.rightsLevel;
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightsLevel(RoomRightLevels rightsLevel)
|
|
|
|
{
|
|
|
|
this.rightsLevel = rightsLevel;
|
|
|
|
}
|
2018-09-28 21:25:00 +02:00
|
|
|
|
|
|
|
public void setInvisible(boolean invisible)
|
|
|
|
{
|
|
|
|
this.invisible = invisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInvisible()
|
|
|
|
{
|
|
|
|
return this.invisible;
|
|
|
|
}
|
2019-05-04 11:22:20 +02:00
|
|
|
|
|
|
|
public Room getRoom() {
|
|
|
|
return room;
|
|
|
|
}
|
2019-05-12 09:59:01 +02:00
|
|
|
|
|
|
|
public boolean canOverrideTile(RoomTile tile) {
|
|
|
|
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;
|
|
|
|
if(!this.overridableTiles.contains(tileIndex)) {
|
|
|
|
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;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|