public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage) { bool NeedsReAdd = false; if (!newItem) { NeedsReAdd = this.GetRoom.GetGameMap().RemoveFromMap(Item); } Dictionary <int, ThreeDCoord> affectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); foreach (ThreeDCoord threeDcoord in affectedTiles.Values) { if (!this.GetRoom.GetGameMap().ValidTile(threeDcoord.X, threeDcoord.Y) || (this.GetRoom.GetGameMap().SquareHasUsers(threeDcoord.X, threeDcoord.Y) && !Item.GetBaseItem().IsSeat&& Item.GetBaseItem().InteractionType != InteractionType.bed) || this.GetRoom.GetGameMap().Model.SqState[threeDcoord.X, threeDcoord.Y] != SquareState.OPEN) { if (NeedsReAdd) { this.UpdateItem(Item); this.GetRoom.GetGameMap().AddToMap(Item); } return(false); } } double pZ = (double)this.GetRoom.GetGameMap().Model.SqFloorHeight[newX, newY]; List <Item> ItemsAffected = new List <Item>(); List <Item> ItemsComplete = new List <Item>(); foreach (ThreeDCoord threeDcoord in affectedTiles.Values) { List <Item> Temp = this.GetRoom.GetGameMap().GetCoordinatedItems(new Point(threeDcoord.X, threeDcoord.Y)); if (Temp != null) { ItemsAffected.AddRange(Temp); } } //ItemsComplete.AddRange(ItemsOnTile); ItemsComplete.AddRange(ItemsAffected); bool ConstruitMode = false; bool ConstruitZMode = false; double ConstruitHeigth = 1.0; bool PileMagic = false; if (Item.GetBaseItem().InteractionType == InteractionType.pilemagic) { PileMagic = true; } if (Session != null && Session.GetHabbo() != null && Session.GetHabbo().CurrentRoom != null) { RoomUser User_room = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id); if (User_room != null) { ConstruitMode = User_room.ConstruitMode; ConstruitZMode = User_room.ConstruitZMode; ConstruitHeigth = User_room.ConstruitHeigth; } } if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY && !ConstruitZMode) { pZ = Item.GetZ; } if (ConstruitZMode) { pZ = pZ + ConstruitHeigth; } else { foreach (Item roomItem in ItemsComplete) { if (roomItem.GetBaseItem().InteractionType == InteractionType.pilemagic) { pZ = roomItem.GetZ; PileMagic = true; break; } if (roomItem.Id != Item.Id && roomItem.TotalHeight > pZ) { if (ConstruitMode) { pZ = roomItem.GetZ + ConstruitHeigth; } else { pZ = roomItem.TotalHeight; } } } } if (!OnRoller) { foreach (Item roomItem in ItemsComplete) { if (roomItem != null && roomItem.Id != Item.Id && (roomItem.GetBaseItem() != null && (!roomItem.GetBaseItem().Stackable&& !ConstruitMode && !PileMagic && !ConstruitZMode))) { if (NeedsReAdd) { this.UpdateItem(Item); this.GetRoom.GetGameMap().AddToMap(Item); } return(false); } } } if (newRot != 1 && newRot != 2 && newRot != 3 && newRot != 4 && newRot != 5 && newRot != 6 && newRot != 7 && newRot != 8) { newRot = 0; } List <RoomUser> userForSquare = new List <RoomUser>(); foreach (ThreeDCoord threeDcoord in Item.GetAffectedTiles.Values) { userForSquare.AddRange(this.GetRoom.GetGameMap().GetRoomUsers(new Point(threeDcoord.X, threeDcoord.Y))); } Item.Rotation = newRot; Item.SetState(newX, newY, pZ, affectedTiles); if (!OnRoller && Session != null) { Item.Interactor.OnPlace(Session, Item); } if (newItem) { if (this._floorItems.ContainsKey(Item.Id)) { if (Session != null) { Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("room.itemplaced", Session.Langue)); } return(true); } else { if (Item.IsFloorItem && !this._floorItems.ContainsKey(Item.Id)) { this._floorItems.TryAdd(Item.Id, Item); } else if (Item.IsWallItem && !this._wallItems.ContainsKey(Item.Id)) { this._wallItems.TryAdd(Item.Id, Item); } this.UpdateItem(Item); if (sendMessage) { this.GetRoom.SendPacket(new ObjectAddComposer(Item, this.GetRoom.RoomData.OwnerName, this.GetRoom.RoomData.OwnerId)); } } } else { this.UpdateItem(Item); if (!OnRoller && sendMessage) { GetRoom.SendPacket(new ObjectUpdateComposer(Item, GetRoom.RoomData.OwnerId)); } } this.GetRoom.GetGameMap().AddToMap(Item); foreach (ThreeDCoord threeDcoord in Item.GetAffectedTiles.Values) { userForSquare.AddRange(this.GetRoom.GetGameMap().GetRoomUsers(new Point(threeDcoord.X, threeDcoord.Y))); } foreach (RoomUser User in userForSquare) { if (User == null) { continue; } if (User.IsWalking) { continue; } this.GetRoom.GetRoomUserManager().UpdateUserStatus(User, false); } return(true); }
public void RotReset(Item pItem, int newRot) { pItem.Rotation = newRot; GetRoom.SendPacket(new ObjectUpdateComposer(pItem, GetRoom.RoomData.OwnerId)); }