Exemplo n.º 1
0
        public override void OnWalkOff(RoomUnit user)
        {
            RoomTile nextTile = this.Room.RoomGamemapManager.GetTile(user.NextStepX, user.NextStepY);

            if (!(nextTile.HigestRoomItem is RoomItemIceSkatingPatch))
            {
                if (user.IsRealUser && user is RoomUnitUser user_)
                {
                    this.Room.RoomGameManager.LeaveTag(user_);
                }
            }
        }
Exemplo n.º 2
0
        public bool CanPlaceItemAt(RoomItem item, int x, int y)
        {
            if (!this.Room.RoomGamemapManager.CoordsInsideRoom(x, y)) //its inside room
            {
                return(false);
            }

            RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, y);

            if (tile.HigestRoomItem == null || tile.HigestRoomItem.ID != item.ID) //its not same item
            {
                if (!tile.IsStackable)                                            //cant stack
                {
                    return(false);
                }
            }

            if (tile.IsHole) //its not on tile
            {
                return(false);
            }

            if (tile.IsDoor) //we dont allow put stuff on door
            {
                return(false);
            }

            if (tile.IsInUse) //user in tile
            {
                if (this.Room.RoomData.ExtraData.RoomSettingsLogic.Contains("building-users-block-furni-placement"))
                {
                    return(false);
                }
                else
                {
                    if (!(item is RoomItemBall) && !(item is RoomItemBattleBanzaiPuck))
                    {
                        if (!item.GetBaseItem().IsSeat&& !item.GetBaseItem().Walkable)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }


            return(true);
        }
Exemplo n.º 3
0
        public RoomUnitUser GetTaggedUser(int x, int y)
        {
            RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, y);

            if (tile != null)
            {
                return((RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser && ((RoomUnitUser)u).IceSkateStatus == IceSkateStatus.Playing));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public override void OnUse(GameClient session, RoomItem item, int request, bool userHasRights)
        {
            ThreeDCoord userLocation = new ThreeDCoord(session.GetHabbo().GetRoomSession().GetRoomUser().X, session.GetHabbo().GetRoomSession().GetRoomUser().Y);
            ThreeDCoord test1        = new ThreeDCoord(this.X + 1, this.Y);
            ThreeDCoord test2        = new ThreeDCoord(this.X - 1, this.Y);
            ThreeDCoord test3        = new ThreeDCoord(this.X, this.Y + 1);
            ThreeDCoord test4        = new ThreeDCoord(this.X, this.Y - 1);

            int x = this.X;
            int y = this.Y;

            if (ThreeDCoord.smethod_0(test1, userLocation))
            {
                x--;
            }
            else if (ThreeDCoord.smethod_0(test2, userLocation))
            {
                x++;
            }
            else if (ThreeDCoord.smethod_0(test3, userLocation))
            {
                y--;
            }
            else if (ThreeDCoord.smethod_0(test4, userLocation))
            {
                y++;
            }
            else
            {
                if ((session.GetHabbo().GetRoomSession().GetRoomUser().RestrictMovementType & RestrictMovementType.Client) == 0)
                {
                    session.GetHabbo().GetRoomSession().GetRoomUser().MoveTo(this.X, this.Y);
                }

                return;
            }

            RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, y);

            if (tile != null && (tile.HigestRoomItem == null || tile.HigestRoomItem.GetBaseItem().Walkable))
            {
                int    oldX = this.X;
                int    oldY = this.Y;
                double oldZ = this.Z;

                if (this.Room.RoomItemManager.MoveFloorItemOnRoom(session, item, x, y, this.Rot))
                {
                    this.Room.RoomItemManager.MoveAnimation[this.ID] = new RoomItemRollerMovement(this.ID, this.X, this.Y, this.Z, 0, oldX, oldY, oldZ);
                }
            }
        }
Exemplo n.º 5
0
 public void UserWalkOn(RoomUnit user)
 {
     if (user.IsRealUser && user is RoomUnitUser user_)
     {
         RoomTile tile = user.CurrentTile;
         if (tile?.HigestRoomItem != null)
         {
             foreach (RoomItemWiredTrigger item in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemWiredOnFurni)))
             {
                 this.WiredTrigger(item, user_, new HashSet <uint>(), tile.HigestRoomItem.ID);
             }
         }
     }
 }
