awesome shit (see desc)

No longer Additive, it just sets the scroll speed

Now you can set it to either strumline
This commit is contained in:
Burgerballs 2024-05-10 21:23:35 +01:00
parent e5ee6efdf4
commit a5700b37e1
3 changed files with 77 additions and 51 deletions

View File

@ -239,7 +239,7 @@ class PlayState extends MusicBeatSubState
/**
* An FlxTween that changes the additive speed to the desired amount.
*/
public var additiveScrollSpeedTween:FlxTween;
public var scrollSpeedTweens:Array<FlxTween> = [];
/**
* The camera follow point from the last stage.
@ -1184,10 +1184,14 @@ class PlayState extends MusicBeatSubState
cameraZoomTween.active = false;
cameraTweensPausedBySubState.add(cameraZoomTween);
}
if (additiveScrollSpeedTween != null && additiveScrollSpeedTween.active)
for (tween in scrollSpeedTweens)
{
additiveScrollSpeedTween.active = false;
cameraTweensPausedBySubState.add(additiveScrollSpeedTween);
if (tween != null && tween.active)
{
tween.active = false;
cameraTweensPausedBySubState.add(tween);
}
}
// Pause the countdown.
@ -3035,7 +3039,7 @@ class PlayState extends MusicBeatSubState
// Cancel camera and scroll tweening if it's active.
cancelAllCameraTweens();
cancelAdditiveScrollSpeedTween();
cancelScrollSpeedTweens();
// If the opponent is GF, zoom in on the opponent.
// Else, if there is no GF, zoom in on BF.
@ -3256,37 +3260,39 @@ class PlayState extends MusicBeatSubState
}
/**
* The magical function that shall tween the additive scroll speed.
* The magical function that shall tween the scroll speed.
*/
public function tweenAdditiveScrollSpeed(?speed:Float, ?duration:Float, ?ease:Null<Float->Float>):Void
public function tweenScrollSpeed(?speed:Float, ?duration:Float, ?ease:Null<Float->Float>, strumlines:Array<String>):Void
{
// Cancel the current tween if it's active.
cancelAdditiveScrollSpeedTween();
var strumLineTargets:Array<Float> = [
playerStrumline.scrollSpeedAdditive + speed,
opponentStrumline.scrollSpeedAdditive + speed
];
cancelScrollSpeedTweens();
for (i in strumlines)
{
var value:Float = speed;
var strum:Strumline = Reflect.getProperty(this, i);
if (duration == 0)
{
playerStrumline.scrollSpeedAdditive = strumLineTargets[0];
opponentStrumline.scrollSpeedAdditive = strumLineTargets[1];
}
else
{
additiveScrollSpeedTween = FlxTween.tween(this,
{
"playerStrumline.scrollSpeedAdditive": strumLineTargets[0],
"opponentStrumline.scrollSpeedAdditive": strumLineTargets[1]
}, duration, {ease: ease});
if (duration == 0)
{
strum.scrollSpeed = value;
}
else
{
scrollSpeedTweens.push(FlxTween.tween(strum,
{
'scrollSpeed': value
}, duration, {ease: ease}));
}
}
}
public function cancelAdditiveScrollSpeedTween()
public function cancelScrollSpeedTweens()
{
if (additiveScrollSpeedTween != null)
for (tween in scrollSpeedTweens)
{
additiveScrollSpeedTween.cancel();
if (tween != null)
{
tween.cancel();
}
}
}

View File

@ -17,30 +17,31 @@ import funkin.data.event.SongEventSchema.SongEventFieldType;
* Example: Scroll speed change of both strums from 1x to 1.3x:
* ```
* {
* 'e': 'AdditiveScrollSpeed',
* 'e': 'ScrollSpeed',
* "v": {
* "scroll": "0.3",
* "scroll": "1.3",
* "duration": "4",
* "ease": "linear"
* }
* }
* ```
*/
class AdditiveScrollSpeedEvent extends SongEvent
class ScrollSpeedEvent extends SongEvent
{
public function new()
{
super('AdditiveScrollSpeed');
super('ScrollSpeed');
}
static final DEFAULT_SCROLL:Float = 0;
static final DEFAULT_SCROLL:Float = 1;
static final DEFAULT_DURATION:Float = 4.0;
static final DEFAULT_EASE:String = 'linear';
static final DEFAULT_STRUMLINE:String = 'both'; // my special little trick
public override function handleEvent(data:SongEventData):Void
{
// Does nothing if there is no PlayState camera or stage.
if (PlayState.instance == null || PlayState.instance.currentStage == null) return;
// Does nothing if there is no PlayState.
if (PlayState.instance == null) return;
var scroll:Float = data.getFloat('scroll') ?? DEFAULT_SCROLL;
@ -48,11 +49,28 @@ class AdditiveScrollSpeedEvent extends SongEvent
var ease:String = data.getString('ease') ?? DEFAULT_EASE;
var strumline:String = data.getString('strumline') ?? DEFAULT_STRUMLINE;
var strumlineNames:Array<String> = [];
if (scroll == 0)
{
// if the parameter is set to 0, reset the scroll speed to normal.
scroll = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0;
}
switch (strumline)
{
case 'both':
strumlineNames = ['playerStrumline', 'opponentStrumline'];
default:
strumlineNames = [strumline + 'Strumline'];
}
// If it's a string, check the value.
switch (ease)
{
case 'INSTANT':
PlayState.instance.tweenAdditiveScrollSpeed(scroll, 0);
PlayState.instance.tweenScrollSpeed(scroll, 0, null, strumlineNames);
default:
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
@ -62,19 +80,19 @@ class AdditiveScrollSpeedEvent extends SongEvent
return;
}
PlayState.instance.tweenAdditiveScrollSpeed(scroll, durSeconds, easeFunction);
PlayState.instance.tweenScrollSpeed(scroll, durSeconds, easeFunction, strumlineNames);
}
}
public override function getTitle():String
{
return 'Additive Scroll Speed';
return 'Scroll Speed';
}
/**
* ```
* {
* 'scroll': FLOAT, // Target additive scroll level.
* 'scroll': FLOAT, // Target scroll level.
* 'duration': FLOAT, // Duration in steps.
* 'ease': ENUM, // Easing function.
* }
@ -85,7 +103,7 @@ class AdditiveScrollSpeedEvent extends SongEvent
return new SongEventSchema([
{
name: 'scroll',
title: 'Additive Scroll Amount',
title: 'Scroll Amount',
defaultValue: 0.0,
step: 0.1,
type: SongEventFieldType.FLOAT,
@ -106,7 +124,7 @@ class AdditiveScrollSpeedEvent extends SongEvent
type: SongEventFieldType.ENUM,
keys: [
'Linear' => 'linear',
'Instant' => 'INSTANT',
'Instant (Ignores Duration)' => 'INSTANT',
'Sine In' => 'sineIn',
'Sine Out' => 'sineOut',
'Sine In/Out' => 'sineInOut',
@ -132,6 +150,13 @@ class AdditiveScrollSpeedEvent extends SongEvent
'Elastic Out' => 'elasticOut',
'Elastic In/Out' => 'elasticInOut'
]
},
{
name: 'strumline',
title: 'Target Strumline',
defaultValue: 'both',
type: SongEventFieldType.ENUM,
keys: ['Both' => 'both', 'Player' => 'player', 'Opponent' => 'opponent']
}
]);
}

View File

@ -52,13 +52,12 @@ class Strumline extends FlxSpriteGroup
*/
public var conductorInUse(get, set):Conductor;
// Used in-game to control the scroll speed within a song, for example if a song has an additive scroll speed of 1 and the base scroll speed is 1, it will be 2 - burgerballs
public var scrollSpeedAdditive:Float = 0;
public var scrollSpeed(get, never):Float;
// Used in-game to control the scroll speed within a song
public var scrollSpeed:Float = 1.0;
function get_scrollSpeed():Float
public function resetScrollSpeed():Void
{
return (PlayState.instance?.currentChart?.scrollSpeed ?? 1.0) + scrollSpeedAdditive;
scrollSpeed = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0;
}
var _conductorInUse:Null<Conductor>;
@ -143,6 +142,7 @@ class Strumline extends FlxSpriteGroup
this.refresh();
this.onNoteIncoming = new FlxTypedSignal<NoteSprite->Void>();
resetScrollSpeed();
for (i in 0...KEY_COUNT)
{
@ -217,11 +217,6 @@ class Strumline extends FlxSpriteGroup
return null;
}
public function resetScrollSpeed():Void
{
scrollSpeedAdditive = 0;
}
public function getHoldNoteSprite(noteData:SongNoteData):SustainTrail
{
if (noteData == null || ((noteData.length ?? 0.0) <= 0.0)) return null;
@ -552,7 +547,7 @@ class Strumline extends FlxSpriteGroup
{
playStatic(dir);
}
scrollSpeedAdditive = 0;
resetScrollSpeed();
}
public function applyNoteData(data:Array<SongNoteData>):Void