88#include " gameplay/enctime.h"
99
1010#include < bit>
11+ #include < filesystem>
1112
12- bool EarlyStrike (double noteStartTime, double inputTime, double inputOffset) {
13- if (noteStartTime - goodFrontend > inputTime - inputOffset) {
14- return true ;
15- }
16- return false ;
17- }
18- bool InHitwindow (double noteStartTime, double inputTime, double inputOffset) {
19- if ((noteStartTime - goodFrontend < inputTime - inputOffset)
20- && (noteStartTime + goodBackend > inputTime - inputOffset)) {
21- return true ;
22- }
23- return false ;
24- }
2513bool MaskMatch (uint8_t noteMask, uint8_t playerMask) {
2614 // chord check
2715 if (std::has_single_bit (noteMask)) {
@@ -56,16 +44,22 @@ bool Encore::RhythmEngine::GuitarEngine::ActivateOverdrive(
5644 if (stats->OverdriveFill >= 0.25 && channel == InputChannel::OVERDRIVE
5745 && action == Action::PRESS) {
5846 stats->OverdriveActive = true ;
59- stats->OverdriveActivationTime = TheSongTime.GetSongTime (); // todo: set to
47+ stats->OverdriveActivationTime = TheSongTime.GetElapsedTime (); // todo: set to
6048 // current input time
6149 return true ;
6250 }
6351 return false ;
6452}
53+ void Encore::RhythmEngine::GuitarEngine::UpdateOnFrame (double CurrentTime) {
54+ CheckMissedNotes (0 , TheSongTime.GetElapsedTime ());
55+ stats->OverdriveFill += chart->overdrive .CheckOverdrive (CurrentTime);
56+ if (stats->OverdriveFill > 1.0 ) stats->OverdriveFill = 1.0 ;
57+ // there is ONLY lane 0 for guitar
58+ }
6559void Encore::RhythmEngine::GuitarEngine::SetStatsInputState (
6660 InputChannel channel, Action action
6761) {
68- stats->InputTime = TheSongTime.GetSongTime (); // todo: REPLACE WITH ACTUAL SONG TIME
62+ stats->InputTime = TheSongTime.GetElapsedTime (); // todo: REPLACE WITH ACTUAL SONG TIME
6963 // (IN SECONDS)
7064 if (action == Action::PRESS) {
7165 switch (channel) {
@@ -113,12 +107,15 @@ void Encore::RhythmEngine::GuitarEngine::SetStatsInputState(
113107int Encore::RhythmEngine::GuitarEngine::RunHitStateCheck (
114108 InputChannel channel, Action action
115109) {
116- if (chart->empty ())
110+ if (chart->at ( 0 ). empty ())
117111 return CheckNextInput;
118- ;
112+
119113 auto curNoteItr = chart->at (0 ).begin ();
120114 while (curNoteItr->StartSeconds + goodBackend
121- < TheSongTime.GetSongTime () - stats->InputOffset ) {
115+ < TheSongTime.GetElapsedTime () - stats->InputOffset ) {
116+ if (curNoteItr + 1 == chart->at (0 ).end ()) {
117+ return CheckNextInput;
118+ }
122119 ++curNoteItr;
123120 }
124121 EncNote &CurrentNote = *curNoteItr;
@@ -130,6 +127,7 @@ int Encore::RhythmEngine::GuitarEngine::RunHitStateCheck(
130127 // miss should be managed by current frame
131128 // overhit is managed here
132129 if (EarlyStrike (CurrentNote.StartSeconds , stats->InputTime , stats->InputOffset )) {
130+ chart->overdrive .UpdateEventViaNote (false , CurrentNote.StartTicks );
133131 return OverhitNote;
134132 }
135133 // if frets match, continue and try to hit
@@ -155,7 +153,8 @@ int Encore::RhythmEngine::GuitarEngine::RunHitStateCheck(
155153 && InHitwindow (CurrentNote.StartSeconds , stats->InputTime , stats->InputOffset )
156154 && (HittableAsHopo (CurrentNote.NoteType , stats->Combo )
157155 || HittableAsTap (CurrentNote.NoteType ) || strum)) {
158- stats->HitNote (std::popcount (chart->at (0 ).front ().Lane ));
156+ stats->HitNote (std::popcount (CurrentNote.Lane ));
157+ chart->overdrive .UpdateEventViaNote (true , CurrentNote.StartTicks );
159158 stats->FretAfterStrum = false ;
160159 chart->at (0 ).erase (curNoteItr);
161160 return HitState::HitNote;
@@ -170,4 +169,4 @@ void Encore::RhythmEngine::GuitarEngine::HitNote() {
170169}
171170void Encore::RhythmEngine::GuitarEngine::Overhit () {
172171 stats->Overhit ();
173- }
172+ }
0 commit comments