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"); if (!User.forcesit) User.Statusses.Remove("sit"); User.UpdateNeeded = true; } //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y); //CoordItemSearch ItemSearch = new CoordItemSearch(room.GetGameMap().CoordinatedItems); int userCoord = User.GetDoubleCoordinate(); List<RoomItem> ItemsOnSquare = room.GetGameMap().GetCoordinatedItems(ref userCoord); //ItemSearch.GetAllRoomItemForSquare(User.X, User.Y); double newZ = room.GetGameMap().GetNewZForUser(User.X, User.Y, User.Z); if (newZ != User.Z) { if (User.isFlying) newZ += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); if (User.UserIsRidingAHorse()) newZ += 1; User.Z = newZ; 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; } RoomItem[] items = room.GetGameMap().GetCoordinatedHeighestItems(ref userCoord).ToArray(); foreach (RoomItem item in items) item.OnUserWalk(User, cyclegameitems); if (User.pressurePlate != 0) { if (User.PressurePlateReset) { RoomItem plate = room.GetRoomItemHandler().GetItem(User.pressurePlate); if (plate == null) return; User.pressurePlate = 0; plate.ExtraData = "0"; plate.UpdateState(false, true); } User.PressurePlateReset = true; } 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 HandleSetMovement(SquarePoint Point, RoomUser User, ref bool updated, bool setSquareMap) { int nextX = Point.X; int nextY = Point.Y; User.RemoveStatus("mv"); //double nextZ = room.GetGameMap().SqAbsoluteHeight(nextX, nextY); double nextZ = room.GetGameMap().GetNewZForUser(nextX, nextY, User.Z); //if (room.GetGameMap().SquareOccupied(nextX, nextY, nextZ)) // return; if (User.UserIsRidingAHorse()) nextZ += 1; User.Statusses.Remove("lay"); User.Statusses.Remove("sit"); if (!User.isFlying) User.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ)); else User.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ + 4 + (0.5 * Math.Sin(0.7 * User.flyk)))); int newRot = Rotation.Calculate(User.X, User.Y, nextX, nextY, User.moonwalkEnabled); User.RotBody = newRot; User.RotHead = newRot; User.SetStep = true; User.SetX = nextX; User.SetY = nextY; User.SetZ = nextZ; UpdateUserEffect(User, User.SetX, User.SetY); updated = true; User.UpdateNeeded = true; if (setSquareMap) { room.GetGameMap().GameMap[User.X, User.Y] = User.SqState; // REstore the old one User.SqState = room.GetGameMap().GameMap[User.SetX, User.SetY];//Backup the new one if (!room.AllowWalkthrough) room.GetGameMap().GameMap[nextX, nextY] = 0; } }