Skip to content

Commit 8fc1493

Browse files
authored
optimize updateInput (#878)
* optimize updateInput * resize optimize * __notePerStrum optimize * Update StrumLine.hx
1 parent 69d82f5 commit 8fc1493

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

source/funkin/game/StrumLine.hx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
253253
var __notePerStrum:Array<Note> = [];
254254

255255
function __inputProcessPressed(note:Note) {
256-
if (__pressed[note.strumID] && note.isSustainNote && note.sustainParent.wasGoodHit && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
256+
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit && note.sustainParent.wasGoodHit) {
257257
PlayState.instance.goodNoteHit(this, note);
258258
}
259259
}
@@ -284,9 +284,11 @@ class StrumLine extends FlxTypedGroup<Strum> {
284284

285285
if (cpu) return;
286286

287-
__pressed.resize(members.length);
288-
__justPressed.resize(members.length);
289-
__justReleased.resize(members.length);
287+
if (__pressed.length != members.length) {
288+
__pressed.resize(members.length);
289+
__justPressed.resize(members.length);
290+
__justReleased.resize(members.length);
291+
}
290292

291293
for (i in 0...members.length) {
292294
__pressed[i] = members[i].__getPressed(this);
@@ -304,17 +306,17 @@ class StrumLine extends FlxTypedGroup<Strum> {
304306

305307
__notePerStrum = cast new haxe.ds.Vector(members.length); // [for(_ in 0...members.length) null];
306308

307-
if (__justPressed.contains(true)) {
308-
notes.forEachAlive(__inputProcessJustPressed);
309+
if (__pressed.contains(true)) {
310+
if (__justPressed.contains(true)) {
311+
notes.forEachAlive(__inputProcessJustPressed);
309312

310-
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
311-
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
312-
}
313+
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
314+
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
313315

314-
if (__pressed.contains(true)) {
315-
for (e in __notePerStrum)
316-
if (e != null)
317-
PlayState.instance.goodNoteHit(this, e);
316+
for (e in __notePerStrum)
317+
if (e != null)
318+
PlayState.instance.goodNoteHit(this, e);
319+
}
318320

319321
for (c in characters)
320322
if (c.lastAnimContext != DANCE)
@@ -324,7 +326,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
324326
}
325327

326328
forEach(function(str:Strum) {
327-
str.updatePlayerInput(str.__getPressed(this), str.__getJustPressed(this), str.__getJustReleased(this));
329+
str.updatePlayerInput(__pressed[str.ID], __justPressed[str.ID], __justReleased[str.ID]);
328330
});
329331

330332
PlayState.instance.gameAndCharsCall("onPostInputUpdate");

0 commit comments

Comments
 (0)