public List <FNFSong.FNFNote> GetHitNotes(FNFSong.FNFSection sect) { List <FNFSong.FNFNote> notes = new List <FNFSong.FNFNote>(); foreach (FNFSong.FNFNote n in sect.Notes) { if (sect.MustHitSection && n.Type < (FNFSong.NoteType) 4) { notes.Add(n); } else if (n.Type >= (FNFSong.NoteType) 4 && !sect.MustHitSection) { notes.Add(n); } } return(notes); }
private void PlayThread() { ended = false; Form1.WriteToConsole("Play Thread created..."); nPlay.Clear(); int currentSect = 0; int notesPPlayed = 0; int lastRendered = 0; try { while (true) { if (!watch.IsRunning && Playing) { Form1.watchTime.Text = "Time: 0"; watch.Start(); } else if (!Playing && watch.IsRunning) { Form1.console.Text = ""; watch.Reset(); } if (!Playing) { Thread.Sleep(100); continue; } int i = 0; FNFSong.FNFSection sect = mBot.song.Sections[currentSect]; if (notesPPlayed >= sect.Notes.Count) { currentSect++; notesPPlayed = 0; sect = mBot.song.Sections[currentSect]; Form1.WriteToConsole("Next section!"); } List <FNFSong.FNFNote> notesToPlay = mBot.GetHitNotes(sect); if (notesToPlay.Count == 0) { currentSect++; Form1.WriteToConsole("Skiping to section " + currentSect); } else if (lastRendered != currentSect) { lastRendered = currentSect; if (Form1.Rendering) { Form1.watchTime.Text = "Time: " + watch.Elapsed.TotalSeconds.ToString(); Thread list = new Thread(() => rBot.ListNotes(mBot.GetHitNotes(sect))); Form1.currentThreads.Add(list); list.Start(); } } foreach (FNFSong.FNFNote n in notesToPlay) { // ke default hit windows or something like em if ((float)watch.Elapsed.TotalMilliseconds + kBot.offset >= (double)(n.Time - 22) && !nPlay.Contains(n)) { HandleNote(n); nPlay.Add(n); notesPPlayed++; } i++; } // check if we should let go of holds for (int ii = 0; ii < 4; ii++) { if (watch.ElapsedMilliseconds > holdTimes[ii] && holdTimes[ii] != 0) { holdTimes[ii] = 0; switch (ii) { case 0: simulator.Keyboard.KeyUp(VirtualKeyCode.LEFT); break; case 1: simulator.Keyboard.KeyUp(VirtualKeyCode.DOWN); break; case 2: simulator.Keyboard.KeyUp(VirtualKeyCode.UP); break; case 3: simulator.Keyboard.KeyUp(VirtualKeyCode.RIGHT); break; } } } if (!Playing) { break; } // Form1.WriteToConsole("Section See: " + sectionSee); notesPlayed = 0; } Form1.console.Text = ""; Playing = false; Form1.WriteToConsole("Completed!"); ended = true; } catch (Exception e) { Form1.WriteToConsole("Exception on Play Thread\n" + e); } }