Exemplo n.º 6
0
        //return: was not blocked
        public bool DoFootballHitTest(RoomItemBall football, int x, int y, int direction, int blockedDirection)
        {
            RoomTile tile       = this.Room.RoomGamemapManager.GetTile(x, y);
            RoomItem higestGoal = tile?.ItemsOnTile.Get(typeof(RoomItemFootballGoal)).OrderBy(i => i.Z).FirstOrDefault();

            bool goalBlocks = false;

            if (higestGoal != null)
            {
                if (higestGoal.Rot == 0 && direction != 4)
                {
                    goalBlocks = true;
                }
                else if (higestGoal.Rot == 2 && direction != 6)
                {
                    goalBlocks = true;
                }
                else if (higestGoal.Rot == 4 && direction != 0)
                {
                    goalBlocks = true;
                }
                else if (higestGoal.Rot == 6 && direction != 2)
                {
                    goalBlocks = true;
                }
            }

            if (!goalBlocks && this.Room.RoomItemManager.MoveFloorItemOnRoom(null, football, x, y, football.Rot, -1.0, false))
            {
                football.FootballDirection = direction;
                return(true);
            }
            else
            {
                if (tile != null && tile.IsInUse)
                {
                    football.ExtraData = "10";
                    football.UpdateState(false, true);
                    return(true);
                }
                else
                {
                    football.FootballDirection = blockedDirection;
                    football.FootballWaitTime  = 3;
                    return(false);
                }
            }
        }
Exemplo n.º 7
0
        public void UpdateTiles()
        {
            //reset some data
            foreach (RoomTile tile in this.Tiles)
            {
                if (tile != null)
                {
                    tile.ResetGamemap();
                }
            }

            foreach (RoomItem item in this.Room.RoomItemManager.FloorItems.Values)
            {
                HashSet <AffectedTile> tiles = new HashSet <AffectedTile>(item.AffectedTiles)
                {
                    new AffectedTile(item.X, item.Y, item.Rot)
                };
                foreach (AffectedTile tile in tiles)
                {
                    RoomTile roomtile = this.GetTile(tile.X, tile.Y);
                    if (roomtile != null)
                    {
                        roomtile.AddItemToTile(item);
                    }
                }
            }

            foreach (RoomUnit user in this.Room.RoomUserManager.GetRoomUsers())
            {
                if (user.HasNextStep)
                {
                    this.GetTile(user.NextStepX, user.NextStepY).UsersOnTile.Add(user.VirtualID, user);
                }
                else
                {
                    this.GetTile(user.X, user.Y).UsersOnTile.Add(user.VirtualID, user);
                }
            }
        }
Exemplo n.º 8
0
        public override void OnUse(GameClients.GameClient session, RoomItem item, int request, bool userHasRights)
        {
            RoomTile tile = this.Room.RoomGamemapManager.GetTile(item.X, item.Y);

            if (tile != null && !tile.IsInUse)
            {
                foreach (AffectedTile tile_ in this.AffectedTiles)
                {
                    if (tile.IsInUse)
                    {
                        return;
                    }
                }

                base.OnUse(session, item, request, userHasRights);

                this.Room.RoomGamemapManager.GetTile(this.X, this.Y).UpdateTile();
                foreach (AffectedTile tile_ in this.AffectedTiles)
                {
                    this.Room.RoomGamemapManager.GetTile(tile_.X, tile_.Y).UpdateTile();
                }
            }
        }
Exemplo n.º 9
0
 //return: was not blocked
 public bool DoPuckHitTest(RoomItemBattleBanzaiPuck puck, int x, int y, int direction, int blockedDirection)
 {
     if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, puck, x, y, puck.Rot, -1.0, false))
     {
         puck.PuckDirection = direction;
         return(true);
     }
     else
     {
         RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, y);
         if (tile != null && tile.IsInUse)
         {
             puck.Power = 0;
             return(true);
         }
         else
         {
             puck.PuckDirection = blockedDirection;
             puck.PuckWaitTime  = 3;
             return(false);
         }
     }
 }
