diff --git a/buildnumber.txt b/buildnumber.txt index c0340d26..3af922be 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1312 \ No newline at end of file +1315 \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 33e58894..c763c858 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -727,11 +727,6 @@ class PlayState extends MusicBeatState } } - function tweenCamIn():Void - { - FlxTween.tween(FlxG.camera, {zoom: 1.3}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut}); - } - override function openSubState(SubState:FlxSubState) { var event = scripts.event("onSubstateOpen", new StateEvent(SubState)); @@ -835,6 +830,12 @@ class PlayState extends MusicBeatState public var startedCountdown:Bool = false; public var canPause:Bool = true; + public var curSection(get, null):SwagSection; + + public function get_curSection() { + return PlayState.SONG.notes[Std.int(curStep / 16)]; + } + public function pauseGame() { // TODO: Cancellable game pause @@ -954,58 +955,28 @@ class PlayState extends MusicBeatState } } - if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null) + if (generatedMusic && curSection != null) { - if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) - { - var pos = boyfriend.getCameraPosition(); - camFollow.setPosition(pos.x, pos.y); + var dadPos = dad.getCameraPosition(); + var bfPos = boyfriend.getCameraPosition(); + var section = curSection; - // switch (curStage) - // { - // case 'limo': - // camFollow.x = boyfriend.getMidpoint().x - 300; - // case 'mall': - // camFollow.y = boyfriend.getMidpoint().y - 200; - // case 'school': - // camFollow.x = boyfriend.getMidpoint().x - 200; - // camFollow.y = boyfriend.getMidpoint().y - 200; - // case 'schoolEvil': - // camFollow.x = boyfriend.getMidpoint().x - 200; - // camFollow.y = boyfriend.getMidpoint().y - 200; - // } - - if (SONG.song.toLowerCase() == 'tutorial') - { - FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut}); - } - } else { - var pos = dad.getCameraPosition(); - camFollow.setPosition(pos.x, pos.y); + // from dad to bf + var ratio:Float = 0; + if (section.camTarget != null) + ratio = section.camTarget; + else + ratio = section.mustHitSection ? 1 : 0; - // camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100); - // camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210); + var event = scripts.event("onCameraMove", new CamMoveEvent(bfPos, dadPos, ratio, FlxPoint.get(FlxMath.lerp(dadPos.x, bfPos.x, ratio), FlxMath.lerp(dadPos.y, bfPos.y, ratio)))); - // switch (dad.curCharacter) - // { - // case 'mom': - // camFollow.y = dad.getMidpoint().y; - // case 'senpai': - // camFollow.y = dad.getMidpoint().y - 430; - // camFollow.x = dad.getMidpoint().x - 100; - // case 'senpai-angry': - // camFollow.y = dad.getMidpoint().y - 430; - // camFollow.x = dad.getMidpoint().x - 100; - // } - - if (dad.curCharacter == 'mom') - vocals.volume = 1; - - if (SONG.song.toLowerCase() == 'tutorial') - { - tweenCamIn(); - } + if (!event.cancelled) { + camFollow.setPosition( + event.position.x, event.position.y + ); } + for(e in [event.position, event.bfCamPos, event.dadCamPos]) + e.put(); } if (camZooming) diff --git a/source/funkin/menus/ModSwitchMenu.hx b/source/funkin/menus/ModSwitchMenu.hx index 62dbf753..5ffde6f4 100644 --- a/source/funkin/menus/ModSwitchMenu.hx +++ b/source/funkin/menus/ModSwitchMenu.hx @@ -38,8 +38,6 @@ class ModSwitchMenu extends MusicBeatSubstate { case 'zip': // is a zip mod!! mods.push(Path.withoutExtension(modFolder)); - default: - trace('$modFolder is not a valid mod folder!!'); } } } diff --git a/source/funkin/scripting/events/CamMoveEvent.hx b/source/funkin/scripting/events/CamMoveEvent.hx new file mode 100644 index 00000000..7f33f557 --- /dev/null +++ b/source/funkin/scripting/events/CamMoveEvent.hx @@ -0,0 +1,42 @@ +package funkin.scripting.events; + +import flixel.math.FlxPoint; + +class CamMoveEvent extends CancellableEvent { + /** + * Final camera position. + */ + public var position:FlxPoint; + + /** + * Boyfriend's camera position. + */ + public var bfCamPos:FlxPoint; + + /** + * Dad's camera position. + */ + public var dadCamPos:FlxPoint; + + /** + * Ratio for lerping between Dad and BF. + * 0 = Camera focuses dad + * 0.5 = Duet Camera + * 1 = Camera focuses BF + */ + public var ratio:Float = 0; + + /** + * Whenever the camera focuses BF more than dad. + */ + public var focusBF:Bool = false; + + public function new(bfCamPos:FlxPoint, dadCamPos:FlxPoint, ratio:Float, position:FlxPoint) { + super(); + this.bfCamPos = bfCamPos; + this.dadCamPos = dadCamPos; + this.ratio = ratio; + this.position = position; + this.focusBF = ratio >= 0.5; + } +} \ No newline at end of file diff --git a/source/funkin/system/Section.hx b/source/funkin/system/Section.hx index 19de7112..b57400c5 100644 --- a/source/funkin/system/Section.hx +++ b/source/funkin/system/Section.hx @@ -9,6 +9,7 @@ typedef SwagSection = var bpm:Float; var changeBPM:Bool; var altAnim:Bool; + @:optional var camTarget:Null; } class Section