Skip to content

Commit e0e1deb

Browse files
el error mas pendejo de la historia
1 parent 5c8c8cf commit e0e1deb

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

source/funkin/states/NeoPlayState.hx

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ class NeoPlayState extends ScriptState
366366

367367
override function update(elapsed:Float)
368368
{
369-
Conductor.songPosition = FlxG.sound.music.time;
369+
if (FlxG.sound.music.playing)
370+
Conductor.songPosition += elapsed * 1000;
370371

371372
super.update(elapsed);
372373

@@ -377,6 +378,13 @@ class NeoPlayState extends ScriptState
377378
);
378379

379380
scoreText.text = ClientPrefs.data.botplay ? 'BOTPLAY' : 'Score: ' + score + ' Misses: ' + misses + ' Accuracy: ' + CoolUtil.floorDecimal(accuracy, 2) + '%';
381+
382+
if (Controls.RESET)
383+
{
384+
FlxG.sound.music?.pause();
385+
386+
FlxG.resetState();
387+
}
380388
}
381389

382390
function addCharacter(character:Character)
@@ -531,6 +539,49 @@ class NeoPlayState extends ScriptState
531539
}
532540
}
533541

542+
final vocalsToSync:Array<FlxSound> = [];
543+
544+
function resyncVocals():Void
545+
{
546+
if (FlxG.sound.music != null)
547+
Conductor.songPosition = FlxG.sound.music.time;
548+
549+
for (vocal in vocalsToSync)
550+
if (vocal != null)
551+
{
552+
vocal.pause();
553+
554+
if (Conductor.songPosition <= vocal.length)
555+
vocal.time = Conductor.songPosition;
556+
557+
vocal.play();
558+
}
559+
}
560+
561+
override function stepHit()
562+
{
563+
if (FlxG.sound.music != null && FlxG.sound.music.time >= -ClientPrefs.data.noteOffset)
564+
{
565+
final timeSub:Float = Conductor.songPosition - Conductor.offset;
566+
final syncTime:Float = 20;
567+
568+
for (audio in [FlxG.sound.music].concat(vocalsToSync))
569+
{
570+
if (audio != null)
571+
{
572+
if (audio.length > 0 && Math.abs(audio.time - timeSub) > syncTime)
573+
{
574+
resyncVocals();
575+
576+
break;
577+
}
578+
}
579+
}
580+
}
581+
582+
super.stepHit();
583+
}
584+
534585
override function beatHit()
535586
{
536587
super.beatHit();

0 commit comments

Comments
 (0)