1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-02-09 13:07:10 +00:00

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. * 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. * The camera follow point from the last stage.
@ -1184,10 +1184,14 @@ class PlayState extends MusicBeatSubState
cameraZoomTween.active = false; cameraZoomTween.active = false;
cameraTweensPausedBySubState.add(cameraZoomTween); cameraTweensPausedBySubState.add(cameraZoomTween);
} }
if (additiveScrollSpeedTween != null && additiveScrollSpeedTween.active)
for (tween in scrollSpeedTweens)
{ {
additiveScrollSpeedTween.active = false; if (tween != null && tween.active)
cameraTweensPausedBySubState.add(additiveScrollSpeedTween); {
tween.active = false;
cameraTweensPausedBySubState.add(tween);
}
} }
// Pause the countdown. // Pause the countdown.
@ -3035,7 +3039,7 @@ class PlayState extends MusicBeatSubState
// Cancel camera and scroll tweening if it's active. // Cancel camera and scroll tweening if it's active.
cancelAllCameraTweens(); cancelAllCameraTweens();
cancelAdditiveScrollSpeedTween(); cancelScrollSpeedTweens();
// If the opponent is GF, zoom in on the opponent. // If the opponent is GF, zoom in on the opponent.
// Else, if there is no GF, zoom in on BF. // 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. // Cancel the current tween if it's active.
cancelAdditiveScrollSpeedTween(); cancelScrollSpeedTweens();
var strumLineTargets:Array<Float> = [ for (i in strumlines)
playerStrumline.scrollSpeedAdditive + speed, {
opponentStrumline.scrollSpeedAdditive + speed var value:Float = speed;
]; var strum:Strumline = Reflect.getProperty(this, i);
if (duration == 0) if (duration == 0)
{ {
playerStrumline.scrollSpeedAdditive = strumLineTargets[0]; strum.scrollSpeed = value;
opponentStrumline.scrollSpeedAdditive = strumLineTargets[1]; }
} else
else {
{ scrollSpeedTweens.push(FlxTween.tween(strum,
additiveScrollSpeedTween = FlxTween.tween(this, {
{ 'scrollSpeed': value
"playerStrumline.scrollSpeedAdditive": strumLineTargets[0], }, duration, {ease: ease}));
"opponentStrumline.scrollSpeedAdditive": strumLineTargets[1] }
}, 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: * Example: Scroll speed change of both strums from 1x to 1.3x:
* ``` * ```
* { * {
* 'e': 'AdditiveScrollSpeed', * 'e': 'ScrollSpeed',
* "v": { * "v": {
* "scroll": "0.3", * "scroll": "1.3",
* "duration": "4", * "duration": "4",
* "ease": "linear" * "ease": "linear"
* } * }
* } * }
* ``` * ```
*/ */
class AdditiveScrollSpeedEvent extends SongEvent class ScrollSpeedEvent extends SongEvent
{ {
public function new() 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_DURATION:Float = 4.0;
static final DEFAULT_EASE:String = 'linear'; static final DEFAULT_EASE:String = 'linear';
static final DEFAULT_STRUMLINE:String = 'both'; // my special little trick
public override function handleEvent(data:SongEventData):Void public override function handleEvent(data:SongEventData):Void
{ {
// Does nothing if there is no PlayState camera or stage. // Does nothing if there is no PlayState.
if (PlayState.instance == null || PlayState.instance.currentStage == null) return; if (PlayState.instance == null) return;
var scroll:Float = data.getFloat('scroll') ?? DEFAULT_SCROLL; 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 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. // If it's a string, check the value.
switch (ease) switch (ease)
{ {
case 'INSTANT': case 'INSTANT':
PlayState.instance.tweenAdditiveScrollSpeed(scroll, 0); PlayState.instance.tweenScrollSpeed(scroll, 0, null, strumlineNames);
default: default:
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000; var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease); var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
@ -62,19 +80,19 @@ class AdditiveScrollSpeedEvent extends SongEvent
return; return;
} }
PlayState.instance.tweenAdditiveScrollSpeed(scroll, durSeconds, easeFunction); PlayState.instance.tweenScrollSpeed(scroll, durSeconds, easeFunction, strumlineNames);
} }
} }
public override function getTitle():String 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. * 'duration': FLOAT, // Duration in steps.
* 'ease': ENUM, // Easing function. * 'ease': ENUM, // Easing function.
* } * }
@ -85,7 +103,7 @@ class AdditiveScrollSpeedEvent extends SongEvent
return new SongEventSchema([ return new SongEventSchema([
{ {
name: 'scroll', name: 'scroll',
title: 'Additive Scroll Amount', title: 'Scroll Amount',
defaultValue: 0.0, defaultValue: 0.0,
step: 0.1, step: 0.1,
type: SongEventFieldType.FLOAT, type: SongEventFieldType.FLOAT,
@ -106,7 +124,7 @@ class AdditiveScrollSpeedEvent extends SongEvent
type: SongEventFieldType.ENUM, type: SongEventFieldType.ENUM,
keys: [ keys: [
'Linear' => 'linear', 'Linear' => 'linear',
'Instant' => 'INSTANT', 'Instant (Ignores Duration)' => 'INSTANT',
'Sine In' => 'sineIn', 'Sine In' => 'sineIn',
'Sine Out' => 'sineOut', 'Sine Out' => 'sineOut',
'Sine In/Out' => 'sineInOut', 'Sine In/Out' => 'sineInOut',
@ -132,6 +150,13 @@ class AdditiveScrollSpeedEvent extends SongEvent
'Elastic Out' => 'elasticOut', 'Elastic Out' => 'elasticOut',
'Elastic In/Out' => 'elasticInOut' '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; 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 // Used in-game to control the scroll speed within a song
public var scrollSpeedAdditive:Float = 0; public var scrollSpeed:Float = 1.0;
public var scrollSpeed(get, never):Float;
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>; var _conductorInUse:Null<Conductor>;
@ -143,6 +142,7 @@ class Strumline extends FlxSpriteGroup
this.refresh(); this.refresh();
this.onNoteIncoming = new FlxTypedSignal<NoteSprite->Void>(); this.onNoteIncoming = new FlxTypedSignal<NoteSprite->Void>();
resetScrollSpeed();
for (i in 0...KEY_COUNT) for (i in 0...KEY_COUNT)
{ {
@ -217,11 +217,6 @@ class Strumline extends FlxSpriteGroup
return null; return null;
} }
public function resetScrollSpeed():Void
{
scrollSpeedAdditive = 0;
}
public function getHoldNoteSprite(noteData:SongNoteData):SustainTrail public function getHoldNoteSprite(noteData:SongNoteData):SustainTrail
{ {
if (noteData == null || ((noteData.length ?? 0.0) <= 0.0)) return null; if (noteData == null || ((noteData.length ?? 0.0) <= 0.0)) return null;
@ -552,7 +547,7 @@ class Strumline extends FlxSpriteGroup
{ {
playStatic(dir); playStatic(dir);
} }
scrollSpeedAdditive = 0; resetScrollSpeed();
} }
public function applyNoteData(data:Array<SongNoteData>):Void public function applyNoteData(data:Array<SongNoteData>):Void