Skip to content

Commit 31ae98f

Browse files
committed
updateRatingStuff as dynamic + adding iconArray
Resolves #624
1 parent 4e91b60 commit 31ae98f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

source/funkin/game/PlayState.hx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ class PlayState extends MusicBeatState
294294
* Opponent's icon
295295
*/
296296
public var iconP2:HealthIcon;
297+
/**
298+
* Every active icon that will be updated during gameplay (defaults to `iconP1` and `iconP1` between `create` and `postCreate` in scripts)
299+
*/
300+
public var iconArray:Array<HealthIcon> = [];
301+
297302
/**
298303
* Camera for the HUD (notes, misses).
299304
*/
@@ -750,9 +755,9 @@ class PlayState extends MusicBeatState
750755

751756
health = maxHealth / 2;
752757

753-
iconP1 = new HealthIcon(boyfriend != null ? boyfriend.getIcon() : "face", true);
754-
iconP2 = new HealthIcon(dad != null ? dad.getIcon() : "face", false);
755-
for(icon in [iconP1, iconP2]) {
758+
iconArray.push(iconP1 = new HealthIcon(boyfriend != null ? boyfriend.getIcon() : "face", true));
759+
iconArray.push(iconP2 = new HealthIcon(dad != null ? dad.getIcon() : "face", false));
760+
for (icon in iconArray) {
756761
icon.y = healthBar.y - (icon.height / 2);
757762
add(icon);
758763
}
@@ -769,7 +774,8 @@ class PlayState extends MusicBeatState
769774
scoreTxt.alignment = RIGHT;
770775
missesTxt.alignment = CENTER;
771776
accuracyTxt.alignment = LEFT;
772-
updateRatingStuff();
777+
if (updateRatingStuff != null)
778+
updateRatingStuff();
773779

774780
for(e in [healthBar, healthBarBG, iconP1, iconP2, scoreTxt, missesTxt, accuracyTxt])
775781
e.cameras = [camHUD];
@@ -1227,7 +1233,7 @@ class PlayState extends MusicBeatState
12271233
iconP2.health = 1 - (healthBarPercent / 100);
12281234
}
12291235

1230-
function updateRatingStuff() {
1236+
dynamic function updateRatingStuff() {
12311237
scoreTxt.text = 'Score:$songScore';
12321238
missesTxt.text = '${comboBreaks ? "Combo Breaks" : "Misses"}:$misses';
12331239

@@ -1257,7 +1263,8 @@ class PlayState extends MusicBeatState
12571263
return;
12581264
}
12591265

1260-
updateRatingStuff();
1266+
if (updateRatingStuff != null)
1267+
updateRatingStuff();
12611268

12621269
if (canAccessDebugMenus) {
12631270
if (chartingMode && FlxG.keys.justPressed.SEVEN) {
@@ -1271,7 +1278,7 @@ class PlayState extends MusicBeatState
12711278
}
12721279

12731280
if (doIconBop)
1274-
for (icon in [iconP1, iconP2])
1281+
for (icon in iconArray)
12751282
if (icon.updateBump != null)
12761283
icon.updateBump();
12771284

@@ -1849,7 +1856,7 @@ class PlayState extends MusicBeatState
18491856
}
18501857

18511858
if (doIconBop)
1852-
for (icon in [iconP1, iconP2])
1859+
for (icon in iconArray)
18531860
if (icon.bump != null)
18541861
icon.bump();
18551862

0 commit comments

Comments
 (0)