Exemplo n.º 1
0
        private void HandleUsers(Object Obj)
        {
            foreach (VirtualRoomUser User in GetUsers())
            {
                try
                {
                    User.GetClient();
                }
                catch { RemoveUser(User.HabboId); continue; }

                User.SuppressAlive++;

                if (User.NeedsWalking)
                {
                    User.UnSuppress();

                    if (User.Point.Compare(GetRoom().GetRoomModel().Door) && User.UnhandledGoalPoint.Compare(GetRoom().GetRoomModel().Door))
                    {
                        HandleLeaveUser(User.HabboId, true);
                        continue;
                    }

                    using (Pathfinder Pathfinder = new Pathfinder(RoomId, Matrix, HeightMap, GetRoom().GetRoomModel()))
                    {
                        var Route = Pathfinder.GeneratePath(User.Point, User.UnhandledGoalPoint);

                        User.RemoveStatus("mv");
                        User.RemoveStatus("sit");
                        User.RemoveStatus("lay");

                        if (Route.Count > 0)
                        {
                            User.PathPoints = Route;
                        }
                        else
                        {
                            User.PathPoints = new List<iPoint>();
                            User.UpdateStatus(true);
                        }
                    }
                }

                if (User.WalkFreezed && !User.PlayingGame)
                {
                    if (!User.IsWalking)
                    {
                        HandleLeaveUser(User.HabboId, true);
                        continue;
                    }
                }

                if (User.NeedsLastWalk)
                {
                    User.UpdateStatus(true);
                    User.NeedsLastWalk = false;

                    if (User.Point.Compare(GetRoom().GetRoomModel().Door))
                    {
                        HandleLeaveUser(User.HabboId, true);
                    }
                }

                if (User.IsWalking)
                {
                    User.RemoveStatus("sit");
                    User.RemoveStatus("lay");

                    iPoint Next = User.PathPoints[0];

                    StringBuilder MoveBuilder = new StringBuilder();

                    MoveBuilder.Append(Next.X + ",");
                    MoveBuilder.Append(Next.Y + ",");
                    MoveBuilder.Append(Next.Z.ToString().Replace(",", "."));

                    User.AddStatus("mv", MoveBuilder.ToString());

                    User.PathPoints.Remove(Next);

                    int NewRot = Rotation.Calculate(User.Point.X, User.Point.Y, Next.X, Next.Y);

                    User.RotHead = NewRot;
                    User.RotBody = NewRot;

                    User.UpdateStatus(false);

                    User.UpdatePoint(Next);

                    if (User.PathPoints.Count <= 0)
                    {
                        User.UnhandledGoalPoint = new iPoint(-1, -1);
                        User.RemoveStatus("mv");
                        User.NeedsLastWalk = true;
                    }
                }

                if (User.SuppressAlive >= 600 && !User.Suppressed)
                {
                    Response SuppressedResponse = new Response(486);
                    SuppressedResponse.AppendInt32(User.VirtualId);
                    SuppressedResponse.AppendBoolean(true);
                    BroadcastResponse(SuppressedResponse);

                    User.Suppressed = true;
                }

                if (User.SuppressAlive >= 1800 && User.Suppressed)
                {
                    HandleLeaveUser(User.HabboId, true);
                }
            }

            if (GetUsers().Count <= 0)
            {
                SuppressAlive++;
            }
            else
            {
                SuppressAlive = 0;
            }

            if (SuppressAlive >= 60)
            {
                BrickEngine.GetRoomReactor().DisposeRoom(RoomId);
            }
        }
Exemplo n.º 2
0
        private void HandlePets(Object Obj)
        {
            foreach (VirtualRoomUser Pet in GetPets())
            {
                PetInfo Info = BrickEngine.GetPetReactor().GetPetInfo(Pet.HabboId);

                Info.CollectStatus();

                PetInterAction Action = PetInterAction.Interactive;

                int Rand = Random.Next(1, 30);

                if (Rand == 2)
                {
                    Action = PetInterAction.Walking;
                }
                else if (Rand == 25)
                {
                    Action = PetInterAction.Chatting;
                }
                else if (Rand == 4)
                {
                    Action = PetInterAction.Playing;
                }
                else if (Rand == 5)
                {
                    Action = PetInterAction.Action;
                }

                Info.DoActions(Action, Pet);

                if (Pet.NeedsWalking)
                {
                    using (Pathfinder Pathfinder = new Pathfinder(RoomId, Matrix, HeightMap, GetRoom().GetRoomModel()))
                    {
                        var Route = Pathfinder.GeneratePath(Pet.Point, Pet.UnhandledGoalPoint);

                        Pet.UnhandledGoalPoint = new iPoint(-1, -1);

                        Pet.RemoveStatus("mv");
                        Pet.RemoveStatus("sit");
                        Pet.RemoveStatus("lay");

                        if (Route.Count > 0)
                        {
                            Pet.PathPoints = Route;
                        }
                        else
                        {
                            Pet.PathPoints = new List<iPoint>();
                            Pet.UpdateStatus(true);
                        }
                    }
                }

                if (Pet.NeedsLastWalk)
                {
                    Pet.UpdateStatus(true);
                    Pet.NeedsLastWalk = false;

                    if (Pet.Point.Compare(GetRoom().GetRoomModel().Door))
                    {
                        HandleLeaveUser(Pet.HabboId, true);
                    }
                }

                if (Pet.IsWalking)
                {
                    Pet.RemoveStatus("sit");
                    Pet.RemoveStatus("lay");

                    iPoint Next = Pet.PathPoints[0];

                    StringBuilder MoveBuilder = new StringBuilder();

                    MoveBuilder.Append(Next.X + ",");
                    MoveBuilder.Append(Next.Y + ",");
                    MoveBuilder.Append(Next.Z.ToString().Replace(",", "."));

                    Pet.AddStatus("mv", MoveBuilder.ToString());

                    Pet.PathPoints.Remove(Next);

                    int NewRot = Rotation.Calculate(Pet.Point.X, Pet.Point.Y, Next.X, Next.Y);

                    Pet.RotHead = NewRot;
                    Pet.RotBody = NewRot;

                    Pet.UpdateStatus(false);

                    Pet.UpdatePoint(Next);

                    if (Pet.PathPoints.Count <= 0)
                    {
                        Pet.UnhandledGoalPoint = new iPoint(-1, -1);
                        Pet.RemoveStatus("mv");
                        Pet.NeedsLastWalk = true;
                    }
                }
            }

            if (GetPetToys().Count > 0)
            {
                foreach (Item Toy in GetPetToys())
                {
                    if (Toy.ExtraData.Equals("1"))
                    {
                        int i = 0;

                        foreach (VirtualRoomUser Pet in GetPets())
                        {
                            if (Pet.Point.Compare(Toy.Point))
                            {
                                i++;
                            }
                        }

                        if (i == 0)
                        {
                            Toy.ExtraData = "0";
                            BroadcastResponse(Toy.GetTriggerResponse());
                        }
                    }
                }
            }
        }