Beispiel #1
0
        internal bool RemoveFromMap(RoomItem item, bool handleGameItem)
        {
            if (handleGameItem)
            {
                RemoveSpecialItem(item);
            }

            if (room.GotSoccer())
            {
                room.GetSoccer().onGateRemove(item);
            }

            bool isRemoved = false;

            foreach (Point coord in item.GetCoords)
            {
                if (RemoveCoordinatedItem(item, coord))
                {
                    isRemoved = true;
                }
            }

            Hashtable items = new Hashtable();

            foreach (Point tile in item.GetCoords)
            {
                Point point = new Point(tile.X, tile.Y);
                if (mCoordinatedItems.ContainsKey(point))
                {
                    List <RoomItem> __items = (List <RoomItem>)mCoordinatedItems[point];
                    if (!items.ContainsKey(tile))
                    {
                        items.Add(tile, __items);
                    }
                }
                SetDefaultValue(tile.X, tile.Y);
            }

            foreach (Point coord in items.Keys)
            {
                if (!items.ContainsKey(coord))
                {
                    continue;
                }

                List <RoomItem> _items = (List <RoomItem>)items[coord];

                foreach (RoomItem _item in _items)
                {
                    ConstructMapForItem(_item, coord);
                }
            }

            items.Clear();
            items = null;
            return(isRemoved);
        }
Beispiel #2
0
        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);
                        }
                    }
                }
            }
        }
Beispiel #3
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);
            }
        }