public static bool useObject(Player p, int id, Location location, int option) { foreach (LoadedLaddersAndStairs.HeightObject heightObject in LoadedLaddersAndStairs.objects) { if (heightObject.getId() == id) { if (heightObject.getLocation().Equals(location) && heightObject.getOption() == option) { LoadedLaddersAndStairs.HeightObject obj = heightObject; if (heightObject.getType() == LoadedLaddersAndStairs.Event_Type.COORDINATE_POSITION) { CoordinateEvent useObjectCoordinateEvent = new CoordinateEvent(p, heightObject.getStandLocation()); useObjectCoordinateEvent.setAction(() => { LaddersAndStairs.teleport(p, obj); }); Server.registerCoordinateEvent(useObjectCoordinateEvent); } else if (heightObject.getType() == LoadedLaddersAndStairs.Event_Type.AREA_POSITION) { AreaEvent useObjectAreaEvent = new AreaEvent(p, heightObject.getMinCoords().getX(), heightObject.getMinCoords().getY(), heightObject.getMaxCoords().getX(), heightObject.getMaxCoords().getY()); useObjectAreaEvent.setAction(() => { LaddersAndStairs.teleport(p, obj); }); Server.registerCoordinateEvent(useObjectAreaEvent); } return(true); } } } return(false); }
public static void teleport(Player p, LoadedLaddersAndStairs.HeightObject obj) { p.getWalkingQueue().resetWalkingQueue(); p.setTemporaryAttribute("unmovable", true); p.setFaceLocation(obj.getLocation()); if (obj.getAnimation() != -1) { p.setLastAnimation(new Animation(obj.getAnimation())); } Event teleportEvent = new Event(obj.getAnimation() != -1 ? obj.getTeleDelay() : 500); teleportEvent.setAction(() => { teleportEvent.stop(); p.teleport(obj.getTeleLocation()); p.removeTemporaryAttribute("unmovable"); }); Server.registerEvent(teleportEvent); }