internal void RoomCycleTask() { if (this.loadedBallRooms.Count > 0) { TimeSpan sinceBallLastTime = DateTime.Now - cycleBallLastExecution; if (sinceBallLastTime.TotalMilliseconds >= 145 && roomCyclingEnabled) { cycleBallLastExecution = DateTime.Now; foreach (Room Room in this.loadedBallRooms) { try { if (Room.GotSoccer()) { Room.GetSoccer().OnCycle(); } } catch (Exception e) { Logging.LogCriticalException("INVALID MARIO BUG IN BALLMOVEMENT: <" + Room.Id + "> :" + e); } } } } TimeSpan sinceLastTime = DateTime.Now - cycleLastExecution; if (sinceLastTime.TotalMilliseconds >= 500 && roomCyclingEnabled) { cycleLastExecution = DateTime.Now; foreach (Room Room in loadedRooms.Values) { if (Room.procesoEnCurso == false) { ThreadPool.UnsafeQueueUserWorkItem(Room.ProcessRoom, null); Room.procesoIntentos = 0; } else { Room.procesoIntentos++; if (Room.procesoIntentos > 30) { mToRemove.Add(Room); } } } } }
internal void RemoveFurniture(GameClient Session, uint pId) { RoomItem Item = GetItem(pId); if (Item == null) { return; } if (Item.GetBaseItem().InteractionType == InteractionType.fbgate) { room.GetSoccer().UnRegisterGate(Item); } Item.Interactor.OnRemove(Session, Item); RemoveRoomItem(Item); if (Item.wiredHandler != null) { using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { Item.wiredHandler.DeleteFromDatabase(dbClient); Item.wiredHandler.Dispose(); room.GetWiredHandler().RemoveFurniture(Item); } Item.wiredHandler = null; } if (Item.wiredCondition != null) { using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { Item.wiredCondition.DeleteFromDatabase(dbClient); Item.wiredCondition.Dispose(); room.GetWiredHandler().conditionHandler.ClearTile(Item.Coordinate); } Item.wiredCondition = null; } }
internal void UpdateUserStatus(RoomUser User, bool cyclegameitems) { if (User == null) { return; } bool isBot = User.IsBot; if (isBot) { cyclegameitems = false; } if (User.Statusses.ContainsKey("lay") || User.Statusses.ContainsKey("sit")) { User.Statusses.Remove("lay"); User.Statusses.Remove("sit"); User.UpdateNeeded = true; } //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y); CoordItemSearch ItemSearch = new CoordItemSearch(room.GetGameMap().CoordinatedItems); List <RoomItem> ItemsOnSquare = ItemSearch.GetAllRoomItemForSquare(User.X, User.Y); double newZ = room.GetGameMap().SqAbsoluteHeight(User.X, User.Y, ItemsOnSquare); if (newZ != User.Z) { User.Z = newZ; if (User.isFlying) { User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); } User.UpdateNeeded = true; } DynamicRoomModel Model = room.GetGameMap().Model; if (Model.SqState[User.X, User.Y] == SquareState.SEAT) { if (!User.Statusses.ContainsKey("sit")) { User.Statusses.Add("sit", "1.0"); } User.Z = Model.SqFloorHeight[User.X, User.Y]; if (User.isFlying) { User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); } User.RotHead = Model.SqSeatRot[User.X, User.Y]; User.RotBody = Model.SqSeatRot[User.X, User.Y]; User.UpdateNeeded = true; } foreach (RoomItem Item in ItemsOnSquare) { if (cyclegameitems) { Item.UserWalksOnFurni(User); } if (Item.GetBaseItem().IsSeat) { if (!User.Statusses.ContainsKey("sit")) { User.Statusses.Add("sit", TextHandling.GetString(Item.GetBaseItem().Height)); } User.Z = Item.GetZ; if (User.isFlying) { User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); } User.RotHead = Item.Rot; User.RotBody = Item.Rot; User.UpdateNeeded = true; } switch (Item.GetBaseItem().InteractionType) { case InteractionType.bed: { if (!User.Statusses.ContainsKey("lay")) { User.Statusses.Add("lay", TextHandling.GetString(Item.GetBaseItem().Height) + " null"); } User.Z = Item.GetZ; if (User.isFlying) { User.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * User.flyk)); } User.RotHead = Item.Rot; User.RotBody = Item.Rot; User.UpdateNeeded = true; break; } case InteractionType.fbgate: { if (cyclegameitems) { if (User.team != Item.team) { User.team = Item.team; } else if (User.team == Item.team) { User.team = Team.none; } if (!string.IsNullOrEmpty(Item.Figure)) { //User = GetUserForSquare(Item.Coordinate.X, Item.Coordinate.Y); if (User != null && !User.IsBot) { if (User.Coordinate == Item.Coordinate) { if (User.GetClient().GetHabbo().Gender != Item.Gender && User.GetClient().GetHabbo().Look != Item.Figure) { User.GetClient().GetHabbo().tempGender = User.GetClient().GetHabbo().Gender; User.GetClient().GetHabbo().tempLook = User.GetClient().GetHabbo().Look; User.GetClient().GetHabbo().Gender = Item.Gender; User.GetClient().GetHabbo().Look = Item.Figure; } else { User.GetClient().GetHabbo().Gender = User.GetClient().GetHabbo().tempGender; User.GetClient().GetHabbo().Look = User.GetClient().GetHabbo().tempLook; } ServerMessage RoomUpdate = new ServerMessage(266); RoomUpdate.AppendInt32(User.VirtualId); RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Look); RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Gender.ToLower()); RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Motto); room.SendMessage(RoomUpdate); } } } } break; } //33: Red //34: Green //35: Blue //36: Yellow case InteractionType.banzaigategreen: case InteractionType.banzaigateblue: case InteractionType.banzaigatered: case InteractionType.banzaigateyellow: { if (cyclegameitems) { int effectID = (int)Item.team + 32; AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (User.team != Item.team) { User.team = Item.team; if (efectmanager.CurrentEffect != effectID) { efectmanager.ApplyCustomEffect(effectID); } } else { if (efectmanager.CurrentEffect == effectID) { efectmanager.ApplyCustomEffect(0); } User.team = Team.none; } } break; } case InteractionType.freezeyellowgate: case InteractionType.freezeredgate: case InteractionType.freezegreengate: case InteractionType.freezebluegate: { if (cyclegameitems) { int effectID = (int)Item.team + 39; AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (User.team != Item.team) { User.team = Item.team; if (efectmanager.CurrentEffect != effectID) { efectmanager.ApplyCustomEffect(effectID); } } else { if (efectmanager.CurrentEffect == effectID) { efectmanager.ApplyCustomEffect(0); } User.team = Team.none; } ServerMessage message = new ServerMessage(700); message.AppendBoolean((User.team != Team.none)); User.GetClient().SendMessage(message); } break; } case InteractionType.banzaitele: { room.GetGameItemHandler().onTeleportRoomUserEnter(User, Item); break; } } } if (cyclegameitems) { if (room.GotSoccer()) { room.GetSoccer().OnUserWalk(User); } if (room.GotBanzai()) { room.GetBanzai().OnUserWalk(User); } //if (room.GotFreeze()) room.GetFreeze().OnUserWalk(User); } }
private void AddSpecialItems(RoomItem item) { switch (item.GetBaseItem().InteractionType) { case InteractionType.fbgate: //IsTrans = true; room.GetSoccer().RegisterGate(item); string[] splittedExtraData = item.ExtraData.Split(':'); if (string.IsNullOrEmpty(item.ExtraData) || splittedExtraData.Length <= 1) { item.Gender = "M"; switch (item.team) { case Team.yellow: item.Figure = "lg-275-93.hr-115-61.hd-207-14.ch-265-93.sh-305-62"; break; case Team.red: item.Figure = "lg-275-96.hr-115-61.hd-180-3.ch-265-96.sh-305-62"; break; case Team.green: item.Figure = "lg-275-102.hr-115-61.hd-180-3.ch-265-102.sh-305-62"; break; case Team.blue: item.Figure = "lg-275-108.hr-115-61.hd-180-3.ch-265-108.sh-305-62"; break; } } else { item.Gender = splittedExtraData[0]; item.Figure = splittedExtraData[1]; } break; case InteractionType.banzaifloor: { room.GetBanzai().AddTile(item, item.Id); break; } case InteractionType.banzaipyramid: { room.GetGameItemHandler().AddPyramid(item, item.Id); break; } case InteractionType.banzaitele: { room.GetGameItemHandler().AddTeleport(item, item.Id); item.ExtraData = ""; break; } case InteractionType.banzaipuck: { room.GetBanzai().AddPuck(item); break; } case InteractionType.football: { room.GetSoccer().AddBall(item); break; } case InteractionType.freezetileblock: { room.GetFreeze().AddFreezeBlock(item); break; } case InteractionType.freezetile: { room.GetFreeze().AddFreezeTile(item); break; } case InteractionType.freezeexit: { RoomItem _item = room.GetFreeze().ExitTeleport; if (_item == null) { break; } if (item.Id == _item.Id) { room.GetFreeze().ExitTeleport = null; } break; } } }