opponent mode finally saves correctly

This commit is contained in:
Yoshman29
2023-04-20 22:45:49 +02:00
parent 456a2f7f8d
commit ff322562bb
3 changed files with 57 additions and 30 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

@@ -0,0 +1,19 @@
package funkin.backend.system;
import flixel.group.FlxSpriteGroup;
class RotatingSpriteGroup extends FlxSpriteGroup {
public function recycleLoop(?ObjectClass:Class<FlxSprite>, ?ObjectFactory:Void->FlxSprite, Force:Bool = false, Revive:Bool = true):FlxSprite {
@:privateAccess {
if (maxSize <= 0)
return super.recycle(ObjectClass, ObjectFactory, Force, Revive);
if (group.members.length < maxSize)
return group.recycleCreateObject(ObjectClass, ObjectFactory);
var spr = group.members.shift();
group.members.push(spr);
if (Revive)
spr.revive();
return spr;
}
}
}
+38 -30
View File
@@ -1,5 +1,6 @@
package funkin.game;
import funkin.backend.system.RotatingSpriteGroup;
import funkin.editors.charter.Charter;
import funkin.savedata.FunkinSave;
import flixel.graphics.FlxGraphic;
@@ -424,7 +425,7 @@ class PlayState extends MusicBeatState
/**
* Group containing all of the combo sprites.
*/
public var comboGroup:FlxSpriteGroup;
public var comboGroup:RotatingSpriteGroup;
/**
* Array containing all of the note types names.
*/
@@ -536,7 +537,7 @@ class PlayState extends MusicBeatState
// CHARACTER INITIALISATION
#if REGION
comboGroup = new FlxSpriteGroup(FlxG.width * 0.55, (FlxG.height * 0.5) - 60);
comboGroup = new RotatingSpriteGroup(FlxG.width * 0.55, (FlxG.height * 0.5) - 60);
comboGroup.maxSize = 25;
#end
@@ -1239,13 +1240,22 @@ class PlayState extends MusicBeatState
accuracy: accuracy,
hits: [],
date: Date.now().toString()
});
}, getSongChanges());
#end
}
startCutscene("end-", endCutscene, nextSong);
}
private static inline function getSongChanges():Array<HighscoreChange> {
var a = [];
if (opponentMode)
a.push(COpponentMode);
if (coopMode)
a.push(CCoopMode);
return a;
}
/**
* Immediately switches to the next song, or goes back to the Story/Freeplay menu.
*/
@@ -1495,28 +1505,34 @@ class PlayState extends MusicBeatState
songScore += score;
var comboSpr:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}'));
comboSpr.resetSprite(comboGroup.x, comboGroup.y);
comboGroup.remove(comboSpr, true);
comboSpr.acceleration.y = 600;
comboSpr.velocity.y -= 150;
comboSpr.velocity.x += FlxG.random.int(1, 10);
comboSpr.scale.set(event.ratingScale, event.ratingScale);
comboSpr.antialiasing = event.ratingAntialiasing;
comboSpr.updateHitbox();
var separatedScore:String = Std.string(combo).addZeros(3);
if (combo == 0 || combo >= 10) {
comboGroup.add(comboSpr);
if (combo >= 10) {
var comboSpr:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}'));
comboSpr.resetSprite(comboGroup.x, comboGroup.y);
comboSpr.acceleration.y = 600;
comboSpr.velocity.y -= 150;
comboSpr.velocity.x += FlxG.random.int(1, 10);
comboSpr.scale.set(event.ratingScale, event.ratingScale);
comboSpr.antialiasing = event.ratingAntialiasing;
comboSpr.updateHitbox();
FlxTween.tween(comboSpr, {alpha: 0}, 0.2, {
onComplete: function(tween:FlxTween)
{
comboSpr.visible = comboSpr.active = false;
},
startDelay: Conductor.crochet * 0.001
});
}
for (i in 0...separatedScore.length)
{
var numScore:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}num${separatedScore.charAt(i)}${event.ratingSuffix}'));
var numScore:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}num${separatedScore.charAt(i)}${event.ratingSuffix}'));
numScore.resetSprite(comboGroup.x + (43 * i) - 90, comboGroup.y + 80);
comboGroup.remove(numScore, true);
numScore.antialiasing = event.numAntialiasing;
numScore.scale.set(event.numScale, event.numScale);
numScore.updateHitbox();
@@ -1525,8 +1541,6 @@ class PlayState extends MusicBeatState
numScore.velocity.y -= FlxG.random.int(140, 160);
numScore.velocity.x = FlxG.random.float(-5, 5);
comboGroup.add(numScore);
FlxTween.tween(numScore, {alpha: 0}, 0.2, {
onComplete: function(tween:FlxTween)
{
@@ -1537,7 +1551,7 @@ class PlayState extends MusicBeatState
}
}
var rating:FlxSprite = comboGroup.recycle(FlxSprite);
var rating:FlxSprite = comboGroup.recycleLoop(FlxSprite);
rating.resetSprite(comboGroup.x + -40, comboGroup.y + -60);
rating.loadAnimatedGraphic(Paths.image('${event.ratingPrefix}$daRating${event.ratingSuffix}'));
rating.acceleration.y = 550;
@@ -1548,16 +1562,10 @@ class PlayState extends MusicBeatState
rating.updateHitbox();
FlxTween.tween(rating, {alpha: 0}, 0.2, {
startDelay: Conductor.crochet * 0.001
});
FlxTween.tween(comboSpr, {alpha: 0}, 0.2, {
onComplete: function(tween:FlxTween)
{
startDelay: Conductor.crochet * 0.001,
onComplete: function(tween:FlxTween) {
rating.visible = rating.active = false;
comboSpr.visible = comboSpr.active = false;
},
startDelay: Conductor.crochet * 0.001
}
});
ratingNum += 1;