public void Update() { if (m_started) { TimeSpan elapsed = m_delta.Elapsed; m_delta.Restart(); m_currentObject = null; osu.HitObject.Data m_nextObject = null; int actedId = -1; for (int i = m_songData.HitObjects.Count - 1; i >= 0; i--) { if (PassedTime >= new TimeSpan(0, 0, 0, 0, (int)m_songData.HitObjects[i].HitData.Time)) { if (m_hasBeenActed[i] == false) { m_currentObject = m_actors[i]; actedId = i; if (actedId > m_lastActId && m_lastActId != -1) { m_hasBeenActed[m_lastActId] = true; } m_lastActId = actedId; break; } else { if (m_nextObject == null) { if (i + 1 < m_songData.HitObjects.Count) { m_nextObject = m_songData.HitObjects[i + 1].HitData; } } } } } if (m_currentObject != null) { if (m_currentObject.HasBeenInit == false) { m_currentObject.Init(m_songData, m_controller, PassedTime, elapsed, DoubleTime); } m_hasBeenActed[actedId] = m_currentObject.Act(m_controller, PassedTime, elapsed, DoubleTime); } else { //Interpolate if (m_nextObject != null) { WinAPI.POINT cursor = new WinAPI.POINT(); WinAPI.GetCursorPos(ref cursor); WinAPI.POINT dest = new WinAPI.POINT(); dest.x = m_nextObject.X; dest.y = m_nextObject.Y; osu.OsuOptions.Convert(ref dest, m_controller.WindowHandle.Size().x, m_controller.WindowHandle.Size().y); Vector2 newpos = m_controller.WindowHandle.ConvertToScreen(new Vector2(dest.x, dest.y)); dest.x = newpos.x; dest.y = newpos.y; const double INTER_SPEED = 1.3f; if (cursor.x < dest.x) { cursor.x += (int)(INTER_SPEED * elapsed.TotalMilliseconds); } if (cursor.x > dest.x) { cursor.x -= (int)(INTER_SPEED * elapsed.TotalMilliseconds); } if (cursor.y < dest.y) { cursor.y += (int)(INTER_SPEED * elapsed.TotalMilliseconds); } if (cursor.y > dest.y) { cursor.y -= (int)(INTER_SPEED * elapsed.TotalMilliseconds); } WinAPI.SetCursorPos(cursor.x, cursor.y); } if (actedId >= 0) { m_hasBeenActed[actedId] = true; } } } }
static void Main(string[] args) { #region oldmain Console.Clear(); if (args.Length > 0) { const char GRAB_WINDOW_KEY = 'Q'; const char PLAY_SONG_KEY = 'W'; const char DTIME_KEY = 'E'; const char RESET_KEY = 'R'; const char QUIT_KEY = 'T'; Console.WriteLine("Loading: " + args[0]); Console.WriteLine("Press: " + GRAB_WINDOW_KEY + " to set the osu window"); Console.WriteLine("Press: " + PLAY_SONG_KEY + " to start the song after the first note"); Console.WriteLine("Press: " + DTIME_KEY + " to toggle double time"); Console.WriteLine("Press: " + RESET_KEY + " to reset"); Console.WriteLine("Press: " + QUIT_KEY + " to force close the bot"); bool allow_toggle = false; bool windowSet = false; Controller.Win_Controller controller = new Controller.Win_Controller(null); bool doubleTime = false; RESET_POINT: osu.SongData song = new osu.SongData(); song.Parse(File.OpenRead(args[0])); Player osuPlayer = new Player(controller); osuPlayer.Reset(); osuPlayer.SetSong(song); bool songPlayed = false; while (true) { osuPlayer.DoubleTime = doubleTime; WinAPI.POINT point = new WinAPI.POINT(); WinAPI.GetCursorPos(ref point); if (!windowSet && WinAPI.GetAsyncKeyState(GRAB_WINDOW_KEY) != 0) { windowSet = true; IntPtr handle = WinAPI.WindowFromPoint(point); controller.WindowHandle = new Win32.Window(handle); Console.WriteLine(controller.WindowHandle.Title()); Console.WriteLine("Window set"); } if (WinAPI.GetAsyncKeyState(QUIT_KEY) != 0) { return; } if (WinAPI.GetAsyncKeyState(RESET_KEY) != 0 && osuPlayer.IsPlaying) { Console.WriteLine("Reset"); goto RESET_POINT; } if (WinAPI.GetAsyncKeyState(DTIME_KEY) != 0) { if (allow_toggle) { allow_toggle = false; if (doubleTime) { doubleTime = false; Console.WriteLine("Double time is OFF..."); } else { doubleTime = true; Console.WriteLine("Double time is ON..."); } } } else { allow_toggle = true; } if (windowSet) { if (!songPlayed && WinAPI.GetAsyncKeyState(PLAY_SONG_KEY) != 0) { songPlayed = true; osuPlayer.StartFirstNote(); Console.WriteLine("Song started"); } osuPlayer.Update(); } System.Threading.Thread.Sleep(2); } } else { Console.WriteLine("Please drag an osu file into the EXE to begin..."); } #endregion }