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);
            }
        }
Exemple #2
0
        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);
            }
        }