Exemplo n.º 10
0
        public void PickupFloorItemFromRoom(GameClient session, RoomItem item)
        {
            this.RemoveItem(session, item);

            HashSet <AffectedTile> oldTiles = new HashSet <AffectedTile>(item.AffectedTiles)
            {
                new AffectedTile(item.X, item.Y, item.Rot)
            };

            foreach (AffectedTile tile in oldTiles)
            {
                RoomTile tile_ = this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y);
                if (tile_ != null)
                {
                    tile_.RemoveItemFromTile(item);
                }
            }

            foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers())
            {
                foreach (AffectedTile tile in oldTiles)
                {
                    if (user.X == tile.X && user.Y == tile.Y)
                    {
                        user.UpdateState();
                        break;
                    }
                }
            }

            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
            {
                dbClient.AddParamWithValue("userid", session.GetHabbo().ID);
                dbClient.AddParamWithValue("itemid", item.ID);
                dbClient.ExecuteQuery("UPDATE items SET room_id = 0, user_id = @userid WHERE id = @itemid");
            }
        }
Exemplo n.º 11
0
        public override void AboutToWalkOn(RoomUnit user)
        {
            if (user.IsRealUser && user is RoomUnitUser user_ && user_.ActiveEffect == 71) //are we even skateboarding?!?
            {
                RoomTile lastTile = this.Room.RoomGamemapManager.GetTile(user.X, user.Y);
                RoomTile nextTile = this.Room.RoomGamemapManager.GetTile(user.NextStepX, user.NextStepY);

                if (nextTile.HigestRoomItem is RoomItemSkateboardRail)                  //next tile aka this is skateboard rail.. yeah
                {
                    if (lastTile.HigestRoomItem is RoomItemSkateboardRail)              //if the LAST tile was skateboard rail too
                    {
                        if (nextTile.HigestRoomItem.Rot != lastTile.HigestRoomItem.Rot) //are we performing jump?
                        {
                            if (nextTile.HigestRoomItem.Rot == 0)
                            {
                                if (user.HeadRotation != 0 && user.HeadRotation != 4)
                                {
                                    user_.Session.GetHabbo().GetUserStats().SkateboardJumper++;
                                    user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardJumper");
                                }
                                else
                                {
                                    user_.Session.GetHabbo().GetUserStats().SkateboardSlider++;
                                    user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardSlider");
                                }
                            }
                            else if (nextTile.HigestRoomItem.Rot == 2)
                            {
                                if (user.HeadRotation != 2 && user.HeadRotation != 6)
                                {
                                    user_.Session.GetHabbo().GetUserStats().SkateboardJumper++;
                                    user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardJumper");
                                }
                                else
                                {
                                    user_.Session.GetHabbo().GetUserStats().SkateboardSlider++;
                                    user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardSlider");
                                }
                            }
                        }
                        else //we are performing slide, its same item rotation as last tile!
                        {
                            if (user.HeadRotation != 2 && user.HeadRotation != 6)
                            {
                                user_.Session.GetHabbo().GetUserStats().SkateboardSlider++;
                                user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardSlider");
                            }
                        }
                    }
                    else
                    {
                        if (nextTile.HigestRoomItem.Rot == 0)
                        {
                            if (user.HeadRotation != 0 && user.HeadRotation != 4)
                            {
                                user_.Session.GetHabbo().GetUserStats().SkateboardJumper++;
                                user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardJumper");
                            }
                            else
                            {
                                user_.Session.GetHabbo().GetUserStats().SkateboardSlider++;
                                user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardSlider");
                            }
                        }
                        else if (nextTile.HigestRoomItem.Rot == 2)
                        {
                            if (user.HeadRotation != 2 && user.HeadRotation != 6)
                            {
                                user_.Session.GetHabbo().GetUserStats().SkateboardJumper++;
                                user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardJumper");
                            }
                            else
                            {
                                user_.Session.GetHabbo().GetUserStats().SkateboardSlider++;
                                user_.Session.GetHabbo().GetUserAchievements().CheckAchievement("SkateboardSlider");
                            }
                        }
                    }

                    //move user to next tile
                    if (nextTile.HigestRoomItem.Rot == 0)
                    {
                        if (user.HeadRotation == 0)
                        {
                            if (user.TargetX == nextTile.HigestRoomItem.X && user.TargetY == nextTile.HigestRoomItem.Y)
                            {
                                user.MoveTo(nextTile.HigestRoomItem.X, nextTile.HigestRoomItem.Y - 1);
                            }

                            user_.SkateboardRotation = 6;
                        }
                        else if (user.HeadRotation == 4)
                        {
                            if (user.TargetX == nextTile.HigestRoomItem.X && user.TargetY == nextTile.HigestRoomItem.Y)
                            {
                                user.MoveTo(nextTile.HigestRoomItem.X, nextTile.HigestRoomItem.Y + 1);
                            }

                            user_.SkateboardRotation = 2;
                        }
                        else
                        {
                            user_.SkateboardRotation = null;
                        }
                    }
                    else if (nextTile.HigestRoomItem.Rot == 2)
                    {
                        if (user.HeadRotation == 2)
                        {
                            if (user.TargetX == nextTile.HigestRoomItem.X && user.TargetY == nextTile.HigestRoomItem.Y)
                            {
                                user.MoveTo(nextTile.HigestRoomItem.X + 1, nextTile.HigestRoomItem.Y);
                            }

                            user_.SkateboardRotation = 0;
                        }
                        else if (user.HeadRotation == 6)
                        {
                            if (user.TargetX == nextTile.HigestRoomItem.X && user.TargetY == nextTile.HigestRoomItem.Y)
                            {
                                user.MoveTo(nextTile.HigestRoomItem.X - 1, nextTile.HigestRoomItem.Y);
                            }

                            user_.SkateboardRotation = 4;
                        }
                        else
                        {
                            user_.SkateboardRotation = null;
                        }
                    }
                    else
                    {
                        user_.SkateboardRotation = null;
                    }

                    user.NeedUpdate = true;
                }
                else
                {
                    user_.SkateboardRotation = null;
                }
            }
        }
