/// <summary> /// Remove item handler /// </summary> public void RemoveItem(Item item, Player player) { RoomTile tile = item.Position.GetTile(room); if (tile == null) { return; } room.Mapping.RemoveItem(item); if (item.Definition.HasBehaviour(ItemBehaviour.WALL_ITEM)) { room.Send(new RemoveWallItemComposer(item)); item.Data.WallPosition = string.Empty; } else { room.Send(new RemoveFloorItemComposer(item)); item.UpdateEntities(); item.Data.X = item.Position.X; item.Data.Y = item.Position.Y; item.Data.Z = item.Position.Z; item.Data.Rotation = item.Position.Rotation; item.ApplyPosition(); } item.Interactor.OnPickup(player); item.Data.RoomId = 0; item.Save(); room.ItemManager.RemoveItem(item); }
public override void OnStop(IEntity entity) { Position destination = entity.RoomEntity.Position.Copy(); if (!IsPillowTile(destination)) { destination = ConvertToPillow(destination); } if (destination != null) { var tile = destination.GetTile(entity.RoomEntity.Room); if (tile == null) { return; } if (!RoomTile.IsValidTile(entity.RoomEntity.Room, entity, destination)) { return; } entity.RoomEntity.Position.Rotation = Item.Position.Rotation; entity.RoomEntity.AddStatus("lay", Item.Definition.Data.TopHeight.ToClientValue()); entity.RoomEntity.NeedsUpdate = true; } }
/// <summary> /// Warp etntiy to position /// </summary> /// <param name="id"></param> /// <param name="v"></param> public void Warp(Position targetPosition, bool instantUpdate = false) { RoomTile oldTile = CurrentTile; if (oldTile != null) { oldTile.RemoveEntity(Entity); } if (Next != null) { RoomTile nextTile = Next.GetTile(Room); if (nextTile != null) { nextTile.RemoveEntity(Entity); } } Position = targetPosition.Copy(); RefreshHeight(targetPosition); RoomTile newTile = CurrentTile; if (newTile != null) { newTile.AddEntity(Entity); } if (instantUpdate && Room != null) { InteractItem(); Room.Send(new UsersStatusComposer(List.Create(Entity))); } }
/// <summary> /// Process user inside room /// </summary> /// <param name="entity">the entity to process</param> private void ProcessUser(IEntity entity) { Position position = entity.RoomEntity.Position; Position goal = entity.RoomEntity.Goal; if (entity.RoomEntity.IsWalking) { if (entity.RoomEntity.Next != null) { entity.RoomEntity.Position.X = entity.RoomEntity.Next.X; entity.RoomEntity.Position.Y = entity.RoomEntity.Next.Y; entity.RoomEntity.Position.Z = entity.RoomEntity.Position.GetTile(room).GetWalkingHeight(); } if (entity.RoomEntity.PathList.Count > 0) { Position next = entity.RoomEntity.PathList[0]; entity.RoomEntity.PathList.Remove(next); var previousTile = entity.RoomEntity.CurrentTile; if (previousTile != null) { previousTile.RemoveEntity(entity); } RoomTile nextTile = next.GetTile(room); if (nextTile == null || !RoomTile.IsValidTile(room, entity, next, lastStep: !entity.RoomEntity.PathList.Any())) { entity.RoomEntity.PathList.Clear(); ProcessUser(entity); entity.RoomEntity.Move(goal.X, goal.Y); return; } nextTile.AddEntity(entity); int rotation = Rotation.CalculateDirection(position.X, position.Y, next.X, next.Y); double height = next.GetTile(room).GetWalkingHeight(); entity.RoomEntity.RemoveStatus("mv"); entity.RoomEntity.RemoveStatus("sit"); entity.RoomEntity.RemoveStatus("lay"); entity.RoomEntity.Position.Rotation = rotation; entity.RoomEntity.AddStatus("mv", string.Format("{0},{1},{2}", next.X, next.Y, height.ToClientValue())); entity.RoomEntity.Next = next; } else { entity.RoomEntity.StopWalking(); } entity.RoomEntity.NeedsUpdate = true; } }
public void DoRoll(IEntity entity, Item roller, Room room, Position fromPosition, Position nextPosition) { RoomTile previousTile = fromPosition.GetTile(room); RoomTile nextTile = nextPosition.GetTile(room); // Temporary fix if the user walks on an item and their height gets put up. if (entity.RoomEntity.CurrentItem != null && entity.RoomEntity.CurrentItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { if (Math.Abs(entity.RoomEntity.Position.Z - roller.Position.Z) >= 0.1) { if (nextTile.HighestItem != null && nextTile.HighestItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { nextPosition.Z = roller.Position.Z + roller.Definition.Data.TopHeight; } } } // The next height but what the client sees. double displayNextHeight = nextPosition.Z; //if (entity.getRoomUser().isSittingOnGround()) //{ // displayNextHeight -= 0.5; // Take away sit offset when sitting on ground, because yeah, weird stuff. //} entity.RoomEntity.RollingData.DisplayHeight = displayNextHeight;//setZ(displayNextHeight); entity.RoomEntity.Position.X = nextPosition.X; entity.RoomEntity.Position.Y = nextPosition.Y; entity.RoomEntity.Position.Z = nextPosition.Z; previousTile.RemoveEntity(entity); nextTile.AddEntity(entity); /* * * * // Fix bounce for sitting on chairs if the chair top height is higher 1.0 * if (entity.getRoomUser().containsStatus(StatusType.SIT)) { * double sitHeight = Double.parseDouble(entity.getRoomUser().getStatus(StatusType.SIT).getValue()); * * if (sitHeight > 1.0) { * displayNextHeight += (sitHeight - 1.0); // Add new height offset found. * } * } * * entity.getRoomUser().getRollingData().setDisplayHeight(displayNextHeight);//setZ(displayNextHeight); * * entity.getRoomUser().getPosition().setX(nextPosition.getX()); * entity.getRoomUser().getPosition().setY(nextPosition.getY()); * entity.getRoomUser().getPosition().setZ(nextPosition.getZ()); * * previousTile.removeEntity(entity); * nextTile.addEntity(entity);*/ }
private void HandleItemAdjusted(Item item, bool isRotation) { RoomTile tile = item.Position.GetTile(room); if (tile == null) { return; } if (!isRotation) { Item highestItem = tile.HighestItem; double tileHeight = tile.TileHeight; if (highestItem != null && highestItem.Id == item.Id) { tileHeight -= highestItem.Height; double defaultHeight = room.Model.TileHeights[item.Position.X, item.Position.Y];//this.room.getModel().getTileHeight(item.getPosition().getX(), item.getPosition().getY()); if (tileHeight < defaultHeight) { tileHeight = defaultHeight; } } item.Position.Z = tileHeight;//.getPosition().setZ(tileHeight); if (highestItem != null && highestItem.RollingData != null) { Item roller = highestItem.RollingData.Roller; if (highestItem.GetItemBelow() != null && highestItem.GetItemBelow().Definition.HasBehaviour(ItemBehaviour.ROLLER)) { // If the difference between the roller, and the next item up is more than 0.5, then set the item below the floating item if (Math.Abs(highestItem.Position.Z - roller.Position.Z) >= 0.5) { item.Position.Z = roller.Position.Z + roller.Definition.GetPositiveTopHeight();//.getPosition().setZ(roller.getPosition().getZ() + roller.getDefinition().getPositiveTopHeight()); } } item.Position.Z = roller.Position.Z + roller.Definition.GetPositiveTopHeight();//getPosition().setZ(roller.getPosition().getZ() + roller.getDefinition().getPositiveTopHeight()); /*if (!highestItem.hasBehaviour(ItemBehaviour.CAN_STACK_ON_TOP)) { * item.getPosition().setZ(roller.getPosition().getZ() + roller.getDefinition().getTopHeight()); * * /*for (Item tileItem : tile.getItems()) { * if (tileItem.getPosition().getZ() >= item.getPosition().getZ()) { * tileItem.getRollingData().setHeightUpdate(item.getDefinition().getTopHeight()); * } * } * }*/ } } }
/// <summary> /// Request move handler /// </summary> /// <param name="x">x coord goal</param> /// <param name="y">y coord goal</param> public void Move(int x, int y) { if (Room == null) { return; } if (Next != null) { var oldPosition = Next.Copy(); Position.X = oldPosition.X; Position.Y = oldPosition.Y; Position.Z = Room.Model.TileHeights[oldPosition.X, oldPosition.Y]; NeedsUpdate = true; } Goal = new Position(x, y); var goalTile = Goal.GetTile(Room); if (goalTile != null && goalTile.HighestItem != null) { if (goalTile.HighestItem.Interactor.OnWalkRequest(Entity, Goal)) { return; } } if (!RoomTile.IsValidTile(Room, Entity, Goal)) { return; } var pathList = Pathfinder.FindPath(Entity, Room, Position, Goal); if (pathList == null) { return; } if (pathList.Count > 0) { PathList = pathList; IsWalking = true; } }
/// <summary> /// Get the closest tile to this current tile /// </summary> public Position ClosestTile(Room room, Position other, IEntity entity = null) { List <Position> potentialTiles = new List <Position>(); for (int i = 0; i < Pathfinder.MovePoints.Length; i++) { potentialTiles.Add(Copy() + Pathfinder.MovePoints[i]); } potentialTiles.RemoveAll(x => !RoomTile.IsValidTile(room, entity, x)); if (potentialTiles.Count > 0) { potentialTiles = potentialTiles.OrderBy(x => x.GetDistanceSquared(other)).ToList(); return(potentialTiles[0]); } return(null); }
/// <summary> /// Add item to map handler /// </summary> internal void AddItem(Item item, Position position = null, string wallPosition = null, Player player = null) { item.Data.RoomId = room.Data.Id; if (item.Definition.HasBehaviour(ItemBehaviour.WALL_ITEM)) { item.Data.WallPosition = wallPosition; room.Send(new WallItemComposer(item)); } else { RoomTile tile = position.GetTile(room); if (tile == null) { return; } position.Z = tile.TileHeight; item.Data.X = position.X; item.Data.Y = position.Y; item.Data.Z = position.Z; item.Data.Rotation = position.Rotation; item.ApplyPosition(); HandleItemAdjusted(item, false); room.Send(new FloorItemComposer(item)); room.Mapping.AddItem(item); item.UpdateEntities(); } item.Interactor.OnPlace(player); item.Save(); room.ItemManager.AddItem(item); }
/// <summary> /// Regenerate the room map /// </summary> public void Load() { Tiles = new RoomTile[model.MapSizeX, model.MapSizeY]; for (int y = 0; y < model.MapSizeY; y++) { for (int x = 0; x < model.MapSizeX; x++) { Tiles[x, y] = new RoomTile( room, new Position(x, y), model.TileHeights[x, y], model.TileStates[x, y] ); } } foreach (var item in room.ItemManager.Items.Values) { if (item.Definition.HasBehaviour(ItemBehaviour.WALL_ITEM)) { continue; } foreach (Position position in AffectedTile.GetAffectedTiles(item)) { var tile = position.GetTile(room); if (tile == null) { continue; } tile.AddItem(item); } } }
public void TryGetRollingData(Item item, Item roller, Room room, out Position nextPosition) { nextPosition = null; if (roller == null || roller.Room == null || roller.CurrentTile == null) { return; } if (item.Id == roller.Id) { return; } if (item.Position.Z < roller.Position.Z) { return; } Position front = roller.Position.GetSquareInFront(); RoomTile frontTile = front.GetTile(room); if (frontTile == null) { return; } // Check all entities in the room foreach (IEntity e in room.Entities.Values) { if (e.RoomEntity.Room == null) { continue; } // Don't roll if an entity is going to walk into the furniture if (e.RoomEntity.Next != null) { if (e.RoomEntity.Next == front) { return; } } // Ignore people who are walking if (e.RoomEntity.IsWalking) { continue; } // Don't roll if there's an entity rolling into you if (e.RoomEntity.RollingData != null) { if (e.RoomEntity.RollingData.NextPosition == front) { return; } } if (e.RoomEntity.Position == front) { return; } } // Check all rolling items in the room foreach (Item floorItem in room.ItemManager.Items.Values.Where(x => !x.Definition.HasBehaviour(ItemBehaviour.WALL_ITEM)).ToList()) { if (floorItem.RollingData != null) { if (floorItem.Position == roller.Position) { continue; } // Don't roll if there's another item that's going to roll into this item if (floorItem.RollingData.NextPosition == front)//.getRollingData().getNextPosition().equals(front)) { return; } } } double nextHeight = item.Position.Z;//this.room.getModel().getTileHeight(roller.Position.getX(), roller.Position.getY()); bool subtractRollerHeight = true; if (frontTile.HighestItem != null) { Item frontRoller = null; foreach (Item frontItem in frontTile.GetTileItems()) { if (!frontItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { continue; } frontRoller = frontItem; } if (frontRoller != null) { subtractRollerHeight = false; if (frontRoller.Position.Z != roller.Position.Z) { if (Math.Abs(frontRoller.Position.Z - roller.Position.Z) > 0.1) { return; // Don't roll if the height of the roller is different by >0.1 } } foreach (Item frontItem in frontTile.GetTileItems()) { if (frontItem.Position.Z < frontRoller.Position.Z) { continue; } if (frontItem.Id == item.Id) { continue; } if (frontItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { Position frontPosition = frontRoller.Position.GetSquareInFront(); // Don't roll an item into the next roller, if the next roller is facing towards the roller // it just rolled from, and the next roller has an item on it. if (frontPosition == item.Position) { if (frontTile.GetItemsAbove(frontRoller).Count > 0 || frontTile.Entities.Count > 0) { return; } } } } Item highestNextItem = frontTile.HighestItem; if (!highestNextItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { if (highestNextItem.Definition.HasBehaviour(ItemBehaviour.IS_STACKABLE) && item.CurrentTile.Entities.IsEmpty) { foreach (Item frontItem in frontRoller.CurrentTile.GetTileItems()) { frontItem.IsRollingBlocked = true; } nextHeight = (highestNextItem.Position.Z + highestNextItem.Definition.Data.TopHeight) + item.Position.Z - frontRoller.Definition.Data.TopHeight; } else { return; } } } else { if (!RoomTile.IsValidTile(room, null, frontTile.Position)) { return; } } } if (subtractRollerHeight) { nextHeight -= roller.Definition.Data.TopHeight; } /*if (nextHeight > GameConfiguration.getInstance().getInteger("stack.height.limit")) * { * nextHeight = GameConfiguration.getInstance().getInteger("stack.height.limit"); * }*/ nextPosition = new Position(front.X, front.Y, nextHeight); item.RollingData = new RollingData { RollingItem = item, Roller = roller, FromPosition = item.Position.Copy(), NextPosition = nextPosition.Copy() }; }
/// <summary> /// Check if the step is valid /// </summary> public static bool IsValidStep(Room room, IEntity entity, Position from, Position to, bool isFinalMove) { if (!RoomTile.IsValidTile(room, entity, to)) { return(false); } if (!RoomTile.IsValidTile(room, entity, from)) { return(false); } /* * double oldHeight = fromTile.getWalkingHeight(); * double newHeight = toTile.getWalkingHeight(); * * Item fromItem = fromTile.getHighestItem(); * Item toItem = toTile.getHighestItem(); * * boolean hasPool = room.getModel().getName().startsWith("pool_") || room.getModel().getName().equals("md_a"); * boolean isPrivateRoom = !room.isPublicRoom(); * * if (hasPool || isPrivateRoom) { * if (hasPool) { * if (oldHeight - 3 >= newHeight) { * return fromItem != null && (fromItem.hasBehaviour(ItemBehaviour.TELEPORTER) || (fromItem.getDefinition().getSprite().equals("wsJoinQueue")) || (fromItem.getDefinition().getSprite().equals("wsQueueTile")) || (fromItem.getDefinition().getSprite().equals("poolEnter")) || (fromItem.getDefinition().getSprite().equals("poolExit"))); || } || ||} || ||if (oldHeight + 1.5 <= newHeight) { || return toItem != null && (toItem.hasBehaviour(ItemBehaviour.TELEPORTER) || (toItem.getDefinition().getSprite().equals("wsJoinQueue")) || (toItem.getDefinition().getSprite().equals("poolEnter")) || (toItem.getDefinition().getSprite().equals("poolExit"))); ||} ||} else { ||// Apply this to the rest of public rooms ||if (oldHeight - 1.5 >= newHeight) { || return false; ||} || ||if (oldHeight + 1.5 <= newHeight) { || return false; ||} ||}*/ var fromTile = from.GetTile(room); var toTile = to.GetTile(room); var oldHeight = fromTile.WalkingHeight; var newHeight = toTile.WalkingHeight; if (oldHeight + 1.5 <= newHeight) { return(false); } return(true); }
public void TryGetRollingData(IEntity entity, Item roller, Room room, out Position nextPosition) { nextPosition = null; if (roller == null || roller.Room == null || roller.CurrentTile == null || entity.RoomEntity.RollingData != null) { return; } if (entity.RoomEntity.IsWalking) { return; } if (entity.RoomEntity.Position.Z < roller.Position.Z) { return; } Position front = roller.Position.GetSquareInFront(); RoomTile frontTile = front.GetTile(room); if (frontTile == null) { return; } // Check all entities in the room foreach (IEntity e in room.Entities.Values) { if (e.RoomEntity.Room == null) { continue; } // Don't roll if an entity is going to walk into the furniture if (e.RoomEntity.Next != null) { if (e.RoomEntity.Next == front) { return; } } // Ignore people who are walking if (e.RoomEntity.IsWalking) { continue; } // Don't roll if there's an entity rolling into you if (e.RoomEntity.RollingData != null) { if (e.RoomEntity.RollingData.NextPosition == front) { return; } } if (e.RoomEntity.Position == front) { return; } } // Check all rolling items in the room foreach (Item floorItem in room.ItemManager.Items.Values.Where(x => !x.Definition.HasBehaviour(ItemBehaviour.WALL_ITEM)).ToList()) { if (floorItem.RollingData != null) { if (floorItem.Position == roller.Position) { continue; } // Don't roll if there's another item that's going to roll into this item if (floorItem.RollingData.NextPosition == front)//.getRollingData().getNextPosition().equals(front)) { return; } } } double nextHeight = entity.RoomEntity.Position.Z;//this.room.getModel().getTileHeight(roller.Position.getX(), roller.Position.getY()); bool subtractRollerHeight = true; if (frontTile.HighestItem != null) { Item frontRoller = null; foreach (Item frontItem in frontTile.GetTileItems()) { if (!frontItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { continue; } frontRoller = frontItem; } if (frontRoller != null) { subtractRollerHeight = false; if (frontRoller.Position.Z != roller.Position.Z) { if (Math.Abs(frontRoller.Position.Z - roller.Position.Z) > 0.1) { return; // Don't roll if the height of the roller is different by >0.1 } } foreach (Item frontItem in frontTile.GetTileItems()) { if (frontItem.Position.Z < frontRoller.Position.Z) { continue; } // This is because the ItemRollingAnalysis has setHighestItem in nextTile in doRoll which blocks this if (entity.RoomEntity.CurrentItem != null && entity.RoomEntity.CurrentItem.Id == frontItem.Id) { continue; } if (frontItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { Position frontPosition = frontRoller.Position.GetSquareInFront(); // Don't roll an item into the next roller, if the next roller is facing towards the roller // it just rolled from, and the next roller has an item on it. if (frontPosition == entity.RoomEntity.Position) { if (frontTile.GetItemsAbove(frontRoller).Count > 0 || frontTile.Entities.Count > 0) { return; } } } else { return; } } } else { if (!RoomTile.IsValidTile(room, entity, frontTile.Position)) { return; } } } if (subtractRollerHeight) { nextHeight -= roller.Definition.Data.TopHeight; } Item currentItem = entity.RoomEntity.CurrentItem; if (currentItem != null && !currentItem.Definition.HasBehaviour(ItemBehaviour.ROLLER)) { // If we can roll but our item can't, don't roll! RoomTaskManager.RollerItemTask.TryGetRollingData(currentItem, roller, room, out var rollPosition); if (rollPosition == null) { return; } } nextPosition = new Position(front.X, front.Y, nextHeight); entity.RoomEntity.RollingData = new RollingData { RollingEntity = entity, Roller = roller, FromPosition = entity.RoomEntity.Position.Copy(), NextPosition = nextPosition.Copy() }; }
public override void OnInteract(IEntity entity, int requestData) { var roomUser = entity.RoomEntity; var room = entity.RoomEntity.Room; if (!string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } Position front = Item.Position.GetSquareInFront(); if (front != roomUser.Position && Item.Position != roomUser.Position) { roomUser.Move(front.X, front.Y); return; } var teleporterData = (TeleporterExtraData)GetJsonObject(); string pairId = ((TeleporterExtraData)GetJsonObject()).LinkedItem; ItemData targetTeleporterData = ItemDao.GetItem(pairId); Item.UpdateState(TELEPORTER_OPEN); roomUser.Move(Item.Position.X, Item.Position.Y); roomUser.WalkingAllowed = false; // Broken link, make user walk in then walk out if (string.IsNullOrEmpty(pairId) || targetTeleporterData == null || RoomManager.Instance.GetRoom(targetTeleporterData.RoomId) == null) { Task.Delay(1000).ContinueWith(t => { roomUser.Move( Item.Position.GetSquareInFront().X, Item.Position.GetSquareInFront().Y ); }); Task.Delay(2000).ContinueWith(t => { Item.UpdateState(TELEPORTER_CLOSE); }); Task.Delay(2500).ContinueWith(t => { roomUser.WalkingAllowed = true; }); return; } var targetTeleporter = ItemManager.Instance.ResolveItem(targetTeleporterData.Id.ToString()); var pairedTeleporter = targetTeleporter ?? new Item(targetTeleporterData); var pairedData = ((TeleporterExtraData)pairedTeleporter.Interactor.GetJsonObject()); roomUser.AuthenticateTeleporterId = pairedTeleporter.Data.Id.ToString(); // Check if the user is inside the teleporter, if so, walk out. Useful if the user is stuck inside. if (Item.Position == roomUser.Position && !RoomTile.IsValidTile(roomUser.Room, entity, Item.Position.GetSquareInFront())) { Item.UpdateState(TELEPORTER_EFFECTS); Task.Delay(1000).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } Item.UpdateState(TELEPORTER_CLOSE); }); Task.Delay(2000).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } if (pairedTeleporter.Data.RoomId == Item.Data.RoomId) { pairedTeleporter.UpdateState(TELEPORTER_EFFECTS); var newPosition = pairedTeleporter.Position.Copy(); newPosition.Rotation = pairedTeleporter.Position.Rotation; roomUser.Warp(newPosition, instantUpdate: true); } else { roomUser.AuthenticateRoomId = pairedTeleporter.Data.RoomId; roomUser.Room.Forward(roomUser.Entity); } }); // Handle teleporting in the same room if (pairedTeleporter.Data.RoomId == Item.Data.RoomId) { Task.Delay(3000).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } pairedTeleporter.UpdateState(TELEPORTER_OPEN); roomUser.Move( pairedTeleporter.Position.GetSquareInFront().X, pairedTeleporter.Position.GetSquareInFront().Y); roomUser.WalkingAllowed = true; }); Task.Delay(4000).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } pairedTeleporter.UpdateState(TELEPORTER_CLOSE); roomUser.AuthenticateTeleporterId = null; }); } return; } // Resume normal teleportation Task.Delay(1000).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } Item.UpdateState(TELEPORTER_EFFECTS); }); Task.Delay(1500).ContinueWith(t => { if (string.IsNullOrEmpty(roomUser.AuthenticateTeleporterId)) { return; } Item.UpdateState(TELEPORTER_CLOSE); if (pairedTeleporter.Data.RoomId != Item.Data.RoomId) { roomUser.AuthenticateRoomId = pairedTeleporter.Room.Data.Id; pairedTeleporter.Room.Forward(roomUser.Entity); } else { roomUser.Warp(pairedTeleporter.Position.Copy(), instantUpdate: true); } if (pairedTeleporter.Data.RoomId == Item.Data.RoomId) { pairedTeleporter.UpdateState(TELEPORTER_EFFECTS); } }); if (pairedTeleporter.Data.RoomId == Item.Data.RoomId) { Task.Delay(3000).ContinueWith(t => { if (roomUser.RoomId != room.Data.Id) { roomUser.AuthenticateTeleporterId = null; return; } pairedTeleporter.UpdateState(TELEPORTER_OPEN); roomUser.WalkingAllowed = true; roomUser.Move( pairedTeleporter.Position.GetSquareInFront().X, pairedTeleporter.Position.GetSquareInFront().Y); }); Task.Delay(4000).ContinueWith(t => { if (roomUser.RoomId != room.Data.Id) { roomUser.AuthenticateTeleporterId = null; return; } roomUser.AuthenticateTeleporterId = null; if (pairedTeleporter.Data.RoomId == Item.Data.RoomId) { pairedTeleporter.UpdateState(TELEPORTER_CLOSE); } else { pairedTeleporter.UpdateState(TELEPORTER_CLOSE); } }); } }