mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-31 12:22:36 +01:00
Pathfinder fixes
This commit is contained in:
parent
62610a0a5f
commit
d652210751
@ -80,7 +80,10 @@ public class InteractionMultiHeight extends HabboItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateUnitsOnItem(Room room) {
|
public void updateUnitsOnItem(Room room) {
|
||||||
Collection<RoomUnit> unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(this.getX(), this.getY()));
|
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
|
||||||
|
|
||||||
|
for(RoomTile tile : occupiedTiles) {
|
||||||
|
Collection<RoomUnit> unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.x, tile.y));
|
||||||
|
|
||||||
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
||||||
for (RoomUnit unit : unitsOnItem) {
|
for (RoomUnit unit : unitsOnItem) {
|
||||||
@ -94,17 +97,18 @@ public class InteractionMultiHeight extends HabboItem {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if(this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||||
unit.sitUpdate = true;
|
unit.sitUpdate = true;
|
||||||
}
|
unit.statusUpdate(true);
|
||||||
|
} else {
|
||||||
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
||||||
unit.setPreviousLocationZ(unit.getZ());
|
unit.setPreviousLocationZ(unit.getZ());
|
||||||
|
unit.statusUpdate(true);
|
||||||
updatedUnits.add(unit);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
//room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -566,12 +566,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return RoomTileState.INVALID;
|
return RoomTileState.INVALID;
|
||||||
|
|
||||||
RoomTileState result = RoomTileState.OPEN;
|
RoomTileState result = RoomTileState.OPEN;
|
||||||
HabboItem highestItem = null;
|
//HabboItem highestItem = null;
|
||||||
HabboItem lowestChair = this.getLowestChair(tile);
|
//HabboItem lowestChair = this.getLowestChair(tile);
|
||||||
THashSet<HabboItem> items = this.getItemsAt(tile);
|
THashSet<HabboItem> items = this.getItemsAt(tile);
|
||||||
|
|
||||||
if (items == null) return RoomTileState.INVALID;
|
if (items == null) return RoomTileState.INVALID;
|
||||||
|
|
||||||
|
HabboItem tallestItem = null;
|
||||||
|
|
||||||
for (HabboItem item : items) {
|
for (HabboItem item : items) {
|
||||||
if (exclude != null && item == exclude) continue;
|
if (exclude != null && item == exclude) continue;
|
||||||
|
|
||||||
@ -579,13 +581,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return RoomTileState.LAY;
|
return RoomTileState.LAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
|
/*if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
highestItem = item;*/
|
||||||
|
|
||||||
|
if(tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
highestItem = item;
|
|
||||||
if (result == RoomTileState.OPEN) {
|
|
||||||
result = this.checkStateForItem(item, tile);
|
result = this.checkStateForItem(item, tile);
|
||||||
}
|
tallestItem = item;
|
||||||
|
|
||||||
/*if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
|
/*if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
|
||||||
continue;
|
continue;
|
||||||
@ -602,7 +607,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowestChair != null) return RoomTileState.SIT;
|
//if (lowestChair != null) return RoomTileState.SIT;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -751,13 +756,20 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
THashSet<RoomUnit> roomUnits = new THashSet<>();
|
THashSet<RoomUnit> roomUnits = new THashSet<>();
|
||||||
for (Habbo habbo : habbos) {
|
for (Habbo habbo : habbos) {
|
||||||
|
|
||||||
|
double oldZ = habbo.getRoomUnit().getZ();
|
||||||
|
RoomUserRotation oldRotation = habbo.getRoomUnit().getBodyRotation();
|
||||||
double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight();
|
double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight();
|
||||||
|
boolean updated = false;
|
||||||
|
|
||||||
if ((item == null && !habbo.getRoomUnit().cmdSit) || (item != null && !item.getBaseItem().allowSit()))
|
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().cmdSit) || (item != null && !item.getBaseItem().allowSit()))) {
|
||||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
|
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ((item == null && !habbo.getRoomUnit().cmdLay) || (item != null && !item.getBaseItem().allowLay()))
|
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().cmdLay) || (item != null && !item.getBaseItem().allowLay()))) {
|
||||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
|
habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
|
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
|
||||||
habbo.getRoomUnit().setZ(item.getZ());
|
habbo.getRoomUnit().setZ(item.getZ());
|
||||||
@ -767,8 +779,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
habbo.getRoomUnit().setZ(z);
|
habbo.getRoomUnit().setZ(z);
|
||||||
habbo.getRoomUnit().setPreviousLocationZ(z);
|
habbo.getRoomUnit().setPreviousLocationZ(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(habbo.getRoomUnit().getCurrentLocation().is(x, y) && (oldZ != z || updated || oldRotation != habbo.getRoomUnit().getBodyRotation())) {
|
||||||
roomUnits.add(habbo.getRoomUnit());
|
roomUnits.add(habbo.getRoomUnit());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!roomUnits.isEmpty()) {
|
if (!roomUnits.isEmpty()) {
|
||||||
this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose());
|
this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose());
|
||||||
@ -1408,7 +1423,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HabboItem nextTileChair = this.getLowestChair(tileInFront);
|
HabboItem nextTileChair = this.getTallestChair(tileInFront);
|
||||||
|
|
||||||
THashSet<Integer> usersRolledThisTile = new THashSet<>();
|
THashSet<Integer> usersRolledThisTile = new THashSet<>();
|
||||||
|
|
||||||
@ -1463,7 +1478,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
if (unit.getGoal() == rollerTile) {
|
if (unit.getGoal() == rollerTile) {
|
||||||
try {
|
try {
|
||||||
item.onWalkOn(unit, room, null);
|
item.onWalkOn(unit, room, new Object[] { rollerTile, tileInFront });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Caught exception", e);
|
LOGGER.error("Caught exception", e);
|
||||||
}
|
}
|
||||||
@ -1602,15 +1617,15 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!unit.isWalking() && !unit.cmdSit) {
|
if (!unit.isWalking() && !unit.cmdSit) {
|
||||||
HabboItem topItem = this.getLowestChair(this.getLayout().getTile(unit.getX(), unit.getY()));
|
RoomTile thisTile = this.getLayout().getTile(unit.getX(), unit.getY());
|
||||||
|
HabboItem topItem = this.getTallestChair(thisTile);
|
||||||
|
|
||||||
if (topItem == null || !topItem.getBaseItem().allowSit()) {
|
if (topItem == null || !topItem.getBaseItem().allowSit()) {
|
||||||
if (unit.hasStatus(RoomUnitStatus.SIT)) {
|
if (unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||||
unit.removeStatus(RoomUnitStatus.SIT);
|
unit.removeStatus(RoomUnitStatus.SIT);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (thisTile.state == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate)) {
|
||||||
if (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate) {
|
|
||||||
this.dance(unit, DanceType.NONE);
|
this.dance(unit, DanceType.NONE);
|
||||||
//int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z;
|
//int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z;
|
||||||
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + "");
|
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + "");
|
||||||
@ -1621,7 +1636,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!unit.isWalking() && !unit.cmdLay) {
|
if (!unit.isWalking() && !unit.cmdLay) {
|
||||||
HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY());
|
HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY());
|
||||||
@ -3548,6 +3562,26 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return lowestChair;
|
return lowestChair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HabboItem getTallestChair(RoomTile tile) {
|
||||||
|
HabboItem lowestChair = null;
|
||||||
|
|
||||||
|
THashSet<HabboItem> items = this.getItemsAt(tile);
|
||||||
|
if (items != null && !items.isEmpty()) {
|
||||||
|
for (HabboItem item : items) {
|
||||||
|
|
||||||
|
if(!item.getBaseItem().allowSit())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) < item.getZ() + Item.getCurrentHeight(item))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lowestChair = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lowestChair;
|
||||||
|
}
|
||||||
|
|
||||||
public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) {
|
public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) {
|
||||||
|
|
||||||
if (x < 0 || y < 0 || this.layout == null)
|
if (x < 0 || y < 0 || this.layout == null)
|
||||||
@ -3578,11 +3612,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
height = item.getZ() + Item.getCurrentHeight(item);
|
height = item.getZ() + Item.getCurrentHeight(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
HabboItem lowestChair = this.getLowestChair(x, y);
|
/*HabboItem lowestChair = this.getLowestChair(x, y);
|
||||||
if (lowestChair != null && lowestChair != exclude) {
|
if (lowestChair != null && lowestChair != exclude) {
|
||||||
canStack = true;
|
canStack = true;
|
||||||
height = lowestChair.getZ();
|
height = lowestChair.getZ();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (calculateHeightmap) {
|
if (calculateHeightmap) {
|
||||||
return (canStack ? height * 256.0D : Short.MAX_VALUE);
|
return (canStack ? height * 256.0D : Short.MAX_VALUE);
|
||||||
@ -3658,41 +3692,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (items == null)
|
if (items == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HabboItem topItem = null;
|
HabboItem tallestItem = null;
|
||||||
HabboItem lowestSitItem = null;
|
|
||||||
boolean canSitUnder = false;
|
|
||||||
|
|
||||||
for (HabboItem item : items) {
|
for (HabboItem item : items) {
|
||||||
if ((lowestSitItem == null || lowestSitItem.getZ() > item.getZ()) && item.getBaseItem().allowSit()) {
|
if(tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item))
|
||||||
lowestSitItem = item;
|
continue;
|
||||||
canSitUnder = true;
|
|
||||||
|
tallestItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowestSitItem != null && canSitUnder) {
|
if (tallestItem == null)
|
||||||
if (item != lowestSitItem) {
|
|
||||||
double distance = item.getZ() - lowestSitItem.getZ();
|
|
||||||
|
|
||||||
if (distance >= 0 && distance < 0.8) {
|
|
||||||
canSitUnder = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topItem == null || Item.getCurrentHeight(item) > Item.getCurrentHeight(topItem)) {
|
|
||||||
topItem = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topItem == null)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (lowestSitItem == null)
|
return tallestItem.getBaseItem().allowSit();
|
||||||
return false;
|
|
||||||
|
|
||||||
if (topItem == lowestSitItem)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return topItem.getZ() <= lowestSitItem.getZ() || (canSitUnder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canLayAt(int x, int y) {
|
public boolean canLayAt(int x, int y) {
|
||||||
|
@ -260,10 +260,10 @@ public class RoomUnit {
|
|||||||
boolean canSitNextTile = room.canSitAt(next.x, next.y);
|
boolean canSitNextTile = room.canSitAt(next.x, next.y);
|
||||||
|
|
||||||
if (canSitNextTile) {
|
if (canSitNextTile) {
|
||||||
HabboItem lowestChair = room.getLowestChair(next);
|
HabboItem tallestChair = room.getTallestChair(next);
|
||||||
|
|
||||||
if (lowestChair != null)
|
if (tallestChair != null)
|
||||||
item = lowestChair;
|
item = tallestChair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) {
|
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user