Exemplo n.º 12
0
        public void Update()
        {
            int state = 0;

            RoomTile tile2 = this.Room.RoomGamemapManager.GetTile(this.X + 1, this.Y + 2);

            if (tile2 == null || tile2.IsHole)
            {
                state = state | 2;
            }

            RoomTile tile3 = this.Room.RoomGamemapManager.GetTile(this.X, this.Y + 2);

            if (tile3 == null || tile3.IsHole)
            {
                state = state | 4;
            }

            RoomTile tile5 = this.Room.RoomGamemapManager.GetTile(this.X + 2, this.Y + 1);

            if (tile5 == null || tile5.IsHole)
            {
                state = state | 16;
            }

            RoomTile tile6 = this.Room.RoomGamemapManager.GetTile(this.X - 1, this.Y + 1);

            if (tile6 == null || tile6.IsHole)
            {
                state = state | 32;
            }

            RoomTile tile7 = this.Room.RoomGamemapManager.GetTile(this.X + 2, this.Y);

            if (tile7 == null || tile7.IsHole)
            {
                state = state | 64;
            }

            RoomTile tile8 = this.Room.RoomGamemapManager.GetTile(this.X - 1, this.Y);

            if (tile8 == null || tile8.IsHole)
            {
                state = state | 128;
            }

            RoomTile tile10 = this.Room.RoomGamemapManager.GetTile(this.X + 1, this.Y - 1);

            if (tile10 == null || tile10.IsHole)
            {
                state = state | 512;
            }

            RoomTile tile11 = this.Room.RoomGamemapManager.GetTile(this.X, this.Y - 1);

            if (tile11 == null || tile11.IsHole)
            {
                state = state | 1024;
            }

            //CORNERS
            RoomTile tile = this.Room.RoomGamemapManager.GetTile(this.X + 2, this.Y + 2);

            if (tile == null || tile.IsHole)
            {
                if (tile5 != null && !tile5.IsHole && tile2 != null && !tile2.IsHole)
                {
                    state = state | 1;
                }
            }

            RoomTile tile4 = this.Room.RoomGamemapManager.GetTile(this.X - 1, this.Y + 2);

            if (tile4 == null || tile4.IsHole)
            {
                if (tile10 != null && !tile10.IsHole && tile7 != null && !tile7.IsHole)
                {
                    state = state | 8;
                }
            }

            RoomTile tile9 = this.Room.RoomGamemapManager.GetTile(this.X + 2, this.Y - 1);

            if (tile9 == null || tile9.IsHole)
            {
                if (tile6 != null && !tile6.IsHole && tile3 != null && !tile3.IsHole)
                {
                    state = state | 256;
                }
            }

            RoomTile tile12 = this.Room.RoomGamemapManager.GetTile(this.X - 1, this.Y - 1);

            if (tile12 == null || tile12.IsHole)
            {
                if (tile8 != null && !tile8.IsHole && tile11 != null && !tile11.IsHole)
                {
                    state = state | 2048;
                }
            }

            this.ExtraData = state.ToString();
            this.UpdateState(true, true);
        }
