mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-31 12:22:36 +01:00
Merge remote-tracking branch 'origin/dev' into dev222
This commit is contained in:
commit
eb07ed91b2
@ -178,6 +178,7 @@ public class ItemManager {
|
|||||||
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
||||||
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||||
this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
|
this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
|
||||||
|
this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class));
|
||||||
|
|
||||||
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
|
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
@ -16,7 +17,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InteractionEffectVendingMachine extends InteractionDefault {
|
public class InteractionEffectVendingMachine extends InteractionVendingMachine {
|
||||||
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
@ -28,58 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionDefault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
public void giveVendingMachineItem(Habbo habbo, Room room) {
|
||||||
super.onClick(client, room, objects);
|
room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30);
|
||||||
|
|
||||||
if (client != null) {
|
|
||||||
RoomTile tile = getSquareInFront(room.getLayout(), this);
|
|
||||||
|
|
||||||
if (tile != null) {
|
|
||||||
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
|
||||||
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
|
||||||
room.updateHabbo(client.getHabbo());
|
|
||||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
|
|
||||||
client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
|
|
||||||
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
|
||||||
}
|
|
||||||
this.setExtradata("1");
|
|
||||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
|
||||||
Emulator.getThreading().run(this, 1000);
|
|
||||||
HabboItem instance = this;
|
|
||||||
Emulator.getThreading().run(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem(), 30);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
|
|
||||||
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
|
|
||||||
if (t != null && t.isWalkable()) {
|
|
||||||
tile = t;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Runnable> onSuccess = new ArrayList<>();
|
|
||||||
List<Runnable> onFail = new ArrayList<>();
|
|
||||||
|
|
||||||
onSuccess.add(() -> Emulator.getThreading().run(() -> {
|
|
||||||
try {
|
|
||||||
this.onClick(client, room, objects);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}, 500));
|
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InteractionNoSidesVendingMachine extends InteractionVendingMachine {
|
||||||
|
public InteractionNoSidesVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||||
|
super(set, baseItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RoomTile getRequiredTile(Habbo habbo, Room room) {
|
||||||
|
return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true);
|
||||||
|
}
|
||||||
|
}
|
@ -4,13 +4,13 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||||
import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
|
|
||||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
import com.eu.habbo.util.pathfinding.Rotation;
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class InteractionVendingMachine extends HabboItem {
|
public class InteractionVendingMachine extends HabboItem {
|
||||||
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||||
@ -45,28 +46,32 @@ public class InteractionVendingMachine extends HabboItem {
|
|||||||
super.onClick(client, room, objects);
|
super.onClick(client, room, objects);
|
||||||
|
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
RoomTile tile = getSquareInFront(room.getLayout(), this);
|
RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
|
||||||
|
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||||
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
||||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
|
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
|
||||||
room.updateHabbo(client.getHabbo());
|
room.updateHabbo(client.getHabbo());
|
||||||
client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
|
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||||
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||||
}
|
}
|
||||||
this.setExtradata("1");
|
|
||||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
|
||||||
Emulator.getThreading().run(this, 1000);
|
|
||||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
|
|
||||||
|
|
||||||
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
|
||||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
|
||||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
|
||||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
|
||||||
|
|
||||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||||
|
|
||||||
|
this.setExtradata("1");
|
||||||
|
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||||
|
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||||
|
|
||||||
|
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||||
|
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||||
|
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||||
|
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
|
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
|
||||||
@ -81,13 +86,42 @@ public class InteractionVendingMachine extends HabboItem {
|
|||||||
List<Runnable> onSuccess = new ArrayList<>();
|
List<Runnable> onSuccess = new ArrayList<>();
|
||||||
List<Runnable> onFail = new ArrayList<>();
|
List<Runnable> onFail = new ArrayList<>();
|
||||||
|
|
||||||
onSuccess.add(() -> Emulator.getThreading().run(() -> {
|
RoomTile finalTile = tile;
|
||||||
|
onSuccess.add(() -> {
|
||||||
|
this.setExtradata("1");
|
||||||
|
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.onClick(client, room, objects);
|
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}, 500));
|
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
Runnable procedure = () -> {
|
||||||
|
if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
|
||||||
|
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||||
|
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||||
|
|
||||||
|
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||||
|
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||||
|
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||||
|
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||||
|
}, 500).get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(procedure, 300));
|
||||||
|
}, 250);
|
||||||
|
});
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail));
|
||||||
@ -136,4 +170,45 @@ public class InteractionVendingMachine extends HabboItem {
|
|||||||
public boolean isUsable() {
|
public boolean isUsable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rotateToMachine(RoomUnit unit) {
|
||||||
|
RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
|
||||||
|
boolean onlyHead = false;
|
||||||
|
|
||||||
|
switch (unit.getBodyRotation()) {
|
||||||
|
case NORTH_EAST:
|
||||||
|
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST))
|
||||||
|
onlyHead = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORTH_WEST:
|
||||||
|
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST))
|
||||||
|
onlyHead = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH_EAST:
|
||||||
|
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST))
|
||||||
|
onlyHead = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH_WEST:
|
||||||
|
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST))
|
||||||
|
onlyHead = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyHead) {
|
||||||
|
unit.setHeadRotation(rotation);
|
||||||
|
} else {
|
||||||
|
unit.setRotation(rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveVendingMachineItem(Habbo habbo, Room room) {
|
||||||
|
Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoomTile getRequiredTile(Habbo habbo, Room room) {
|
||||||
|
return getSquareInFront(room.getLayout(), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ public class RoomLayout {
|
|||||||
return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
|
return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LinkedList<>();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RoomTile findTile(List<RoomTile> tiles, short x, short y) {
|
private RoomTile findTile(List<RoomTile> tiles, short x, short y) {
|
||||||
|
@ -27,6 +27,7 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
public class RoomUnit {
|
public class RoomUnit {
|
||||||
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
||||||
@ -65,6 +66,7 @@ public class RoomUnit {
|
|||||||
private int walkTimeOut;
|
private int walkTimeOut;
|
||||||
private int effectId;
|
private int effectId;
|
||||||
private int effectEndTimestamp;
|
private int effectEndTimestamp;
|
||||||
|
private ScheduledFuture moveBlockingTask;
|
||||||
|
|
||||||
private int idleTimer;
|
private int idleTimer;
|
||||||
private Room room;
|
private Room room;
|
||||||
@ -175,6 +177,9 @@ public class RoomUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
|
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
|
||||||
|
|
||||||
|
if (peekPath == null) peekPath = new LinkedList<>();
|
||||||
|
|
||||||
if (peekPath.size() >= 3) {
|
if (peekPath.size() >= 3) {
|
||||||
if (path.isEmpty()) return true;
|
if (path.isEmpty()) return true;
|
||||||
|
|
||||||
@ -541,10 +546,9 @@ public class RoomUnit {
|
|||||||
|
|
||||||
public void findPath()
|
public void findPath()
|
||||||
{
|
{
|
||||||
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)))
|
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;
|
||||||
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,4 +772,12 @@ public class RoomUnit {
|
|||||||
.filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y))
|
.filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y))
|
||||||
.min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null);
|
.min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScheduledFuture getMoveBlockingTask() {
|
||||||
|
return moveBlockingTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
|
||||||
|
this.moveBlockingTask = moveBlockingTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,8 @@ public class RoomUserWalkEvent extends MessageHandler {
|
|||||||
|
|
||||||
// This is where we set the end location and begin finding a path
|
// This is where we set the end location and begin finding a path
|
||||||
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
|
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
|
||||||
|
if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get();
|
||||||
|
|
||||||
roomUnit.setGoalLocation(tile);
|
roomUnit.setGoalLocation(tile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,17 +29,17 @@ public class RoomUnitWalkToLocation implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.walker.getGoal().equals(this.goalTile)) {
|
|
||||||
onFail();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.walker.getCurrentLocation().equals(this.goalTile)) {
|
if (this.walker.getCurrentLocation().equals(this.goalTile)) {
|
||||||
onSuccess();
|
onSuccess();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(this, 500);
|
if (!this.walker.getGoal().equals(this.goalTile)) {
|
||||||
|
onFail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(this, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSuccess() {
|
private void onSuccess() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user