Exemplo n.º 13
0
        public void StartGame()
        {
            if (!this.GameStarted)
            {
                this.GameStarted = true;

                foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers())
                {
                    if (user.GameType == GameType.Freeze)
                    {
                        FreezePlayer player = new FreezePlayer(this.Room, user, user.GameTeam);
                        this.Players.Add(user.Session.GetHabbo().ID, player);

                        player.Reset();
                        player.GiveHelmet();
                    }
                }

                if (this.FreezeExitTile != null)
                {
                    this.FreezeExitTile.ExtraData = "1";
                    this.FreezeExitTile.UpdateState(false, true);
                }

                List <Point> checkedTiles = new List <Point>();
                foreach (RoomItem item in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemFreezeTile)))
                {
                    item.ExtraData = "0";
                    item.UpdateState(false, true);

                    Point point = new Point(item.X, item.Y);
                    if (!checkedTiles.Contains(point))
                    {
                        RoomTile tile = this.Room.RoomGamemapManager.GetTile(point.X, point.Y);
                        if (tile != null)
                        {
                            foreach (RoomUnitUser user in tile.UsersOnTile.Values)
                            {
                                if (!this.Players.ContainsKey(user.Session.GetHabbo().ID))
                                {
                                    if (this.FreezeExitTile != null)
                                    {
                                        user.StopMoving();
                                        user.SetLocation(this.FreezeExitTile.X, this.FreezeExitTile.Y, this.FreezeExitTile.Z); //set new location
                                        user.UpdateState();
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (RoomItem item in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemFreezeIceBlock)))
                {
                    item.ExtraData = "0";
                    item.UpdateState(true, true);
                }

                this.UpdateScoreboards();

                foreach (RoomItem gate in this.FreezeGates.Values)
                {
                    this.Room.RoomGamemapManager.GetTile(gate.X, gate.Y).UpdateTile();
                }
            }
        }
Exemplo n.º 14
0
        public void OnCycle()
        {
            this.RollerTimer++;
            if (this.RollerTimer >= this.Room.RollerSpeed)
            {
                this.RollerTimer = 0;

                List <int>  rollerUsers = new List <int>();
                List <uint> rollerItems = new List <uint>();

                foreach (RoomItem item in this.FloorItems.Get(typeof(RoomItemRoller)).OrderBy(i => i.Z))
                {
                    this.Room.ThrowIfRoomCycleCancalled("Cycle rollers", item); //Have room cycle cancalled?

                    ThreeDCoord way = item.TDC;
                    if (way.x >= this.Room.RoomGamemapManager.Model.MaxX || way.y >= this.Room.RoomGamemapManager.Model.MaxY || way.x < 0 || way.y < 0) //dont roll it out of room
                    {
                        continue;
                    }
                    else
                    {
                        RoomTile to = this.Room.RoomGamemapManager.GetTile(way.x, way.y);
                        if (!to.IsHole && !to.IsDoor && !to.IsInUse)
                        {
                            RoomTile        from      = this.Room.RoomGamemapManager.GetTile(item.X, item.Y);
                            List <RoomItem> itemsFrom = from.ItemsOnTile.Values.Where(i => i.Z >= item.ActiveHeight && !rollerItems.Contains(i.ID) && this.FitsInsideRoom(i, way.x, way.y, i.Rot)).ToList();
                            List <RoomItem> itemsTo   = to.ItemsOnTile.Values.OrderByDescending(i => i.Z).ToList();
                            itemsTo.RemoveAll(t => itemsFrom.Contains(t));

                            RoomItem higestItem = null;
                            foreach (RoomItem item_ in itemsTo)
                            {
                                if (higestItem == null)
                                {
                                    higestItem = item_;
                                }
                                else
                                {
                                    if (higestItem.Z == item_.Z)
                                    {
                                        if (item_.ActiveHeight > higestItem.ActiveHeight)
                                        {
                                            higestItem = item_;
                                        }
                                    }
                                    else //not even on same height
                                    {
                                        break;
                                    }
                                }
                            }

                            if (!(higestItem is RoomItemRoller)) //the top item isint roller
                            {
                                if (itemsTo.Any(i => i is RoomItemRoller))
                                {
                                    continue;
                                }
                            }

                            RoomUnit user = to.CanUserMoveToTile ? this.Room.RoomGamemapManager.GetTile(item.X, item.Y).UsersOnTile.Values.FirstOrDefault(u => u.Moving == false && !rollerUsers.Contains(u.VirtualID)) : null;
                            if (itemsFrom.Count > 0 || user != null) //we have some work to do
                            {
                                double baseZ = 0;
                                if (higestItem is RoomItemRoller)
                                {
                                    baseZ = to.GetZ(true);
                                }
                                else
                                {
                                    baseZ = to.ModelZ;
                                }

                                foreach (RoomItem item_ in itemsFrom)
                                {
                                    rollerItems.Add(item_.ID);

                                    foreach (AffectedTile tile in new HashSet <AffectedTile>(item_.AffectedTiles)
                                    {
                                        new AffectedTile(item_.X, item_.Y, item_.Rot)
                                    })
                                    {
                                        this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y).RemoveItemFromTile(item_);
                                    }

                                    foreach (AffectedTile tile in new HashSet <AffectedTile>(ItemUtilies.AffectedTiles(item_.GetBaseItem().Lenght, item_.GetBaseItem().Width, to.X, to.Y, item_.Rot).Values)
                                    {
                                        new AffectedTile(to.X, to.Y, item_.Rot)
                                    })
                                    {
                                        this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y).AddItemToTile(item_);
                                    }

                                    double oldZ = item_.Z;

                                    item_.SetLocation(to.X, to.Y, baseZ + item_.Z - (item.Z + item.GetBaseItem().Height));

                                    this.Room.RoomItemManager.MoveAnimation[item.ID] = new RoomItemRollerMovement(item_.ID, item.X, item.Y, oldZ, item.ID, to.X, to.Y, item_.Z);
                                }

                                if (user != null)
                                {
                                    this.Room.UserWalkOff(user);
                                    if (user.X == item.X && user.Y == item.Y) //did walkoff prevent this?
                                    {
                                        rollerUsers.Add(user.VirtualID);

                                        double newZ = to.GetZ(true);

                                        this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RollerMovement, new ValueHolder("User", new RoomUserRollerMovement(user.VirtualID, item.X, item.Y, user.Z, item.ID, to.X, to.Y, newZ))));

                                        user.SetLocation(to.X, to.Y, newZ, false);
                                        user.UpdateUserStateTimer = 2;

                                        //update user state somehow respecting the movement packet
                                        this.Room.UserWalkOn(user);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (this.FloorItems.Count > 0)
            {
                foreach (RoomItem item in this.FloorItems.Values)
                {
                    this.Room.ThrowIfRoomCycleCancalled("Cycle floor items", item); //Have room cycle cancalled?

                    item.OnCycle();
                }
            }

            if (this.WallItems.Count > 0)
            {
                foreach (RoomItem item in this.WallItems.Values)
                {
                    this.Room.ThrowIfRoomCycleCancalled("Cycle wall items", item); //Have room cycle cancalled?

                    item.OnCycle();
                }
            }

            //AUTO SAVE
            if (this.Room.LastAutoSave.Elapsed.TotalMinutes >= 5) //Every 5min :)
            {
                this.Room.LastAutoSave.Restart();

                this.SaveAll();
            }
        }
Exemplo n.º 15
0
        public bool MoveFloorItemOnRoom(GameClient session, RoomItem item, int x, int y, int rotation, double height = -1.0, bool sendPacket = true, params RoomItem[] ignore)
        {
            int forceRotation = session != null?session.GetHabbo().GetRoomSession().GetRoomUser().ForceRotate : -1;

            if (forceRotation != -1)
            {
                rotation = forceRotation;
            }

            HashSet <AffectedTile> oldTiles = new HashSet <AffectedTile>(item.AffectedTiles)
            {
                new AffectedTile(item.X, item.Y, item.Rot)
            };
            HashSet <AffectedTile> newTiles = new HashSet <AffectedTile>(ItemUtilies.AffectedTiles(item.BaseItem.Lenght, item.BaseItem.Width, x, y, rotation).Values)
            {
                new AffectedTile(x, y, rotation)
            };

            if (height == -1.0)
            {
                foreach (AffectedTile tile in newTiles)
                {
                    if (!this.CanPlaceItemAt(item, tile.X, tile.Y))
                    {
                        return(false);
                    }

                    RoomTile tile_ = this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y);
                    if (ignore.Length <= 0)
                    {
                        if (tile_.HigestRoomItem?.ID != item.ID)
                        {
                            height = tile_.GetZ(true);
                        }
                        else
                        {
                            height = tile_.GetZ(false);
                        }
                    }
                    else
                    {
                        RoomItem higestItem = tile_.GetHigestItem(ignore);
                        if (higestItem != null)
                        {
                            if (higestItem.ID != item.ID)
                            {
                                height = higestItem.ActiveHeight;
                            }
                            else
                            {
                                height = higestItem.Z;
                            }
                        }
                        else
                        {
                            height = tile_.ModelZ;
                        }
                    }
                }
            }

            this.AddedAndMovedRoomItems.AddOrUpdate(item.ID, item, (key, oldValue) => item);
            this.RoomItemStateUpdated.TryRemove(item.ID, out RoomItem item_);

            double forceHeight = session != null?session.GetHabbo().GetRoomSession().GetRoomUser().ForceHeight : -1.0;

            int forceState = session != null?session.GetHabbo().GetRoomSession().GetRoomUser().ForceState : -1;

            if (forceState != -1)
            {
                if (item.GetBaseItem().InteractionType == "default")
                {
                    int mode = forceState;

                    if (mode > item.GetBaseItem().InteractionModeCounts - 1)
                    {
                        mode = 0;
                    }

                    item.ExtraData = mode.ToString();
                }
            }

            item.Rot = rotation;
            if (forceHeight != -1.0)
            {
                item.SetLocation(x, y, forceHeight);
            }
            else
            {
                item.SetLocation(x, y, height);
            }

            foreach (AffectedTile tile in oldTiles)
            {
                this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y).RemoveItemFromTile(item);
            }

            foreach (AffectedTile tile in newTiles)
            {
                this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y).AddItemToTile(item);
            }

            if (sendPacket)
            {
                item.TryChangeUpdateState(RoomItem.UpdateStatus.MOVE);
                this.RequireUpdateClientSide.TryAdd(item.ID, item);
            }

            foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers())
            {
                foreach (AffectedTile tile in oldTiles.Concat(newTiles))
                {
                    if (user.X == tile.X && user.Y == tile.Y)
                    {
                        user.UpdateState();
                        break;
                    }
                }
            }

            item.OnMove(session);
            return(true);
        }
Exemplo n.º 16
0
        public bool AddFloorItemToRoom(GameClient session, RoomItem item, int x, int y, int rotation)
        {
            int forceRotation = session != null?session.GetHabbo().GetRoomSession().GetRoomUser().ForceRotate : -1;

            if (forceRotation != -1)
            {
                rotation = forceRotation;
            }

            HashSet <AffectedTile> tiles = new HashSet <AffectedTile>();

            tiles.UnionWith(ItemUtilies.AffectedTiles(item.BaseItem.Lenght, item.BaseItem.Width, x, y, rotation).Values);
            tiles.Add(new AffectedTile(x, y, rotation));

            double height = 0;

            foreach (AffectedTile tile in tiles)
            {
                if (!this.CanPlaceItemAt(item, tile.X, tile.Y))
                {
                    return(false);
                }

                RoomTile tile_ = this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y);
                if (tile_.GetZ(true) > height)
                {
                    height = tile_.GetZ(true);
                }
            }

            double forceHeight = session.GetHabbo().GetRoomSession().GetRoomUser().ForceHeight;
            int    forceState  = session.GetHabbo().GetRoomSession().GetRoomUser().ForceState;

            if (forceState != -1)
            {
                if (item.GetBaseItem().InteractionType == "default")
                {
                    int mode = forceState;

                    if (mode > item.GetBaseItem().InteractionModeCounts - 1)
                    {
                        mode = 0;
                    }

                    item.ExtraData = mode.ToString();
                }
            }

            item.Rot = rotation;
            if (forceHeight != -1.0)
            {
                item.SetLocation(x, y, forceHeight);
            }
            else
            {
                item.SetLocation(x, y, height);
            }

            this.AddItem(session, item, true);
            foreach (AffectedTile tile in tiles)
            {
                this.Room.RoomGamemapManager.GetTile(tile.X, tile.Y).AddItemToTile(item);
            }

            this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.AddFloorItemToRoom, new ValueHolder("Item", item)));

            foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers())
            {
                foreach (AffectedTile tile in tiles)
                {
                    if (user.X == tile.X && user.Y == tile.Y)
                    {
                        user.UpdateState();
                        break;
                    }
                }
            }

            return(true);
        }
Exemplo n.º 17
0
        public override void DoWiredAction(RoomUnitUser user, HashSet <uint> used)
        {
            foreach (RoomItem item_ in this.SelectedItems)
            {
                if (item_ != null)
                {
                    bool foundUser = false;
                    for (int x = item_.X - 5; x < item_.X + 5; x++)
                    {
                        RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, item_.Y);
                        if (tile != null)
                        {
                            RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                            if (user_ != null)
                            {
                                int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                ThreeDCoord moveTo    = item_.TDCR(direction);

                                if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                {
                                    this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                }
                                else
                                {
                                    int    oldX = item_.X;
                                    int    oldY = item_.Y;
                                    double oldZ = item_.Z;
                                    if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                    {
                                        this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                    }
                                }

                                foundUser = true;
                                break;
                            }
                        }
                    }

                    if (!foundUser)
                    {
                        for (int y = item_.Y - 5; y < item_.Y + 5; y++)
                        {
                            RoomTile tile = this.Room.RoomGamemapManager.GetTile(item_.X, y);
                            if (tile != null)
                            {
                                RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                                if (user_ != null)
                                {
                                    int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                    ThreeDCoord moveTo    = item_.TDCR(direction);

                                    if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                    {
                                        this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                    }
                                    else
                                    {
                                        int    oldX = item_.X;
                                        int    oldY = item_.Y;
                                        double oldZ = item_.Z;
                                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                        {
                                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                        }
                                    }

                                    foundUser = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!foundUser) //user STILL not found, lets do random movement
                    {
                        Random random = RandomUtilies.GetRandom();
                        int    x      = item_.X;
                        int    y      = item_.Y;

                        int movement = random.Next(0, 4);
                        if (movement == 0) //up
                        {
                            y--;
                        }
                        else if (movement == 1) //down
                        {
                            y++;
                        }
                        else if (movement == 2) //left
                        {
                            x--;
                        }
                        else if (movement == 3) //right
                        {
                            x++;
                        }

                        int    oldX = item_.X;
                        int    oldY = item_.Y;
                        double oldZ = item_.Z;
                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, x, y, this.Rot))
                        {
                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                        }
                    }
                }
            }
        }