2022-03-08 08:13:53 +00:00
|
|
|
|
package funkin.play;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import flixel.addons.display.FlxPieDial;
|
2023-05-25 22:34:26 +00:00
|
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import flixel.addons.transition.Transition;
|
2020-10-25 20:51:06 +00:00
|
|
|
|
import flixel.FlxCamera;
|
2020-10-04 06:42:58 +00:00
|
|
|
|
import flixel.FlxObject;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
import flixel.FlxState;
|
2020-10-09 21:24:20 +00:00
|
|
|
|
import flixel.FlxSubState;
|
2020-10-05 09:48:30 +00:00
|
|
|
|
import flixel.math.FlxMath;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
import flixel.math.FlxPoint;
|
2021-01-16 22:21:06 +00:00
|
|
|
|
import flixel.math.FlxRect;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
import flixel.text.FlxText;
|
2020-10-05 18:24:51 +00:00
|
|
|
|
import flixel.tweens.FlxEase;
|
2020-10-03 19:32:15 +00:00
|
|
|
|
import flixel.tweens.FlxTween;
|
2020-10-05 20:32:41 +00:00
|
|
|
|
import flixel.ui.FlxBar;
|
2020-10-04 06:42:58 +00:00
|
|
|
|
import flixel.util.FlxColor;
|
2020-10-03 19:32:15 +00:00
|
|
|
|
import flixel.util.FlxTimer;
|
2024-07-10 18:23:50 +00:00
|
|
|
|
import flixel.util.FlxStringUtil;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.api.newgrounds.NGio;
|
2024-03-23 21:50:48 +00:00
|
|
|
|
import funkin.audio.FunkinSound;
|
2023-09-17 11:45:10 +00:00
|
|
|
|
import funkin.audio.VoicesGroup;
|
2024-03-23 19:34:37 +00:00
|
|
|
|
import funkin.data.dialogue.conversation.ConversationRegistry;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.data.event.SongEventRegistry;
|
|
|
|
|
import funkin.data.notestyle.NoteStyleData;
|
2023-09-17 11:45:10 +00:00
|
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.data.song.SongData.SongCharacterData;
|
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
|
|
|
|
import funkin.data.song.SongRegistry;
|
|
|
|
|
import funkin.data.stage.StageRegistry;
|
2024-03-23 21:50:48 +00:00
|
|
|
|
import funkin.graphics.FunkinCamera;
|
|
|
|
|
import funkin.graphics.FunkinSprite;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.Highscore.Tallies;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
import funkin.input.PreciseInputManager;
|
2022-03-11 06:30:01 +00:00
|
|
|
|
import funkin.modding.events.ScriptEvent;
|
|
|
|
|
import funkin.modding.events.ScriptEventDispatcher;
|
2022-04-19 00:39:41 +00:00
|
|
|
|
import funkin.play.character.BaseCharacter;
|
2023-05-25 22:34:26 +00:00
|
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.play.components.ComboMilestone;
|
|
|
|
|
import funkin.play.components.HealthIcon;
|
|
|
|
|
import funkin.play.components.PopUpStuff;
|
|
|
|
|
import funkin.play.cutscene.dialogue.Conversation;
|
2023-02-22 01:58:15 +00:00
|
|
|
|
import funkin.play.cutscene.VanillaCutscenes;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
import funkin.play.cutscene.VideoCutscene;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
import funkin.play.notes.NoteDirection;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.play.notes.NoteSplash;
|
2023-09-17 11:45:10 +00:00
|
|
|
|
import funkin.play.notes.NoteSprite;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.play.notes.notestyle.NoteStyle;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
import funkin.play.notes.Strumline;
|
2023-06-27 22:06:33 +00:00
|
|
|
|
import funkin.play.notes.SustainTrail;
|
2024-05-31 14:55:42 +00:00
|
|
|
|
import funkin.play.notes.notekind.NoteKindManager;
|
2022-07-07 01:49:42 +00:00
|
|
|
|
import funkin.play.scoring.Scoring;
|
2022-09-22 10:34:03 +00:00
|
|
|
|
import funkin.play.song.Song;
|
2022-03-08 08:13:53 +00:00
|
|
|
|
import funkin.play.stage.Stage;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.save.Save;
|
|
|
|
|
import funkin.ui.debug.charting.ChartEditorState;
|
2023-11-07 09:04:22 +00:00
|
|
|
|
import funkin.ui.debug.stage.StageOffsetSubState;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.ui.mainmenu.MainMenuState;
|
|
|
|
|
import funkin.ui.MusicBeatSubState;
|
|
|
|
|
import funkin.ui.options.PreferencesMenu;
|
2023-06-16 21:37:56 +00:00
|
|
|
|
import funkin.ui.story.StoryMenuState;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import funkin.ui.transition.LoadingState;
|
2023-03-18 19:47:23 +00:00
|
|
|
|
import funkin.util.SerializerUtil;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import haxe.Int64;
|
2022-03-09 15:29:03 +00:00
|
|
|
|
import lime.ui.Haptic;
|
2024-02-12 21:50:29 +00:00
|
|
|
|
import openfl.display.BitmapData;
|
|
|
|
|
import openfl.geom.Rectangle;
|
|
|
|
|
import openfl.Lib;
|
2021-03-22 14:09:46 +00:00
|
|
|
|
#if discord_rpc
|
2021-03-21 20:29:47 +00:00
|
|
|
|
import Discord.DiscordClient;
|
|
|
|
|
#end
|
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Parameters used to initialize the PlayState.
|
|
|
|
|
*/
|
|
|
|
|
typedef PlayStateParams =
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The song to play.
|
|
|
|
|
*/
|
|
|
|
|
targetSong:Song,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The difficulty to play the song on.
|
|
|
|
|
* @default `Constants.DEFAULT_DIFFICULTY`
|
|
|
|
|
*/
|
|
|
|
|
?targetDifficulty:String,
|
|
|
|
|
/**
|
2024-02-06 02:35:58 +00:00
|
|
|
|
* The variation to play on.
|
2024-02-29 23:49:20 +00:00
|
|
|
|
* @default `Constants.DEFAULT_VARIATION`
|
2023-06-02 19:35:01 +00:00
|
|
|
|
*/
|
2024-02-06 02:35:58 +00:00
|
|
|
|
?targetVariation:String,
|
2024-02-05 18:35:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* The instrumental to play with.
|
|
|
|
|
* Significant if the `targetSong` supports alternate instrumentals.
|
|
|
|
|
* @default `null`
|
|
|
|
|
*/
|
|
|
|
|
?targetInstrumental:String,
|
2023-07-26 20:52:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the song should start in Practice Mode.
|
|
|
|
|
* @default `false`
|
|
|
|
|
*/
|
|
|
|
|
?practiceMode:Bool,
|
2024-03-06 03:27:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the song should start in Bot Play Mode.
|
|
|
|
|
* @default `false`
|
|
|
|
|
*/
|
|
|
|
|
?botPlayMode:Bool,
|
2023-07-26 20:52:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the song should be in minimal mode.
|
|
|
|
|
* @default `false`
|
|
|
|
|
*/
|
|
|
|
|
?minimalMode:Bool,
|
2023-07-27 00:03:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* If specified, the game will jump to the specified timestamp after the countdown ends.
|
2024-02-29 23:49:20 +00:00
|
|
|
|
* @default `0.0`
|
2023-07-27 00:03:31 +00:00
|
|
|
|
*/
|
|
|
|
|
?startTimestamp:Float,
|
2024-02-29 23:49:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* If specified, the game will play the song with the given speed.
|
|
|
|
|
* @default `1.0` for 100% speed.
|
|
|
|
|
*/
|
|
|
|
|
?playbackRate:Float,
|
2023-08-04 20:15:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* If specified, the game will not load the instrumental or vocal tracks,
|
|
|
|
|
* and must be loaded externally.
|
|
|
|
|
*/
|
|
|
|
|
?overrideMusic:Bool,
|
2024-02-17 04:48:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* The initial camera follow point.
|
|
|
|
|
* Used to persist the position of the `cameraFollowPosition` between levels.
|
|
|
|
|
*/
|
|
|
|
|
?cameraFollowPoint:FlxPoint,
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* The gameplay state, where all the rhythm gaming happens.
|
2023-07-26 20:52:58 +00:00
|
|
|
|
* SubState so it can be loaded as a child of the chart editor.
|
2023-02-22 01:58:15 +00:00
|
|
|
|
*/
|
2023-07-26 20:52:58 +00:00
|
|
|
|
class PlayState extends MusicBeatSubState
|
2020-10-03 06:50:15 +00:00
|
|
|
|
{
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* STATIC VARIABLES
|
|
|
|
|
* Static variables should be used for information that must be persisted between states or between resets,
|
|
|
|
|
* such as the active song or song playlist.
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* The currently active PlayState.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* There should be only one PlayState in existance at a time, we can use a singleton.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public static var instance:PlayState = null;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* This sucks. We need this because FlxG.resetState(); assumes the constructor has no arguments.
|
|
|
|
|
* @see https://github.com/HaxeFlixel/flixel/issues/2541
|
|
|
|
|
*/
|
|
|
|
|
static var lastParams:PlayStateParams = null;
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* PUBLIC INSTANCE VARIABLES
|
|
|
|
|
* Public instance variables should be used for information that must be reset or dereferenced
|
|
|
|
|
* every time the state is changed, but may need to be accessed externally.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The currently selected stage.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var currentSong:Song = null;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The currently selected difficulty.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2024-02-06 02:35:58 +00:00
|
|
|
|
* The currently selected variation.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2024-02-06 02:35:58 +00:00
|
|
|
|
public var currentVariation:String = Constants.DEFAULT_VARIATION;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-06-07 01:38:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* The currently selected instrumental ID.
|
|
|
|
|
* @default `''`
|
|
|
|
|
*/
|
|
|
|
|
public var currentInstrumental:String = '';
|
|
|
|
|
|
2023-01-27 07:38:37 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The currently active Stage. This is the object containing all the props.
|
2023-01-27 07:38:37 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var currentStage:Stage = null;
|
2023-01-27 07:38:37 +00:00
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* Gets set to true when the PlayState needs to reset (player opted to restart or died).
|
|
|
|
|
* Gets disabled once resetting happens.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var needsReset:Bool = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The current 'Blueball Counter' to display in the pause menu.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
* Resets when you beat a song or go back to the main menu.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var deathCounter:Int = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The player's current health.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-27 17:43:42 +00:00
|
|
|
|
public var health:Float = Constants.HEALTH_STARTING;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The player's current score.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* TODO: Move this to its own class.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var songScore:Int = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-05 07:44:57 +00:00
|
|
|
|
/**
|
|
|
|
|
* Start at this point in the song once the countdown is done.
|
|
|
|
|
* For example, if `startTimestamp` is `30000`, the song will start at the 30 second mark.
|
|
|
|
|
* Used for chart playtesting or practice.
|
|
|
|
|
*/
|
|
|
|
|
public var startTimestamp:Float = 0.0;
|
|
|
|
|
|
2024-02-29 23:49:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Play back the song at this speed.
|
|
|
|
|
* @default `1.0` for normal speed.
|
|
|
|
|
*/
|
|
|
|
|
public var playbackRate:Float = 1.0;
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* An empty FlxObject contained in the scene.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* The current gameplay camera will always follow this object. Tween its position to move the camera smoothly.
|
2023-06-09 19:34:56 +00:00
|
|
|
|
*
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* It needs to be an object in the scene for the camera to be configured to follow it.
|
2024-02-22 23:55:24 +00:00
|
|
|
|
* We optionally make this a sprite so we can draw a debug graphic with it.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
public var cameraFollowPoint:FlxObject;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-02-28 06:29:40 +00:00
|
|
|
|
/**
|
|
|
|
|
* An FlxTween that tweens the camera to the follow point.
|
|
|
|
|
* Only used when tweening the camera manually, rather than tweening via follow.
|
|
|
|
|
*/
|
|
|
|
|
public var cameraFollowTween:FlxTween;
|
|
|
|
|
|
2024-03-10 23:35:41 +00:00
|
|
|
|
/**
|
|
|
|
|
* An FlxTween that zooms the camera to the desired amount.
|
|
|
|
|
*/
|
|
|
|
|
public var cameraZoomTween:FlxTween;
|
|
|
|
|
|
2024-05-09 16:51:03 +00:00
|
|
|
|
/**
|
|
|
|
|
* An FlxTween that changes the additive speed to the desired amount.
|
|
|
|
|
*/
|
2024-05-10 20:23:35 +00:00
|
|
|
|
public var scrollSpeedTweens:Array<FlxTween> = [];
|
2024-05-09 16:51:03 +00:00
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The camera follow point from the last stage.
|
|
|
|
|
* Used to persist the position of the `cameraFollowPosition` between levels.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2024-02-17 04:48:43 +00:00
|
|
|
|
public var previousCameraFollowPoint:FlxPoint = null;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
2024-03-16 15:38:10 +00:00
|
|
|
|
* The current camera zoom level without any modifiers applied.
|
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public var currentCameraZoom:Float = FlxCamera.defaultZoom;
|
2024-03-16 15:38:10 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2024-03-28 18:05:38 +00:00
|
|
|
|
* Multiplier for currentCameraZoom for camera bops.
|
|
|
|
|
* Lerped back to 1.0x every frame.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public var cameraBopMultiplier:Float = 1.0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-16 15:38:10 +00:00
|
|
|
|
/**
|
2024-03-28 18:05:38 +00:00
|
|
|
|
* Default camera zoom for the current stage.
|
|
|
|
|
* If we aren't in a stage, just use the default zoom (1.05x).
|
2024-03-16 15:38:10 +00:00
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public var stageZoom(get, never):Float;
|
|
|
|
|
|
|
|
|
|
function get_stageZoom():Float
|
|
|
|
|
{
|
|
|
|
|
if (currentStage != null) return currentStage.camZoom;
|
|
|
|
|
else
|
|
|
|
|
return FlxCamera.defaultZoom * 1.05;
|
|
|
|
|
}
|
2024-03-16 15:38:10 +00:00
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The current HUD camera zoom level.
|
2023-06-09 19:34:56 +00:00
|
|
|
|
*
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* The camera zoom is increased every beat, and lerped back to this value every frame, creating a smooth 'zoom-in' effect.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var defaultHUDCameraZoom:Float = FlxCamera.defaultZoom * 1.0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2024-03-28 18:05:38 +00:00
|
|
|
|
* Camera bop intensity multiplier.
|
|
|
|
|
* Applied to cameraBopMultiplier on camera bops (usually every beat).
|
|
|
|
|
* @default `101.5%`
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public var cameraBopIntensity:Float = Constants.DEFAULT_BOP_INTENSITY;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* Intensity of the HUD camera zoom.
|
2024-03-28 18:05:38 +00:00
|
|
|
|
* Need to make this a multiplier later. Just shoving in 0.015 for now so it doesn't break.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* @default `3.0%`
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public var hudCameraZoomIntensity:Float = 0.015 * 2.0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* How many beats (quarter notes) between camera zooms.
|
|
|
|
|
* @default One camera zoom per measure (four beats).
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public var cameraZoomRate:Int = Constants.DEFAULT_ZOOM_RATE;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the game is currently in the countdown before the song resumes.
|
|
|
|
|
*/
|
|
|
|
|
public var isInCountdown:Bool = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the game is currently in Practice Mode.
|
|
|
|
|
* If true, player will not lose gain or lose score from notes.
|
|
|
|
|
*/
|
|
|
|
|
public var isPracticeMode:Bool = false;
|
|
|
|
|
|
2024-03-06 03:27:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the game is currently in Bot Play Mode.
|
|
|
|
|
* If true, player will not lose gain or lose score from notes.
|
|
|
|
|
*/
|
|
|
|
|
public var isBotPlayMode:Bool = false;
|
|
|
|
|
|
2024-03-04 21:37:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the player has dropped below zero health,
|
|
|
|
|
* and we are just waiting for an animation to play out before transitioning.
|
|
|
|
|
*/
|
|
|
|
|
public var isPlayerDying:Bool = false;
|
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* In Minimal Mode, the stage and characters are not loaded and a standard background is used.
|
|
|
|
|
*/
|
|
|
|
|
public var isMinimalMode:Bool = false;
|
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the game is currently in an animated cutscene, and gameplay should be stopped.
|
|
|
|
|
*/
|
|
|
|
|
public var isInCutscene:Bool = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the inputs should be disabled for whatever reason... used for the stage edit lol!
|
|
|
|
|
*/
|
|
|
|
|
public var disableKeys:Bool = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-08-31 22:47:23 +00:00
|
|
|
|
public var isSubState(get, never):Bool;
|
2023-07-26 20:52:58 +00:00
|
|
|
|
|
|
|
|
|
function get_isSubState():Bool
|
|
|
|
|
{
|
|
|
|
|
return this._parentState != null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 22:47:23 +00:00
|
|
|
|
public var isChartingMode(get, never):Bool;
|
2023-07-26 20:52:58 +00:00
|
|
|
|
|
|
|
|
|
function get_isChartingMode():Bool
|
|
|
|
|
{
|
|
|
|
|
return this._parentState != null && Std.isOfType(this._parentState, ChartEditorState);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 21:37:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* The current dialogue.
|
|
|
|
|
*/
|
|
|
|
|
public var currentConversation:Conversation;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Key press inputs which have been received but not yet processed.
|
|
|
|
|
* These are encoded with an OS timestamp, so they
|
|
|
|
|
**/
|
|
|
|
|
var inputPressQueue:Array<PreciseInputEvent> = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Key release inputs which have been received but not yet processed.
|
|
|
|
|
* These are encoded with an OS timestamp, so they
|
|
|
|
|
**/
|
|
|
|
|
var inputReleaseQueue:Array<PreciseInputEvent> = [];
|
|
|
|
|
|
2024-02-28 05:19:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* If we just unpaused the game, we shouldn't be able to pause again for one frame.
|
|
|
|
|
*/
|
|
|
|
|
var justUnpaused:Bool = false;
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* PRIVATE INSTANCE VARIABLES
|
|
|
|
|
* Private instance variables should be used for information that must be reset or dereferenced
|
|
|
|
|
* every time the state is reset, but should not be accessed externally.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* The Array containing the upcoming song events.
|
|
|
|
|
* The `update()` function regularly shifts these out to trigger events.
|
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
|
var songEvents:Array<SongEventData>;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If true, the player is allowed to pause the game.
|
|
|
|
|
* Disabled during the ending of a song.
|
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
|
var mayPauseGame:Bool = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The displayed value of the player's health.
|
|
|
|
|
* Used to provide smooth animations based on linear interpolation of the player's health.
|
|
|
|
|
*/
|
2023-06-27 17:43:42 +00:00
|
|
|
|
var healthLerp:Float = Constants.HEALTH_STARTING;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* How long the user has held the "Skip Video Cutscene" button for.
|
|
|
|
|
*/
|
|
|
|
|
var skipHeldTimer:Float = 0;
|
|
|
|
|
|
2023-12-05 07:44:57 +00:00
|
|
|
|
/**
|
|
|
|
|
* Whether the PlayState was started with instrumentals and vocals already provided.
|
|
|
|
|
* Used by the chart editor to prevent replacing the music.
|
|
|
|
|
*/
|
|
|
|
|
var overrideMusic:Bool = false;
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* Forcibly disables all update logic while the game moves back to the Menu state.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* This is used only when a critical error occurs and the game absolutely cannot continue.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
|
var criticalFailure:Bool = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
|
/**
|
2023-06-02 19:35:01 +00:00
|
|
|
|
* False as long as the countdown has not finished yet.
|
|
|
|
|
*/
|
|
|
|
|
var startingSong:Bool = false;
|
|
|
|
|
|
2024-02-16 12:54:27 +00:00
|
|
|
|
/**
|
2024-03-10 23:35:41 +00:00
|
|
|
|
* Track if we currently have the music paused for a Pause substate, so we can unpause it when we return.
|
2024-02-16 12:54:27 +00:00
|
|
|
|
*/
|
|
|
|
|
var musicPausedBySubState:Bool = false;
|
|
|
|
|
|
2024-03-15 08:52:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* Track any camera tweens we've paused for a Pause substate, so we can unpause them when we return.
|
|
|
|
|
*/
|
|
|
|
|
var cameraTweensPausedBySubState:List<FlxTween> = new List<FlxTween>();
|
2024-03-10 23:35:41 +00:00
|
|
|
|
|
2023-08-09 04:28:09 +00:00
|
|
|
|
/**
|
|
|
|
|
* False until `create()` has completed.
|
|
|
|
|
*/
|
|
|
|
|
var initialized:Bool = false;
|
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* A group of audio tracks, used to play the song's vocals.
|
2023-02-22 01:58:15 +00:00
|
|
|
|
*/
|
2023-08-04 20:15:07 +00:00
|
|
|
|
public var vocals:VoicesGroup;
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Discord RPC variables
|
|
|
|
|
var storyDifficultyText:String = '';
|
|
|
|
|
var iconRPC:String = '';
|
|
|
|
|
var detailsText:String = '';
|
|
|
|
|
var detailsPausedText:String = '';
|
|
|
|
|
#end
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* RENDER OBJECTS
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* The FlxText which displays the current score.
|
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
|
var scoreText:FlxText;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The bar which displays the player's health.
|
|
|
|
|
* Dynamically updated based on the value of `healthLerp` (which is based on `health`).
|
|
|
|
|
*/
|
|
|
|
|
public var healthBar:FlxBar;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The background image used for the health bar.
|
|
|
|
|
* Emma says the image is slightly skewed so I'm leaving it as an image instead of a `createGraphic`.
|
|
|
|
|
*/
|
2024-02-22 23:55:24 +00:00
|
|
|
|
public var healthBarBG:FunkinSprite;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The health icon representing the player.
|
|
|
|
|
*/
|
|
|
|
|
public var iconP1:HealthIcon;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The health icon representing the opponent.
|
|
|
|
|
*/
|
|
|
|
|
public var iconP2:HealthIcon;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The sprite group containing active player's strumline notes.
|
|
|
|
|
*/
|
|
|
|
|
public var playerStrumline:Strumline;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The sprite group containing opponent's strumline notes.
|
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
public var opponentStrumline:Strumline;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The camera which contains, and controls visibility of, the user interface elements.
|
|
|
|
|
*/
|
|
|
|
|
public var camHUD:FlxCamera;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The camera which contains, and controls visibility of, the stage and characters.
|
|
|
|
|
*/
|
2024-02-13 06:38:11 +00:00
|
|
|
|
public var camGame:FlxCamera;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* The camera which contains, and controls visibility of, a video cutscene.
|
|
|
|
|
*/
|
|
|
|
|
public var camCutscene:FlxCamera;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* The combo popups. Includes the real-time combo counter and the rating.
|
|
|
|
|
*/
|
2024-04-09 02:56:28 +00:00
|
|
|
|
public var comboPopUps:PopUpStuff;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* PROPERTIES
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* If a substate is rendering over the PlayState, it is paused and normal update logic is skipped.
|
|
|
|
|
* Examples include:
|
|
|
|
|
* - The Pause screen is open.
|
|
|
|
|
* - The Game Over screen is open.
|
|
|
|
|
* - The Chart Editor screen is open.
|
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
|
var isGamePaused(get, never):Bool;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
function get_isGamePaused():Bool
|
|
|
|
|
{
|
|
|
|
|
// Note: If there is a substate which requires the game to act unpaused,
|
|
|
|
|
// this should be changed to include something like `&& Std.isOfType()`
|
|
|
|
|
return this.subState != null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-13 06:38:11 +00:00
|
|
|
|
var isExitingViaPauseMenu(get, never):Bool;
|
|
|
|
|
|
|
|
|
|
function get_isExitingViaPauseMenu():Bool
|
|
|
|
|
{
|
|
|
|
|
if (this.subState == null) return false;
|
|
|
|
|
if (!Std.isOfType(this.subState, PauseSubState)) return false;
|
|
|
|
|
|
|
|
|
|
var pauseSubState:PauseSubState = cast this.subState;
|
2024-02-28 05:19:08 +00:00
|
|
|
|
return !pauseSubState.allowInput;
|
2024-02-13 06:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Data for the current difficulty for the current song.
|
|
|
|
|
* Includes chart data, scroll speed, and other information.
|
|
|
|
|
*/
|
2023-08-31 22:47:23 +00:00
|
|
|
|
public var currentChart(get, never):SongDifficulty;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function get_currentChart():SongDifficulty
|
|
|
|
|
{
|
|
|
|
|
if (currentSong == null || currentDifficulty == null) return null;
|
2024-02-06 02:35:58 +00:00
|
|
|
|
return currentSong.getDifficulty(currentDifficulty, currentVariation);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* The internal ID of the currently active Stage.
|
|
|
|
|
* Used to retrieve the data required to build the `currentStage`.
|
|
|
|
|
*/
|
2023-08-31 22:47:23 +00:00
|
|
|
|
public var currentStageId(get, never):String;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
function get_currentStageId():String
|
|
|
|
|
{
|
|
|
|
|
if (currentChart == null || currentChart.stage == null || currentChart.stage == '') return Constants.DEFAULT_STAGE;
|
|
|
|
|
return currentChart.stage;
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-02 19:35:01 +00:00
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* The length of the current song, in milliseconds.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var currentSongLengthMs(get, never):Float;
|
|
|
|
|
|
|
|
|
|
function get_currentSongLengthMs():Float
|
|
|
|
|
{
|
|
|
|
|
return FlxG?.sound?.music?.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Refactor or document
|
|
|
|
|
var generatedMusic:Bool = false;
|
|
|
|
|
var perfectMode:Bool = false;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-04-30 11:21:45 +00:00
|
|
|
|
static final BACKGROUND_COLOR:FlxColor = FlxColor.BLACK;
|
2023-11-29 01:36:59 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Instantiate a new PlayState.
|
|
|
|
|
* @param params The parameters used to initialize the PlayState.
|
|
|
|
|
* Includes information about what song to play and more.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public function new(params:PlayStateParams)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-02 19:35:01 +00:00
|
|
|
|
super();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Validate parameters.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
if (params == null && lastParams == null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-02 19:35:01 +00:00
|
|
|
|
throw 'PlayState constructor called with no available parameters.';
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
else if (params == null)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: PlayState constructor called with no parameters. Reusing previous parameters.');
|
|
|
|
|
params = lastParams;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lastParams = params;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Apply parameters.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
currentSong = params.targetSong;
|
|
|
|
|
if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty;
|
2024-02-06 02:35:58 +00:00
|
|
|
|
if (params.targetVariation != null) currentVariation = params.targetVariation;
|
2024-06-07 01:38:00 +00:00
|
|
|
|
if (params.targetInstrumental != null) currentInstrumental = params.targetInstrumental;
|
2023-07-26 20:52:58 +00:00
|
|
|
|
isPracticeMode = params.practiceMode ?? false;
|
2024-03-06 03:27:07 +00:00
|
|
|
|
isBotPlayMode = params.botPlayMode ?? false;
|
2023-07-26 20:52:58 +00:00
|
|
|
|
isMinimalMode = params.minimalMode ?? false;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
startTimestamp = params.startTimestamp ?? 0.0;
|
2024-02-29 23:49:20 +00:00
|
|
|
|
playbackRate = params.playbackRate ?? 1.0;
|
2023-08-04 20:15:07 +00:00
|
|
|
|
overrideMusic = params.overrideMusic ?? false;
|
2024-02-17 04:48:43 +00:00
|
|
|
|
previousCameraFollowPoint = params.cameraFollowPoint;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// Don't do anything else here! Wait until create() when we attach to the camera.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Called when the PlayState is switched to.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
public override function create():Void
|
|
|
|
|
{
|
|
|
|
|
if (instance != null)
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Do something in this case? IDK.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
trace('WARNING: PlayState instance already exists. This should not happen.');
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
instance = this;
|
|
|
|
|
|
2023-10-09 18:13:14 +00:00
|
|
|
|
if (!assertChartExists()) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-22 23:55:24 +00:00
|
|
|
|
// TODO: Add something to toggle this on!
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (false)
|
|
|
|
|
{
|
|
|
|
|
// Displays the camera follow point as a sprite for debug purposes.
|
2024-02-22 23:55:24 +00:00
|
|
|
|
var cameraFollowPoint = new FunkinSprite(0, 0);
|
|
|
|
|
cameraFollowPoint.makeSolidColor(8, 8, 0xFF00FF00);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
cameraFollowPoint.visible = false;
|
|
|
|
|
cameraFollowPoint.zIndex = 1000000;
|
2024-02-22 23:55:24 +00:00
|
|
|
|
this.cameraFollowPoint = cameraFollowPoint;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Camera follow point is an invisible point in space.
|
|
|
|
|
cameraFollowPoint = new FlxObject(0, 0);
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
// Reduce physics accuracy (who cares!!!) to improve animation quality.
|
|
|
|
|
FlxG.fixedTimestep = false;
|
|
|
|
|
|
|
|
|
|
// This state receives update() even when a substate is active.
|
|
|
|
|
this.persistentUpdate = true;
|
|
|
|
|
// This state receives draw calls even when a substate is active.
|
|
|
|
|
this.persistentDraw = true;
|
|
|
|
|
|
|
|
|
|
// Stop any pre-existing music.
|
2023-08-04 20:15:07 +00:00
|
|
|
|
if (!overrideMusic && FlxG.sound.music != null) FlxG.sound.music.stop();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Prepare the current song's instrumental and vocals to be played.
|
2023-08-04 20:15:07 +00:00
|
|
|
|
if (!overrideMusic && currentChart != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-09-26 03:24:07 +00:00
|
|
|
|
currentChart.cacheInst();
|
|
|
|
|
currentChart.cacheVocals();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Prepare the Conductor.
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.forceBPM(null);
|
2023-12-08 06:57:46 +00:00
|
|
|
|
|
|
|
|
|
if (currentChart.offsets != null)
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.instrumentalOffset = currentChart.offsets.getInstrumentalOffset();
|
2023-12-08 06:57:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.mapTimeChanges(currentChart.timeChanges);
|
|
|
|
|
Conductor.instance.update((Conductor.instance.beatLengthMs * -5) + startTimestamp);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// The song is now loaded. We can continue to initialize the play state.
|
|
|
|
|
initCameras();
|
|
|
|
|
initHealthBar();
|
2023-07-26 20:52:58 +00:00
|
|
|
|
if (!isMinimalMode)
|
|
|
|
|
{
|
|
|
|
|
initStage();
|
|
|
|
|
initCharacters();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
initMinimalMode();
|
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
initStrumlines();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Initialize the judgements and combo meter.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
comboPopUps = new PopUpStuff();
|
2024-02-29 02:19:21 +00:00
|
|
|
|
comboPopUps.zIndex = 900;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
add(comboPopUps);
|
2024-02-29 02:19:21 +00:00
|
|
|
|
comboPopUps.cameras = [camHUD];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Initialize Discord Rich Presence.
|
|
|
|
|
initDiscord();
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Read the song's note data and pass it to the strumlines.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
generateSong();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Reset the camera's zoom and force it to focus on the camera follow point.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
resetCamera();
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
initPreciseInputs();
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// The song is loaded and in the process of starting.
|
|
|
|
|
// This gets set back to false when the chart actually starts.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
startingSong = true;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: We hardcoded the transition into Winter Horrorland. Do this with a ScriptedSong instead.
|
2023-09-08 21:46:44 +00:00
|
|
|
|
if ((currentSong?.id ?? '').toLowerCase() == 'winter-horrorland')
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// VanillaCutscenes will call startCountdown later.
|
|
|
|
|
VanillaCutscenes.playHorrorStartCutscene();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Call a script event to start the countdown.
|
|
|
|
|
// Songs with cutscenes should call event.cancel().
|
|
|
|
|
// As long as they call `PlayState.instance.startCountdown()` later, the countdown will start.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
startCountdown();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-02 22:08:49 +00:00
|
|
|
|
// Do this last to prevent beatHit from being called before create() is done.
|
|
|
|
|
super.create();
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
leftWatermarkText.cameras = [camHUD];
|
|
|
|
|
rightWatermarkText.cameras = [camHUD];
|
|
|
|
|
|
|
|
|
|
// Initialize some debug stuff.
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Display the version number (and git commit hash) in the bottom right corner.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
this.rightWatermarkText.text = Constants.VERSION;
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
|
|
|
|
FlxG.console.registerObject('playState', this);
|
|
|
|
|
#end
|
2023-08-09 04:28:09 +00:00
|
|
|
|
|
|
|
|
|
initialized = true;
|
2024-04-01 17:05:16 +00:00
|
|
|
|
|
|
|
|
|
// This step ensures z-indexes are applied properly,
|
|
|
|
|
// and it's important to call it last so all elements get affected.
|
|
|
|
|
refresh();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 01:36:59 +00:00
|
|
|
|
public override function draw():Void
|
|
|
|
|
{
|
|
|
|
|
// if (FlxG.renderBlit)
|
|
|
|
|
// {
|
|
|
|
|
// camGame.fill(BACKGROUND_COLOR);
|
|
|
|
|
// }
|
|
|
|
|
// else if (FlxG.renderTile)
|
|
|
|
|
// {
|
|
|
|
|
// FlxG.log.warn("PlayState background not displayed properly on tile renderer!");
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// FlxG.log.warn("PlayState background not displayed properly, unknown renderer!");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
super.draw();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 18:13:14 +00:00
|
|
|
|
function assertChartExists():Bool
|
|
|
|
|
{
|
|
|
|
|
// Returns null if the song failed to load or doesn't have the selected difficulty.
|
2024-02-17 03:01:47 +00:00
|
|
|
|
if (currentSong == null || currentChart == null || currentChart.notes == null)
|
2023-10-09 18:13:14 +00:00
|
|
|
|
{
|
|
|
|
|
// We have encountered a critical error. Prevent Flixel from trying to run any gameplay logic.
|
|
|
|
|
criticalFailure = true;
|
|
|
|
|
|
|
|
|
|
// Choose an error message.
|
|
|
|
|
var message:String = 'There was a critical error. Click OK to return to the main menu.';
|
|
|
|
|
if (currentSong == null)
|
|
|
|
|
{
|
2024-05-20 14:42:17 +00:00
|
|
|
|
message = 'There was a critical error loading this song\'s chart. Click OK to return to the main menu.';
|
2023-10-09 18:13:14 +00:00
|
|
|
|
}
|
|
|
|
|
else if (currentDifficulty == null)
|
|
|
|
|
{
|
2024-05-20 14:42:17 +00:00
|
|
|
|
message = 'There was a critical error selecting a difficulty for this song. Click OK to return to the main menu.';
|
2023-10-09 18:13:14 +00:00
|
|
|
|
}
|
2024-02-06 00:46:11 +00:00
|
|
|
|
else if (currentChart == null)
|
2023-10-09 18:13:14 +00:00
|
|
|
|
{
|
2024-05-20 14:42:17 +00:00
|
|
|
|
message = 'There was a critical error retrieving data for this song on "$currentDifficulty" difficulty with variation "$currentVariation". Click OK to return to the main menu.';
|
2023-10-09 18:13:14 +00:00
|
|
|
|
}
|
2024-02-17 03:01:47 +00:00
|
|
|
|
else if (currentChart.notes == null)
|
|
|
|
|
{
|
2024-05-20 14:42:17 +00:00
|
|
|
|
message = 'There was a critical error retrieving note data for this song on "$currentDifficulty" difficulty with variation "$currentVariation". Click OK to return to the main menu.';
|
2024-02-17 03:01:47 +00:00
|
|
|
|
}
|
2023-10-09 18:13:14 +00:00
|
|
|
|
|
|
|
|
|
// Display a popup. This blocks the application until the user clicks OK.
|
|
|
|
|
lime.app.Application.current.window.alert(message, 'Error loading PlayState');
|
|
|
|
|
|
|
|
|
|
// Force the user back to the main menu.
|
|
|
|
|
if (isSubState)
|
|
|
|
|
{
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-06 00:46:11 +00:00
|
|
|
|
FlxG.switchState(() -> new MainMenuState());
|
2023-10-09 18:13:14 +00:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
public override function update(elapsed:Float):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-28 05:19:08 +00:00
|
|
|
|
// TOTAL: 9.42% CPU Time when profiled in VS 2019.
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (criticalFailure) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
super.update(elapsed);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-04-20 06:11:04 +00:00
|
|
|
|
var list = FlxG.sound.list;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
updateHealthBar();
|
|
|
|
|
updateScoreText();
|
|
|
|
|
|
|
|
|
|
// Handle restarting the song when needed (player death or pressing Retry)
|
|
|
|
|
if (needsReset)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-10-09 18:13:14 +00:00
|
|
|
|
if (!assertChartExists()) return;
|
|
|
|
|
|
2024-05-15 16:24:04 +00:00
|
|
|
|
prevScrollTargets = [];
|
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
|
dispatchEvent(new ScriptEvent(SONG_RETRY));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
resetCamera();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-05-09 05:10:53 +00:00
|
|
|
|
var fromDeathState = isPlayerDying;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
persistentUpdate = true;
|
|
|
|
|
persistentDraw = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
startingSong = true;
|
2024-03-04 21:37:42 +00:00
|
|
|
|
isPlayerDying = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
inputSpitter = [];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Reset music properly.
|
2024-04-07 01:42:18 +00:00
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset;
|
|
|
|
|
FlxG.sound.music.pitch = playbackRate;
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
}
|
2023-10-09 18:19:52 +00:00
|
|
|
|
|
2023-10-18 05:02:10 +00:00
|
|
|
|
if (!overrideMusic)
|
|
|
|
|
{
|
2023-11-09 22:00:46 +00:00
|
|
|
|
// Stop the vocals if they already exist.
|
|
|
|
|
if (vocals != null) vocals.stop();
|
2023-10-18 05:02:10 +00:00
|
|
|
|
vocals = currentChart.buildVocals();
|
|
|
|
|
|
|
|
|
|
if (vocals.members.length == 0)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: No vocals found for this song.');
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-09 18:19:52 +00:00
|
|
|
|
vocals.pause();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
vocals.time = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-04-07 01:42:18 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.volume = 1;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
vocals.volume = 1;
|
|
|
|
|
vocals.playerVolume = 1;
|
|
|
|
|
vocals.opponentVolume = 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-27 01:34:38 +00:00
|
|
|
|
if (currentStage != null) currentStage.resetStage();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
2024-05-09 05:10:53 +00:00
|
|
|
|
if (!fromDeathState)
|
|
|
|
|
{
|
|
|
|
|
playerStrumline.vwooshNotes();
|
|
|
|
|
opponentStrumline.vwooshNotes();
|
|
|
|
|
}
|
2023-07-31 17:42:13 +00:00
|
|
|
|
|
2023-07-26 01:39:19 +00:00
|
|
|
|
playerStrumline.clean();
|
|
|
|
|
opponentStrumline.clean();
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Delete all notes and reset the arrays.
|
|
|
|
|
regenNoteData();
|
|
|
|
|
|
|
|
|
|
// Reset camera zooming
|
2024-03-28 18:05:38 +00:00
|
|
|
|
cameraBopIntensity = Constants.DEFAULT_BOP_INTENSITY;
|
2024-04-05 06:44:44 +00:00
|
|
|
|
hudCameraZoomIntensity = (cameraBopIntensity - 1.0) * 2.0;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
cameraZoomRate = Constants.DEFAULT_ZOOM_RATE;
|
|
|
|
|
|
2023-06-27 17:43:42 +00:00
|
|
|
|
health = Constants.HEALTH_STARTING;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
songScore = 0;
|
|
|
|
|
Highscore.tallies.combo = 0;
|
|
|
|
|
Countdown.performCountdown(currentStageId.startsWith('school'));
|
|
|
|
|
|
|
|
|
|
needsReset = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the conductor.
|
|
|
|
|
if (startingSong)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (isInCountdown)
|
|
|
|
|
{
|
2024-04-11 01:31:49 +00:00
|
|
|
|
// Do NOT apply offsets at this point, because they already got applied the previous frame!
|
|
|
|
|
Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false);
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.songPosition >= (startTimestamp)) startSong();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-05 07:44:57 +00:00
|
|
|
|
if (Constants.EXT_SOUND == 'mp3')
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.formatOffset = Constants.MP3_DELAY_MS;
|
2023-12-05 07:44:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.formatOffset = 0.0;
|
2023-12-05 07:44:57 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
Conductor.instance.update(); // Normal conductor update.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var androidPause:Bool = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if android
|
|
|
|
|
androidPause = FlxG.android.justPressed.BACK;
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Attempt to pause the game.
|
2024-02-28 05:19:08 +00:00
|
|
|
|
if ((controls.PAUSE || androidPause) && isInCountdown && mayPauseGame && !justUnpaused)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var event = new PauseScriptEvent(FlxG.random.bool(1 / 1000));
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
dispatchEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (!event.eventCanceled)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Pause updates while the substate is open, preventing the game state from advancing.
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
// Enable drawing while the substate is open, allowing the game state to be shown behind the pause menu.
|
|
|
|
|
persistentDraw = true;
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// There is a 1/1000 change to use a special pause menu.
|
|
|
|
|
// This prevents the player from resuming, but that's the point.
|
|
|
|
|
// It's a reference to Gitaroo Man, which doesn't let you pause the game.
|
2023-07-26 20:52:58 +00:00
|
|
|
|
if (!isSubState && event.gitaroo)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-02-06 00:46:11 +00:00
|
|
|
|
FlxG.switchState(() -> new GitarooPause(
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
targetSong: currentSong,
|
|
|
|
|
targetDifficulty: currentDifficulty,
|
2024-02-06 02:35:58 +00:00
|
|
|
|
targetVariation: currentVariation,
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var boyfriendPos:FlxPoint = new FlxPoint(0, 0);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Prevent the game from crashing if Boyfriend isn't present.
|
|
|
|
|
if (currentStage != null && currentStage.getBoyfriend() != null)
|
|
|
|
|
{
|
|
|
|
|
boyfriendPos = currentStage.getBoyfriend().getScreenPosition();
|
|
|
|
|
}
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2024-02-28 05:19:08 +00:00
|
|
|
|
var pauseSubState:FlxSubState = new PauseSubState({mode: isChartingMode ? Charting : Standard});
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
pauseSubState.camera = camHUD;
|
2024-02-28 05:19:08 +00:00
|
|
|
|
openSubState(pauseSubState);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// boyfriendPos.put(); // TODO: Why is this here?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
DiscordClient.changePresence(detailsPausedText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-02-22 01:58:15 +00:00
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Cap health.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (health > Constants.HEALTH_MAX) health = Constants.HEALTH_MAX;
|
|
|
|
|
if (health < Constants.HEALTH_MIN) health = Constants.HEALTH_MIN;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Apply camera zoom + multipliers.
|
2024-04-20 06:11:04 +00:00
|
|
|
|
if (subState == null && cameraZoomRate > 0.0) // && !isInCutscene)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-03-28 18:05:38 +00:00
|
|
|
|
cameraBopMultiplier = FlxMath.lerp(1.0, cameraBopMultiplier, 0.95); // Lerp bop multiplier back to 1.0x
|
|
|
|
|
var zoomPlusBop = currentCameraZoom * cameraBopMultiplier; // Apply camera bop multiplier.
|
|
|
|
|
FlxG.camera.zoom = zoomPlusBop; // Actually apply the zoom to the camera.
|
2024-03-16 15:38:10 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
camHUD.zoom = FlxMath.lerp(defaultHUDCameraZoom, camHUD.zoom, 0.95);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-01 13:13:06 +00:00
|
|
|
|
if (currentStage != null && currentStage.getBoyfriend() != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.watch.addQuick('bfAnim', currentStage.getBoyfriend().getCurrentAnimation());
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2024-02-15 22:25:28 +00:00
|
|
|
|
FlxG.watch.addQuick('health', health);
|
2024-04-05 06:44:44 +00:00
|
|
|
|
FlxG.watch.addQuick('cameraBopIntensity', cameraBopIntensity);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Add a song event for Handle GF dance speed.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Handle player death.
|
2024-02-13 07:09:25 +00:00
|
|
|
|
if (!isInCutscene && !disableKeys)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
// RESET = Quick Game Over Screen
|
|
|
|
|
if (controls.RESET)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-27 17:43:42 +00:00
|
|
|
|
health = Constants.HEALTH_MIN;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('RESET = True');
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if CAN_CHEAT // brandon's a pussy
|
|
|
|
|
if (controls.CHEAT)
|
|
|
|
|
{
|
2023-06-27 17:43:42 +00:00
|
|
|
|
health += 0.25 * Constants.HEALTH_MAX; // +25% health.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('User is cheating!');
|
|
|
|
|
}
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-04 21:37:42 +00:00
|
|
|
|
if (health <= Constants.HEALTH_MIN && !isPracticeMode && !isPlayerDying)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
vocals.pause();
|
2024-05-01 03:24:43 +00:00
|
|
|
|
|
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.pause();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
deathCounter += 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
|
dispatchEvent(new ScriptEvent(GAME_OVER));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Disable updates, preventing animations in the background from playing.
|
|
|
|
|
persistentUpdate = false;
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (FlxG.keys.pressed.THREE)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Change the key or delete this?
|
|
|
|
|
// In debug builds, pressing 3 to kill the player makes the background transparent.
|
|
|
|
|
persistentDraw = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#end
|
|
|
|
|
persistentDraw = false;
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
#end
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2024-03-04 21:37:42 +00:00
|
|
|
|
isPlayerDying = true;
|
|
|
|
|
|
|
|
|
|
var deathPreTransitionDelay = currentStage?.getBoyfriend()?.getDeathPreTransitionDelay() ?? 0.0;
|
|
|
|
|
if (deathPreTransitionDelay > 0)
|
|
|
|
|
{
|
|
|
|
|
new FlxTimer().start(deathPreTransitionDelay, function(_) {
|
|
|
|
|
moveToGameOver();
|
2023-12-19 06:27:58 +00:00
|
|
|
|
});
|
2024-03-04 21:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Transition immediately.
|
|
|
|
|
moveToGameOver();
|
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Game Over doesn't get his own variable because it's only used here
|
|
|
|
|
DiscordClient.changePresence('Game Over - ' + detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
|
|
|
|
#end
|
|
|
|
|
}
|
2024-03-04 21:37:42 +00:00
|
|
|
|
else if (isPlayerDying)
|
|
|
|
|
{
|
|
|
|
|
// Wait up.
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
processSongEvents();
|
|
|
|
|
|
|
|
|
|
// Handle keybinds.
|
|
|
|
|
processInputQueue();
|
|
|
|
|
if (!isInCutscene && !disableKeys) debugKeyShit();
|
|
|
|
|
if (isInCutscene && !disableKeys) handleCutsceneKeys(elapsed);
|
|
|
|
|
|
|
|
|
|
// Moving notes into position is now done by Strumline.update().
|
2024-03-06 22:22:11 +00:00
|
|
|
|
if (!isInCutscene) processNotes(elapsed);
|
2024-02-28 08:04:56 +00:00
|
|
|
|
|
|
|
|
|
justUnpaused = false;
|
2024-02-27 00:03:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-04 21:37:42 +00:00
|
|
|
|
function moveToGameOver():Void
|
|
|
|
|
{
|
2024-05-09 05:10:53 +00:00
|
|
|
|
// Reset and update a bunch of values in advance for the transition back from the game over substate.
|
|
|
|
|
playerStrumline.clean();
|
|
|
|
|
opponentStrumline.clean();
|
|
|
|
|
|
|
|
|
|
songScore = 0;
|
|
|
|
|
updateScoreText();
|
|
|
|
|
|
|
|
|
|
health = Constants.HEALTH_STARTING;
|
|
|
|
|
healthLerp = health;
|
|
|
|
|
|
|
|
|
|
healthBar.value = healthLerp;
|
|
|
|
|
|
2024-05-15 20:50:34 +00:00
|
|
|
|
if (!isMinimalMode)
|
|
|
|
|
{
|
|
|
|
|
iconP1.updatePosition();
|
|
|
|
|
iconP2.updatePosition();
|
|
|
|
|
}
|
2024-05-09 05:10:53 +00:00
|
|
|
|
|
|
|
|
|
// Transition to the game over substate.
|
2024-03-04 21:37:42 +00:00
|
|
|
|
var gameOverSubState = new GameOverSubState(
|
|
|
|
|
{
|
|
|
|
|
isChartingMode: isChartingMode,
|
|
|
|
|
transparent: persistentDraw
|
|
|
|
|
});
|
2024-03-17 02:20:22 +00:00
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2024-03-04 21:37:42 +00:00
|
|
|
|
openSubState(gameOverSubState);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
function processSongEvents():Void
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Query and activate song events.
|
2024-02-27 00:03:04 +00:00
|
|
|
|
// TODO: Check that these work appropriately even when songPosition is less than 0, to play events during countdown.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (songEvents != null && songEvents.length > 0)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-01-06 01:11:38 +00:00
|
|
|
|
var songEventsToActivate:Array<SongEventData> = SongEventRegistry.queryEvents(songEvents, Conductor.instance.songPosition);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (songEventsToActivate.length > 0)
|
|
|
|
|
{
|
|
|
|
|
trace('Found ${songEventsToActivate.length} event(s) to activate.');
|
|
|
|
|
for (event in songEventsToActivate)
|
|
|
|
|
{
|
2024-02-27 00:03:04 +00:00
|
|
|
|
// If an event is trying to play, but it's over 1 second old, skip it.
|
|
|
|
|
var eventAge:Float = Conductor.instance.songPosition - event.time;
|
|
|
|
|
if (eventAge > 1000)
|
2023-07-27 01:34:38 +00:00
|
|
|
|
{
|
|
|
|
|
event.activated = true;
|
|
|
|
|
continue;
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var eventEvent:SongEventScriptEvent = new SongEventScriptEvent(event);
|
|
|
|
|
dispatchEvent(eventEvent);
|
|
|
|
|
// Calling event.cancelEvent() skips the event. Neat!
|
|
|
|
|
if (!eventEvent.eventCanceled)
|
|
|
|
|
{
|
2024-01-04 02:10:14 +00:00
|
|
|
|
SongEventRegistry.handleEvent(event);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
public override function dispatchEvent(event:ScriptEvent):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// ORDER: Module, Stage, Character, Song, Conversation, Note
|
|
|
|
|
// Modules should get the first chance to cancel the event.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// super.dispatchEvent(event) dispatches event to module scripts.
|
|
|
|
|
super.dispatchEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Dispatch event to stage script.
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Dispatch event to character script(s).
|
|
|
|
|
if (currentStage != null) currentStage.dispatchToCharacters(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Dispatch event to song script.
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentSong, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Dispatch event to conversation script.
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentConversation, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-06-01 16:25:46 +00:00
|
|
|
|
// Dispatch event to note kind scripts
|
|
|
|
|
NoteKindManager.callEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function called before opening a new substate.
|
|
|
|
|
* @param subState The substate to open.
|
|
|
|
|
*/
|
|
|
|
|
public override function openSubState(subState:FlxSubState):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// If there is a substate which requires the game to continue,
|
|
|
|
|
// then make this a condition.
|
2023-08-04 21:25:13 +00:00
|
|
|
|
var shouldPause = (Std.isOfType(subState, PauseSubState) || Std.isOfType(subState, GameOverSubState));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (shouldPause)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Pause the music.
|
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
2024-03-10 23:35:41 +00:00
|
|
|
|
if (FlxG.sound.music.playing)
|
2024-02-28 08:01:20 +00:00
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.pause();
|
2024-03-10 23:35:41 +00:00
|
|
|
|
musicPausedBySubState = true;
|
2024-02-28 08:01:20 +00:00
|
|
|
|
}
|
2024-03-10 23:35:41 +00:00
|
|
|
|
|
|
|
|
|
// Pause vocals.
|
|
|
|
|
// Not tracking that we've done this via a bool because vocal re-syncing involves pausing the vocals anyway.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (vocals != null) vocals.pause();
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-15 08:52:22 +00:00
|
|
|
|
// Pause camera tweening, and keep track of which tweens we pause.
|
2024-03-10 23:35:41 +00:00
|
|
|
|
if (cameraFollowTween != null && cameraFollowTween.active)
|
|
|
|
|
{
|
|
|
|
|
cameraFollowTween.active = false;
|
2024-03-15 08:52:22 +00:00
|
|
|
|
cameraTweensPausedBySubState.add(cameraFollowTween);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cameraZoomTween != null && cameraZoomTween.active)
|
|
|
|
|
{
|
|
|
|
|
cameraZoomTween.active = false;
|
|
|
|
|
cameraTweensPausedBySubState.add(cameraZoomTween);
|
2024-03-10 23:35:41 +00:00
|
|
|
|
}
|
2024-05-10 20:23:35 +00:00
|
|
|
|
|
2024-06-08 00:26:17 +00:00
|
|
|
|
// Pause camera follow
|
|
|
|
|
FlxG.camera.followLerp = 0;
|
|
|
|
|
|
2024-05-10 20:23:35 +00:00
|
|
|
|
for (tween in scrollSpeedTweens)
|
2024-05-09 16:51:03 +00:00
|
|
|
|
{
|
2024-05-10 20:23:35 +00:00
|
|
|
|
if (tween != null && tween.active)
|
|
|
|
|
{
|
|
|
|
|
tween.active = false;
|
|
|
|
|
cameraTweensPausedBySubState.add(tween);
|
|
|
|
|
}
|
2024-05-09 16:51:03 +00:00
|
|
|
|
}
|
2024-03-10 23:35:41 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Pause the countdown.
|
|
|
|
|
Countdown.pauseCountdown();
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
super.openSubState(subState);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function called before closing the current substate.
|
|
|
|
|
* @param subState
|
|
|
|
|
*/
|
|
|
|
|
public override function closeSubState():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-08-04 20:15:07 +00:00
|
|
|
|
if (Std.isOfType(subState, PauseSubState))
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2023-10-26 09:46:22 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(RESUME, true);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
dispatchEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-10 23:35:41 +00:00
|
|
|
|
// Resume music if we paused it.
|
2024-02-16 12:54:27 +00:00
|
|
|
|
if (musicPausedBySubState)
|
|
|
|
|
{
|
2024-02-28 08:01:20 +00:00
|
|
|
|
FlxG.sound.music.play();
|
2024-03-10 23:35:41 +00:00
|
|
|
|
musicPausedBySubState = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 08:52:22 +00:00
|
|
|
|
// Resume camera tweens if we paused any.
|
|
|
|
|
for (camTween in cameraTweensPausedBySubState)
|
2024-03-10 23:35:41 +00:00
|
|
|
|
{
|
2024-03-15 08:52:22 +00:00
|
|
|
|
camTween.active = true;
|
2024-02-16 12:54:27 +00:00
|
|
|
|
}
|
2024-03-15 08:52:22 +00:00
|
|
|
|
cameraTweensPausedBySubState.clear();
|
2023-08-02 22:08:49 +00:00
|
|
|
|
|
2024-06-08 00:26:17 +00:00
|
|
|
|
// Resume camera follow
|
|
|
|
|
FlxG.camera.followLerp = Constants.DEFAULT_CAMERA_FOLLOW_RATE;
|
|
|
|
|
|
2024-02-28 19:51:39 +00:00
|
|
|
|
if (currentConversation != null)
|
|
|
|
|
{
|
|
|
|
|
currentConversation.resumeMusic();
|
2024-02-16 12:54:27 +00:00
|
|
|
|
}
|
2023-08-02 22:08:49 +00:00
|
|
|
|
|
2024-03-10 23:35:41 +00:00
|
|
|
|
// Re-sync vocals.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (FlxG.sound.music != null && !startingSong && !isInCutscene) resyncVocals();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Resume the countdown.
|
|
|
|
|
Countdown.resumeCountdown();
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if discord_rpc
|
|
|
|
|
if (startTimer.finished)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true,
|
2023-12-14 21:56:20 +00:00
|
|
|
|
currentSongLengthMs - Conductor.instance.songPosition);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#end
|
2024-02-28 05:19:08 +00:00
|
|
|
|
|
|
|
|
|
justUnpaused = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-08-04 20:15:07 +00:00
|
|
|
|
else if (Std.isOfType(subState, Transition))
|
|
|
|
|
{
|
|
|
|
|
// Do nothing.
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
super.closeSubState();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function called when the game window gains focus.
|
|
|
|
|
*/
|
|
|
|
|
public override function onFocus():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-06-24 08:55:59 +00:00
|
|
|
|
if (VideoCutscene.isPlaying() && FlxG.autoPause && isGamePaused) VideoCutscene.pauseVideo();
|
|
|
|
|
#if html5
|
|
|
|
|
else
|
|
|
|
|
VideoCutscene.resumeVideo();
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song
|
2023-06-22 05:41:01 +00:00
|
|
|
|
+ ' ('
|
|
|
|
|
+ storyDifficultyText
|
|
|
|
|
+ ')', iconRPC, true,
|
|
|
|
|
currentSongLengthMs
|
2023-12-14 21:56:20 +00:00
|
|
|
|
- Conductor.instance.songPosition);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
else
|
2023-06-02 19:35:01 +00:00
|
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2024-06-24 08:55:59 +00:00
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
super.onFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function called when the game window loses focus.
|
|
|
|
|
*/
|
|
|
|
|
public override function onFocusLost():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-06-24 08:55:59 +00:00
|
|
|
|
#if html5
|
|
|
|
|
if (FlxG.autoPause) VideoCutscene.pauseVideo();
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause) DiscordClient.changePresence(detailsPausedText,
|
|
|
|
|
currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2024-06-24 08:55:59 +00:00
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
super.onFocusLost();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes any references to the current stage, then clears the stage cache,
|
|
|
|
|
* then reloads all the stages.
|
2023-06-08 20:30:45 +00:00
|
|
|
|
*
|
2023-01-23 00:55:30 +00:00
|
|
|
|
* This is useful for when you want to edit a stage without reloading the whole game.
|
|
|
|
|
* Reloading works on both the JSON and the HXC, if applicable.
|
2023-06-08 20:30:45 +00:00
|
|
|
|
*
|
2023-01-23 00:55:30 +00:00
|
|
|
|
* Call this by pressing F5 on a debug build.
|
|
|
|
|
*/
|
2023-06-02 19:35:01 +00:00
|
|
|
|
override function debug_refreshModules():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-07-14 00:27:45 +00:00
|
|
|
|
// Prevent further gameplay updates, which will try to reference dead objects.
|
|
|
|
|
criticalFailure = true;
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
// Remove the current stage. If the stage gets deleted while it's still in use,
|
|
|
|
|
// it'll probably crash the game or something.
|
|
|
|
|
if (this.currentStage != null)
|
|
|
|
|
{
|
|
|
|
|
remove(currentStage);
|
2023-10-26 09:46:22 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(DESTROY, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
|
currentStage = null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-23 21:50:48 +00:00
|
|
|
|
if (!overrideMusic)
|
2023-07-14 00:27:45 +00:00
|
|
|
|
{
|
2024-03-23 21:50:48 +00:00
|
|
|
|
// Stop the instrumental.
|
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.destroy();
|
|
|
|
|
FlxG.sound.music = null;
|
|
|
|
|
}
|
2023-07-14 00:27:45 +00:00
|
|
|
|
|
2024-03-23 21:50:48 +00:00
|
|
|
|
// Stop the vocals.
|
|
|
|
|
if (vocals != null && vocals.exists)
|
|
|
|
|
{
|
|
|
|
|
vocals.destroy();
|
|
|
|
|
vocals = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-03-23 21:50:48 +00:00
|
|
|
|
// Stop the instrumental.
|
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stop the vocals.
|
|
|
|
|
if (vocals != null && vocals.exists)
|
|
|
|
|
{
|
|
|
|
|
vocals.stop();
|
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
super.debug_refreshModules();
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(CREATE, false);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
ScriptEventDispatcher.callEvent(currentSong, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
override function stepHit():Bool
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-08-09 04:28:09 +00:00
|
|
|
|
if (criticalFailure || !initialized) return false;
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// super.stepHit() returns false if a module cancelled the event.
|
|
|
|
|
if (!super.stepHit()) return false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-08-03 15:40:19 +00:00
|
|
|
|
if (isGamePaused) return false;
|
|
|
|
|
|
2023-07-27 00:03:31 +00:00
|
|
|
|
if (!startingSong
|
|
|
|
|
&& FlxG.sound.music != null
|
2023-12-14 21:56:20 +00:00
|
|
|
|
&& (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200
|
|
|
|
|
|| Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200))
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace("VOCALS NEED RESYNC");
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
|
|
|
|
|
trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
|
2023-06-22 05:41:01 +00:00
|
|
|
|
resyncVocals();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (iconP1 != null) iconP1.onStepHit(Std.int(Conductor.instance.currentStep));
|
|
|
|
|
if (iconP2 != null) iconP2.onStepHit(Std.int(Conductor.instance.currentStep));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
return true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
override function beatHit():Bool
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-08-09 04:28:09 +00:00
|
|
|
|
if (criticalFailure || !initialized) return false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// super.beatHit() returns false if a module cancelled the event.
|
|
|
|
|
if (!super.beatHit()) return false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-08-03 15:40:19 +00:00
|
|
|
|
if (isGamePaused) return false;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (generatedMusic)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Sort more efficiently, or less often, to improve performance.
|
|
|
|
|
// activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Only bop camera if zoom level is below 135%
|
2024-03-24 03:52:08 +00:00
|
|
|
|
if (Preferences.zoomCamera
|
2024-03-28 18:05:38 +00:00
|
|
|
|
&& FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom)
|
2024-03-24 03:52:08 +00:00
|
|
|
|
&& cameraZoomRate > 0
|
|
|
|
|
&& Conductor.instance.currentBeat % cameraZoomRate == 0)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Set zoom multiplier for camera bop.
|
|
|
|
|
cameraBopMultiplier = cameraBopIntensity;
|
|
|
|
|
// HUD camera zoom still uses old system. To change. (+3%)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-12-14 21:56:20 +00:00
|
|
|
|
// trace('Not bopping camera: ${FlxG.camera.zoom} < ${(1.35 * defaultCameraZoom)} && ${cameraZoomRate} > 0 && ${Conductor.instance.currentBeat} % ${cameraZoomRate} == ${Conductor.instance.currentBeat % cameraZoomRate}}');
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// That combo milestones that got spoiled that one time.
|
|
|
|
|
// Comes with NEAT visual and audio effects.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// bruh this var is bonkers i thot it was a function lmfaooo
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Break up into individual lines to aid debugging.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var shouldShowComboText:Bool = false;
|
|
|
|
|
// TODO: Re-enable combo text (how to do this without sections?).
|
|
|
|
|
// if (currentSong != null)
|
|
|
|
|
// {
|
2023-12-14 21:56:20 +00:00
|
|
|
|
// shouldShowComboText = (Conductor.instance.currentBeat % 8 == 7);
|
|
|
|
|
// var daSection = .getSong()[Std.int(Conductor.instance.currentBeat / 16)];
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection);
|
|
|
|
|
// shouldShowComboText = shouldShowComboText && (Highscore.tallies.combo > 5);
|
|
|
|
|
//
|
2023-12-14 21:56:20 +00:00
|
|
|
|
// var daNextSection = .getSong()[Std.int(Conductor.instance.currentBeat / 16) + 1];
|
|
|
|
|
// var isEndOfSong = .getSong().length < Std.int(Conductor.instance.currentBeat / 16);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection));
|
|
|
|
|
// }
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (shouldShowComboText)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var animShit:ComboMilestone = new ComboMilestone(-100, 300, Highscore.tallies.combo);
|
|
|
|
|
animShit.scrollFactor.set(0.6, 0.6);
|
2024-02-29 02:19:21 +00:00
|
|
|
|
animShit.zIndex = 1100;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
animShit.cameras = [camHUD];
|
|
|
|
|
add(animShit);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
new FlxTimer().start(((Conductor.instance.beatLengthMs / 1000) * 1.25) - frameShit, function(tmr) {
|
2023-06-22 05:41:01 +00:00
|
|
|
|
animShit.forceFinish();
|
|
|
|
|
});
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (playerStrumline != null) playerStrumline.onBeatHit();
|
|
|
|
|
if (opponentStrumline != null) opponentStrumline.onBeatHit();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Make the characters dance on the beat
|
|
|
|
|
danceOnBeat();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
return true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-16 02:09:01 +00:00
|
|
|
|
public override function destroy():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-12-16 02:09:01 +00:00
|
|
|
|
performCleanup();
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
super.destroy();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handles characters dancing to the beat of the current song.
|
|
|
|
|
*
|
|
|
|
|
* TODO: Move some of this logic into `Bopper.hx`, or individual character scripts.
|
|
|
|
|
*/
|
|
|
|
|
function danceOnBeat():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-05-03 03:06:01 +00:00
|
|
|
|
if (currentStage == null) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Add HEY! song events to Tutorial.
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.currentBeat % 16 == 15
|
2023-06-22 05:41:01 +00:00
|
|
|
|
&& currentStage.getDad().characterId == 'gf'
|
2023-12-14 21:56:20 +00:00
|
|
|
|
&& Conductor.instance.currentBeat > 16
|
|
|
|
|
&& Conductor.instance.currentBeat < 48)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
currentStage.getBoyfriend().playAnimation('hey', true);
|
|
|
|
|
currentStage.getDad().playAnimation('cheer', true);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initializes the game and HUD cameras.
|
|
|
|
|
*/
|
|
|
|
|
function initCameras():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-04-10 18:45:07 +00:00
|
|
|
|
camGame = new FunkinCamera('playStateCamGame');
|
2023-11-29 01:36:59 +00:00
|
|
|
|
camGame.bgColor = BACKGROUND_COLOR; // Show a pink background behind the stage.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
camHUD = new FlxCamera();
|
|
|
|
|
camHUD.bgColor.alpha = 0; // Show the game scene behind the camera.
|
|
|
|
|
camCutscene = new FlxCamera();
|
|
|
|
|
camCutscene.bgColor.alpha = 0; // Show the game scene behind the camera.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.cameras.reset(camGame);
|
|
|
|
|
FlxG.cameras.add(camHUD, false);
|
|
|
|
|
FlxG.cameras.add(camCutscene, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Configure camera follow point.
|
|
|
|
|
if (previousCameraFollowPoint != null)
|
|
|
|
|
{
|
|
|
|
|
cameraFollowPoint.setPosition(previousCameraFollowPoint.x, previousCameraFollowPoint.y);
|
|
|
|
|
previousCameraFollowPoint = null;
|
|
|
|
|
}
|
|
|
|
|
add(cameraFollowPoint);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initializes the health bar on the HUD.
|
|
|
|
|
*/
|
|
|
|
|
function initHealthBar():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
|
var healthBarYPos:Float = Preferences.downscroll ? FlxG.height * 0.1 : FlxG.height * 0.9;
|
2024-03-13 01:34:50 +00:00
|
|
|
|
healthBarBG = FunkinSprite.create(0, healthBarYPos, 'healthBar');
|
2023-06-22 05:41:01 +00:00
|
|
|
|
healthBarBG.screenCenter(X);
|
|
|
|
|
healthBarBG.scrollFactor.set(0, 0);
|
2024-02-29 02:19:21 +00:00
|
|
|
|
healthBarBG.zIndex = 800;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
add(healthBarBG);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
|
|
|
|
|
'healthLerp', 0, 2);
|
|
|
|
|
healthBar.scrollFactor.set();
|
|
|
|
|
healthBar.createFilledBar(Constants.COLOR_HEALTH_BAR_RED, Constants.COLOR_HEALTH_BAR_GREEN);
|
2024-02-29 02:19:21 +00:00
|
|
|
|
healthBar.zIndex = 801;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
add(healthBar);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// The score text below the health bar.
|
|
|
|
|
scoreText = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, '', 20);
|
|
|
|
|
scoreText.setFormat(Paths.font('vcr.ttf'), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
|
|
|
|
|
scoreText.scrollFactor.set();
|
2024-02-29 02:19:21 +00:00
|
|
|
|
scoreText.zIndex = 802;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
add(scoreText);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Move the health bar to the HUD camera.
|
|
|
|
|
healthBar.cameras = [camHUD];
|
|
|
|
|
healthBarBG.cameras = [camHUD];
|
|
|
|
|
scoreText.cameras = [camHUD];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Generates the stage and all its props.
|
|
|
|
|
*/
|
|
|
|
|
function initStage():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
loadStage(currentStageId);
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
|
function initMinimalMode():Void
|
|
|
|
|
{
|
|
|
|
|
// Create the green background.
|
2024-03-13 01:34:50 +00:00
|
|
|
|
var menuBG = FunkinSprite.create('menuDesat');
|
2023-07-26 20:52:58 +00:00
|
|
|
|
menuBG.color = 0xFF4CAF50;
|
|
|
|
|
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
|
|
|
|
|
menuBG.updateHitbox();
|
|
|
|
|
menuBG.screenCenter();
|
|
|
|
|
menuBG.scrollFactor.set(0, 0);
|
|
|
|
|
menuBG.zIndex = -1000;
|
|
|
|
|
add(menuBG);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Loads stage data from cache, assembles the props,
|
|
|
|
|
* and adds it to the state.
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
function loadStage(id:String):Void
|
|
|
|
|
{
|
2024-01-16 21:49:15 +00:00
|
|
|
|
currentStage = StageRegistry.instance.fetchEntry(id);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentStage != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-04-07 02:38:32 +00:00
|
|
|
|
currentStage.revive(); // Stages are killed and props destroyed when the PlayState is destroyed to save memory.
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Actually create and position the sprites.
|
2023-10-26 09:46:22 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(CREATE, false);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-15 22:25:28 +00:00
|
|
|
|
resetCameraZoom();
|
2023-02-22 19:46:46 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Add the stage to the scene.
|
|
|
|
|
this.add(currentStage);
|
2023-02-22 20:01:07 +00:00
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.console.registerObject('stage', currentStage);
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
else
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// lolol
|
2023-11-24 05:42:07 +00:00
|
|
|
|
lime.app.Application.current.window.alert('Unable to load stage ${id}, is its data corrupted?.', 'Stage Error');
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-22 01:58:15 +00:00
|
|
|
|
|
2024-02-15 22:25:28 +00:00
|
|
|
|
public function resetCameraZoom():Void
|
|
|
|
|
{
|
2024-03-22 22:03:17 +00:00
|
|
|
|
if (PlayState.instance.isMinimalMode) return;
|
2024-02-15 22:25:28 +00:00
|
|
|
|
// Apply camera zoom level from stage data.
|
2024-03-28 18:05:38 +00:00
|
|
|
|
currentCameraZoom = stageZoom;
|
2024-03-16 15:38:10 +00:00
|
|
|
|
FlxG.camera.zoom = currentCameraZoom;
|
|
|
|
|
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Reset bop multiplier.
|
|
|
|
|
cameraBopMultiplier = 1.0;
|
2024-02-15 22:25:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Generates the character sprites and adds them to the stage.
|
|
|
|
|
*/
|
|
|
|
|
function initCharacters():Void
|
|
|
|
|
{
|
|
|
|
|
if (currentSong == null || currentChart == null)
|
|
|
|
|
{
|
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
|
var currentCharacterData:SongCharacterData = currentChart.characters; // Switch the variation we are playing on by manipulating targetVariation.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
//
|
|
|
|
|
// GIRLFRIEND
|
|
|
|
|
//
|
2023-09-26 03:24:07 +00:00
|
|
|
|
var girlfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.girlfriend);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (girlfriend != null)
|
|
|
|
|
{
|
|
|
|
|
girlfriend.characterType = CharacterType.GF;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-09-26 03:24:07 +00:00
|
|
|
|
else if (currentCharacterData.girlfriend != '')
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-09-26 03:24:07 +00:00
|
|
|
|
trace('WARNING: Could not load girlfriend character with ID ${currentCharacterData.girlfriend}, skipping...');
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Chosen GF was '' so we don't load one.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
//
|
|
|
|
|
// DAD
|
|
|
|
|
//
|
2023-09-26 03:24:07 +00:00
|
|
|
|
var dad:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.opponent);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (dad != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
dad.characterType = CharacterType.DAD;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-01 13:13:06 +00:00
|
|
|
|
//
|
|
|
|
|
// OPPONENT HEALTH ICON
|
|
|
|
|
//
|
|
|
|
|
iconP2 = new HealthIcon('dad', 1);
|
|
|
|
|
iconP2.y = healthBar.y - (iconP2.height / 2);
|
|
|
|
|
dad.initHealthIcon(true); // Apply the character ID here
|
|
|
|
|
iconP2.zIndex = 850;
|
|
|
|
|
add(iconP2);
|
|
|
|
|
iconP2.cameras = [camHUD];
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
//
|
|
|
|
|
// BOYFRIEND
|
|
|
|
|
//
|
2023-09-26 03:24:07 +00:00
|
|
|
|
var boyfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.player);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (boyfriend != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
boyfriend.characterType = CharacterType.BF;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-01 13:13:06 +00:00
|
|
|
|
//
|
|
|
|
|
// PLAYER HEALTH ICON
|
|
|
|
|
//
|
|
|
|
|
iconP1 = new HealthIcon('bf', 0);
|
|
|
|
|
iconP1.y = healthBar.y - (iconP1.height / 2);
|
|
|
|
|
boyfriend.initHealthIcon(false); // Apply the character ID here
|
|
|
|
|
iconP1.zIndex = 850;
|
|
|
|
|
add(iconP1);
|
|
|
|
|
iconP1.cameras = [camHUD];
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
//
|
|
|
|
|
// ADD CHARACTERS TO SCENE
|
|
|
|
|
//
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentStage != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Characters get added to the stage, not the main scene.
|
|
|
|
|
if (girlfriend != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
currentStage.addCharacter(girlfriend, GF);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.console.registerObject('gf', girlfriend);
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (boyfriend != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
currentStage.addCharacter(boyfriend, BF);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.console.registerObject('bf', boyfriend);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
#end
|
2023-06-16 21:37:56 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (dad != null)
|
2023-06-16 21:37:56 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
currentStage.addCharacter(dad, DAD);
|
|
|
|
|
// Camera starts at dad.
|
|
|
|
|
cameraFollowPoint.setPosition(dad.cameraFocusPoint.x, dad.cameraFocusPoint.y);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.console.registerObject('dad', dad);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
#end
|
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// Rearrange by z-indexes.
|
|
|
|
|
currentStage.refresh();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-16 21:37:56 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Constructs the strumlines for each player.
|
|
|
|
|
*/
|
|
|
|
|
function initStrumlines():Void
|
2023-02-22 01:58:15 +00:00
|
|
|
|
{
|
2024-05-21 20:52:40 +00:00
|
|
|
|
var noteStyleId:String = currentChart.noteStyle;
|
2023-07-14 00:27:45 +00:00
|
|
|
|
var noteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyleId);
|
|
|
|
|
if (noteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-06 02:48:04 +00:00
|
|
|
|
playerStrumline = new Strumline(noteStyle, !isBotPlayMode);
|
|
|
|
|
playerStrumline.onNoteIncoming.add(onStrumlineNoteIncoming);
|
2023-07-14 00:27:45 +00:00
|
|
|
|
opponentStrumline = new Strumline(noteStyle, false);
|
2024-03-06 02:48:04 +00:00
|
|
|
|
opponentStrumline.onNoteIncoming.add(onStrumlineNoteIncoming);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
add(playerStrumline);
|
|
|
|
|
add(opponentStrumline);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
// Position the player strumline on the right half of the screen
|
|
|
|
|
playerStrumline.x = FlxG.width / 2 + Constants.STRUMLINE_X_OFFSET; // Classic style
|
|
|
|
|
// playerStrumline.x = FlxG.width - playerStrumline.width - Constants.STRUMLINE_X_OFFSET; // Centered style
|
2023-10-17 04:38:28 +00:00
|
|
|
|
playerStrumline.y = Preferences.downscroll ? FlxG.height - playerStrumline.height - Constants.STRUMLINE_Y_OFFSET : Constants.STRUMLINE_Y_OFFSET;
|
2024-02-29 02:19:21 +00:00
|
|
|
|
playerStrumline.zIndex = 1001;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
playerStrumline.cameras = [camHUD];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
// Position the opponent strumline on the left half of the screen
|
2023-06-22 05:41:01 +00:00
|
|
|
|
opponentStrumline.x = Constants.STRUMLINE_X_OFFSET;
|
2023-10-17 04:38:28 +00:00
|
|
|
|
opponentStrumline.y = Preferences.downscroll ? FlxG.height - opponentStrumline.height - Constants.STRUMLINE_Y_OFFSET : Constants.STRUMLINE_Y_OFFSET;
|
2024-02-29 02:19:21 +00:00
|
|
|
|
opponentStrumline.zIndex = 1000;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
opponentStrumline.cameras = [camHUD];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-07-04 19:55:19 +00:00
|
|
|
|
playerStrumline.fadeInArrows();
|
|
|
|
|
opponentStrumline.fadeInArrows();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initializes the Discord Rich Presence.
|
|
|
|
|
*/
|
|
|
|
|
function initDiscord():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if discord_rpc
|
|
|
|
|
storyDifficultyText = difficultyString();
|
|
|
|
|
iconRPC = currentSong.player2;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// To avoid having duplicate images in Discord assets
|
|
|
|
|
switch (iconRPC)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
case 'senpai-angry':
|
|
|
|
|
iconRPC = 'senpai';
|
|
|
|
|
case 'monster-christmas':
|
|
|
|
|
iconRPC = 'monster';
|
|
|
|
|
case 'mom-car':
|
|
|
|
|
iconRPC = 'mom';
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
|
|
|
|
|
detailsText = isStoryMode ? 'Story Mode: Week $storyWeek' : 'Freeplay';
|
|
|
|
|
detailsPausedText = 'Paused - $detailsText';
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Updating Discord Rich Presence.
|
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC);
|
|
|
|
|
#end
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function initPreciseInputs():Void
|
|
|
|
|
{
|
|
|
|
|
PreciseInputManager.instance.onInputPressed.add(onKeyPress);
|
|
|
|
|
PreciseInputManager.instance.onInputReleased.add(onKeyRelease);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initializes the song (applying the chart, generating the notes, etc.)
|
|
|
|
|
* Should be done before the countdown starts.
|
|
|
|
|
*/
|
|
|
|
|
function generateSong():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentChart == null)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('Song difficulty could not be loaded.');
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
// Conductor.instance.forceBPM(currentChart.getStartingBPM());
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-08-04 20:15:07 +00:00
|
|
|
|
if (!overrideMusic)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-11-09 22:00:46 +00:00
|
|
|
|
// Stop the vocals if they already exist.
|
|
|
|
|
if (vocals != null) vocals.stop();
|
2023-09-26 03:24:07 +00:00
|
|
|
|
vocals = currentChart.buildVocals();
|
2023-08-04 20:15:07 +00:00
|
|
|
|
|
|
|
|
|
if (vocals.members.length == 0)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: No vocals found for this song.');
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
regenNoteData();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-11-06 22:51:56 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(CREATE, false);
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentSong, event);
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
generatedMusic = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Read note data from the chart and generate the notes.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-07-27 00:03:31 +00:00
|
|
|
|
function regenNoteData(startTime:Float = 0):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
Highscore.tallies.combo = 0;
|
|
|
|
|
Highscore.tallies = new Tallies();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-05-02 08:11:27 +00:00
|
|
|
|
var event:SongLoadScriptEvent = new SongLoadScriptEvent(currentChart.song.id, currentChart.difficulty, currentChart.notes.copy(), currentChart.getEvents());
|
|
|
|
|
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
var builtNoteData = event.notes;
|
|
|
|
|
var builtEventData = event.events;
|
|
|
|
|
|
|
|
|
|
songEvents = builtEventData;
|
2024-01-04 02:10:14 +00:00
|
|
|
|
SongEventRegistry.resetEvents(songEvents);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Reset the notes on each strumline.
|
|
|
|
|
var playerNoteData:Array<SongNoteData> = [];
|
|
|
|
|
var opponentNoteData:Array<SongNoteData> = [];
|
|
|
|
|
|
2024-05-02 08:11:27 +00:00
|
|
|
|
for (songNote in builtNoteData)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var strumTime:Float = songNote.time;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
if (strumTime < startTime) continue; // Skip notes that are before the start time.
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var noteData:Int = songNote.getDirection();
|
|
|
|
|
var playerNote:Bool = true;
|
|
|
|
|
|
|
|
|
|
if (noteData > 3) playerNote = false;
|
|
|
|
|
|
|
|
|
|
switch (songNote.getStrumlineIndex())
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
case 0:
|
|
|
|
|
playerNoteData.push(songNote);
|
2024-03-05 01:47:23 +00:00
|
|
|
|
// increment totalNotes for total possible notes able to be hit by the player
|
|
|
|
|
Highscore.tallies.totalNotes++;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
case 1:
|
|
|
|
|
opponentNoteData.push(songNote);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
playerStrumline.applyNoteData(playerNoteData);
|
|
|
|
|
opponentStrumline.applyNoteData(opponentNoteData);
|
2023-02-22 01:58:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 02:48:04 +00:00
|
|
|
|
function onStrumlineNoteIncoming(noteSprite:NoteSprite):Void
|
|
|
|
|
{
|
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(NOTE_INCOMING, noteSprite, 0, false);
|
|
|
|
|
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Prepares to start the countdown.
|
|
|
|
|
* Ends any running cutscenes, creates the strumlines, and starts the countdown.
|
|
|
|
|
* This is public so that scripts can call it.
|
|
|
|
|
*/
|
|
|
|
|
public function startCountdown():Void
|
2023-07-02 20:46:40 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// If Countdown.performCountdown returns false, then the countdown was canceled by a script.
|
|
|
|
|
var result:Bool = Countdown.performCountdown(currentStageId.startsWith('school'));
|
|
|
|
|
if (!result) return;
|
2023-07-02 20:46:40 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
isInCutscene = false;
|
|
|
|
|
camCutscene.visible = false;
|
2024-04-20 06:11:04 +00:00
|
|
|
|
|
|
|
|
|
// TODO: Maybe tween in the camera after any cutscenes.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
camHUD.visible = true;
|
2023-07-02 20:46:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Displays a dialogue cutscene with the given ID.
|
|
|
|
|
* This is used by song scripts to display dialogue.
|
|
|
|
|
*/
|
|
|
|
|
public function startConversation(conversationId:String):Void
|
2023-02-22 01:58:15 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
isInCutscene = true;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-02-07 14:21:44 +00:00
|
|
|
|
currentConversation = ConversationRegistry.instance.fetchEntry(conversationId);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentConversation == null) return;
|
2024-02-28 08:01:20 +00:00
|
|
|
|
if (!currentConversation.alive) currentConversation.revive();
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
currentConversation.completeCallback = onConversationComplete;
|
|
|
|
|
currentConversation.cameras = [camCutscene];
|
|
|
|
|
currentConversation.zIndex = 1000;
|
|
|
|
|
add(currentConversation);
|
|
|
|
|
refresh();
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
|
var event:ScriptEvent = new ScriptEvent(CREATE, false);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
ScriptEventDispatcher.callEvent(currentConversation, event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handler function called when a conversation ends.
|
|
|
|
|
*/
|
|
|
|
|
function onConversationComplete():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-10-18 01:26:32 +00:00
|
|
|
|
isInCutscene = false;
|
2024-02-28 08:01:20 +00:00
|
|
|
|
|
|
|
|
|
if (currentConversation != null)
|
|
|
|
|
{
|
|
|
|
|
currentConversation.kill();
|
|
|
|
|
remove(currentConversation);
|
|
|
|
|
currentConversation = null;
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (startingSong && !isInCountdown)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
startCountdown();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Starts playing the song after the countdown has completed.
|
|
|
|
|
*/
|
|
|
|
|
function startSong():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
startingSong = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-08-04 20:15:07 +00:00
|
|
|
|
if (!overrideMusic && !isGamePaused && currentChart != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-06-07 01:38:00 +00:00
|
|
|
|
currentChart.playInst(1.0, currentInstrumental, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-23 21:50:48 +00:00
|
|
|
|
if (FlxG.sound.music == null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.log.error('PlayState failed to initialize instrumental!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
FlxG.sound.music.onComplete = endSong.bind(false);
|
2023-12-05 07:44:57 +00:00
|
|
|
|
// A negative instrumental offset means the song skips the first few milliseconds of the track.
|
|
|
|
|
// This just gets added into the startTimestamp behavior so we don't need to do anything extra.
|
2024-02-28 08:01:20 +00:00
|
|
|
|
FlxG.sound.music.play(true, startTimestamp - Conductor.instance.instrumentalOffset);
|
2024-02-29 23:49:20 +00:00
|
|
|
|
FlxG.sound.music.pitch = playbackRate;
|
2024-02-28 08:01:20 +00:00
|
|
|
|
|
2024-03-27 03:24:59 +00:00
|
|
|
|
// Prevent the volume from being wrong.
|
2024-02-28 08:01:20 +00:00
|
|
|
|
FlxG.sound.music.volume = 1.0;
|
2024-03-08 05:21:51 +00:00
|
|
|
|
if (FlxG.sound.music.fadeTween != null) FlxG.sound.music.fadeTween.cancel();
|
2023-12-05 07:44:57 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('Playing vocals...');
|
|
|
|
|
add(vocals);
|
2023-12-07 03:03:36 +00:00
|
|
|
|
vocals.play();
|
2024-03-27 03:24:59 +00:00
|
|
|
|
vocals.volume = 1.0;
|
2024-02-29 23:49:20 +00:00
|
|
|
|
vocals.pitch = playbackRate;
|
2023-12-07 03:03:36 +00:00
|
|
|
|
resyncVocals();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Updating Discord Rich Presence (with Time Left)
|
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, currentSongLengthMs);
|
|
|
|
|
#end
|
2023-07-27 00:03:31 +00:00
|
|
|
|
|
|
|
|
|
if (startTimestamp > 0)
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
// FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
handleSkippedNotes();
|
|
|
|
|
}
|
2024-02-23 09:00:31 +00:00
|
|
|
|
|
|
|
|
|
dispatchEvent(new ScriptEvent(SONG_START));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Resyncronize the vocal tracks if they have become offset from the instrumental.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function resyncVocals():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-13 07:09:25 +00:00
|
|
|
|
if (vocals == null) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-05 07:44:57 +00:00
|
|
|
|
// Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.)
|
2023-08-02 22:08:49 +00:00
|
|
|
|
if (!FlxG.sound.music.playing) return;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
vocals.pause();
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-12-07 03:03:36 +00:00
|
|
|
|
FlxG.sound.music.play(FlxG.sound.music.time);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
vocals.time = FlxG.sound.music.time;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
vocals.play(false, FlxG.sound.music.time);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Updates the position and contents of the score display.
|
|
|
|
|
*/
|
|
|
|
|
function updateScoreText():Void
|
|
|
|
|
{
|
|
|
|
|
// TODO: Add functionality for modules to update the score text.
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (isBotPlayMode)
|
|
|
|
|
{
|
|
|
|
|
scoreText.text = 'Bot Play Enabled';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-07-10 18:23:50 +00:00
|
|
|
|
// TODO: Add an option for this maybe?
|
|
|
|
|
var commaSeparated:Bool = true;
|
|
|
|
|
scoreText.text = 'Score: ${FlxStringUtil.formatMoney(songScore, false, commaSeparated)}';
|
2024-03-06 03:27:07 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Updates the values of the health bar.
|
|
|
|
|
*/
|
|
|
|
|
function updateHealthBar():Void
|
|
|
|
|
{
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (isBotPlayMode)
|
|
|
|
|
{
|
|
|
|
|
healthLerp = Constants.HEALTH_MAX;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
healthLerp = FlxMath.lerp(healthLerp, health, 0.15);
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Callback executed when one of the note keys is pressed.
|
|
|
|
|
*/
|
|
|
|
|
function onKeyPress(event:PreciseInputEvent):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-08-02 22:08:49 +00:00
|
|
|
|
if (isGamePaused) return;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Do the minimal possible work here.
|
|
|
|
|
inputPressQueue.push(event);
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Callback executed when one of the note keys is released.
|
|
|
|
|
*/
|
|
|
|
|
function onKeyRelease(event:PreciseInputEvent):Void
|
|
|
|
|
{
|
2023-08-02 22:08:49 +00:00
|
|
|
|
if (isGamePaused) return;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Do the minimal possible work here.
|
|
|
|
|
inputReleaseQueue.push(event);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Handles opponent note hits and player note misses.
|
2023-06-02 19:35:01 +00:00
|
|
|
|
*/
|
2023-06-27 21:22:51 +00:00
|
|
|
|
function processNotes(elapsed:Float):Void
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-07-14 00:27:45 +00:00
|
|
|
|
if (playerStrumline?.notes?.members == null || opponentStrumline?.notes?.members == null) return;
|
2023-02-22 19:46:46 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Process notes on the opponent's side.
|
|
|
|
|
for (note in opponentStrumline.notes.members)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (note == null) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-23 19:34:37 +00:00
|
|
|
|
// TODO: Are offsets being accounted for in the correct direction?
|
|
|
|
|
var hitWindowStart = note.strumTime + Conductor.instance.inputOffset - Constants.HIT_WINDOW_MS;
|
|
|
|
|
var hitWindowCenter = note.strumTime + Conductor.instance.inputOffset;
|
|
|
|
|
var hitWindowEnd = note.strumTime + Conductor.instance.inputOffset + Constants.HIT_WINDOW_MS;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.songPosition > hitWindowEnd)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (note.hasMissed || note.hasBeenHit) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
note.tooEarly = false;
|
|
|
|
|
note.mayHit = false;
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.hasMissed = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (note.holdNoteSprite != null)
|
|
|
|
|
{
|
|
|
|
|
note.holdNoteSprite.missedNote = true;
|
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-12-14 21:56:20 +00:00
|
|
|
|
else if (Conductor.instance.songPosition > hitWindowCenter)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-07-08 05:03:46 +00:00
|
|
|
|
if (note.hasBeenHit) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Call an event to allow canceling the note hit.
|
|
|
|
|
// NOTE: This is what handles the character animations!
|
2024-05-08 12:26:17 +00:00
|
|
|
|
|
|
|
|
|
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', false, 0);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
dispatchEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
|
if (event.eventCanceled) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Command the opponent to hit the note on time.
|
|
|
|
|
// NOTE: This is what handles the strumline and cleaning up the note itself!
|
|
|
|
|
opponentStrumline.hitNote(note);
|
2023-07-06 02:11:58 +00:00
|
|
|
|
|
|
|
|
|
if (note.holdNoteSprite != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-07-06 02:11:58 +00:00
|
|
|
|
opponentStrumline.playNoteHoldCover(note.holdNoteSprite);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-12-14 21:56:20 +00:00
|
|
|
|
else if (Conductor.instance.songPosition > hitWindowStart)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-07-08 05:03:46 +00:00
|
|
|
|
if (note.hasBeenHit || note.hasMissed) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
note.tooEarly = false;
|
|
|
|
|
note.mayHit = true;
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.hasMissed = false;
|
|
|
|
|
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
note.tooEarly = true;
|
|
|
|
|
note.mayHit = false;
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.hasMissed = false;
|
|
|
|
|
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = false;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
// Process hold notes on the opponent's side.
|
|
|
|
|
for (holdNote in opponentStrumline.holdNotes.members)
|
|
|
|
|
{
|
|
|
|
|
if (holdNote == null || !holdNote.alive) continue;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
// While the hold note is being hit, and there is length on the hold note...
|
|
|
|
|
if (holdNote.hitNote && !holdNote.missedNote && holdNote.sustainLength > 0)
|
|
|
|
|
{
|
|
|
|
|
// Make sure the opponent keeps singing while the note is held.
|
|
|
|
|
if (currentStage != null && currentStage.getDad() != null && currentStage.getDad().isSinging())
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-07-08 05:03:46 +00:00
|
|
|
|
currentStage.getDad().holdTimer = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-15 19:20:44 +00:00
|
|
|
|
if (holdNote.missedNote && !holdNote.handledMiss)
|
|
|
|
|
{
|
2024-01-16 03:10:42 +00:00
|
|
|
|
// When the opponent drops a hold note.
|
2024-01-15 19:20:44 +00:00
|
|
|
|
holdNote.handledMiss = true;
|
2024-01-16 03:10:42 +00:00
|
|
|
|
|
|
|
|
|
// We dropped a hold note.
|
2024-03-23 22:11:06 +00:00
|
|
|
|
// Play miss animation, but don't penalize.
|
2024-01-16 03:10:42 +00:00
|
|
|
|
currentStage.getOpponent().playSingAnimation(holdNote.noteData.getDirection(), true);
|
2024-01-15 19:20:44 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-07-08 05:03:46 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Process notes on the player's side.
|
|
|
|
|
for (note in playerStrumline.notes.members)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-01-16 03:10:42 +00:00
|
|
|
|
if (note == null) continue;
|
|
|
|
|
|
|
|
|
|
if (note.hasBeenHit)
|
|
|
|
|
{
|
|
|
|
|
note.tooEarly = false;
|
|
|
|
|
note.mayHit = false;
|
|
|
|
|
note.hasMissed = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-23 00:16:43 +00:00
|
|
|
|
var hitWindowStart = note.strumTime - Constants.HIT_WINDOW_MS;
|
2023-06-27 17:43:42 +00:00
|
|
|
|
var hitWindowCenter = note.strumTime;
|
2023-07-23 00:16:43 +00:00
|
|
|
|
var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.songPosition > hitWindowEnd)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (note.hasMissed || note.hasBeenHit) continue;
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.tooEarly = false;
|
|
|
|
|
note.mayHit = false;
|
|
|
|
|
note.hasMissed = true;
|
2024-03-06 03:27:07 +00:00
|
|
|
|
if (note.holdNoteSprite != null)
|
|
|
|
|
{
|
|
|
|
|
note.holdNoteSprite.missedNote = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (isBotPlayMode && Conductor.instance.songPosition > hitWindowCenter)
|
|
|
|
|
{
|
|
|
|
|
if (note.hasBeenHit) continue;
|
|
|
|
|
|
|
|
|
|
// We call onHitNote to play the proper animations,
|
|
|
|
|
// but not goodNoteHit! This means zero score and zero notes hit for the results screen!
|
|
|
|
|
|
|
|
|
|
// Call an event to allow canceling the note hit.
|
|
|
|
|
// NOTE: This is what handles the character animations!
|
2024-05-08 12:26:17 +00:00
|
|
|
|
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', false, 0);
|
2024-03-06 03:27:07 +00:00
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
|
if (event.eventCanceled) continue;
|
|
|
|
|
|
|
|
|
|
// Command the bot to hit the note on time.
|
|
|
|
|
// NOTE: This is what handles the strumline and cleaning up the note itself!
|
|
|
|
|
playerStrumline.hitNote(note);
|
|
|
|
|
|
|
|
|
|
if (note.holdNoteSprite != null)
|
|
|
|
|
{
|
|
|
|
|
playerStrumline.playNoteHoldCover(note.holdNoteSprite);
|
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-12-14 21:56:20 +00:00
|
|
|
|
else if (Conductor.instance.songPosition > hitWindowStart)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.tooEarly = false;
|
|
|
|
|
note.mayHit = true;
|
|
|
|
|
note.hasMissed = false;
|
|
|
|
|
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = false;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-27 17:43:42 +00:00
|
|
|
|
note.tooEarly = true;
|
|
|
|
|
note.mayHit = false;
|
|
|
|
|
note.hasMissed = false;
|
|
|
|
|
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = false;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-27 17:43:42 +00:00
|
|
|
|
// This becomes true when the note leaves the hit window.
|
|
|
|
|
// It might still be on screen.
|
|
|
|
|
if (note.hasMissed && !note.handledMiss)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
// Call an event to allow canceling the note miss.
|
|
|
|
|
// NOTE: This is what handles the character animations!
|
2024-03-01 13:13:06 +00:00
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(NOTE_MISS, note, -Constants.HEALTH_MISS_PENALTY, 0, true);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
dispatchEvent(event);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
|
if (event.eventCanceled) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Judge the miss.
|
|
|
|
|
// NOTE: This is what handles the scoring.
|
2023-07-27 01:34:38 +00:00
|
|
|
|
trace('Missed note! ${note.noteData}');
|
2024-03-01 13:13:06 +00:00
|
|
|
|
onNoteMiss(note, event.playSound, event.healthChange);
|
2023-06-27 17:43:42 +00:00
|
|
|
|
|
|
|
|
|
note.handledMiss = true;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-27 00:40:26 +00:00
|
|
|
|
|
|
|
|
|
// Process hold notes on the player's side.
|
|
|
|
|
// This handles scoring so we don't need it on the opponent's side.
|
2023-06-27 21:22:51 +00:00
|
|
|
|
for (holdNote in playerStrumline.holdNotes.members)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-27 22:06:33 +00:00
|
|
|
|
if (holdNote == null || !holdNote.alive) continue;
|
|
|
|
|
|
2023-06-27 21:22:51 +00:00
|
|
|
|
// While the hold note is being hit, and there is length on the hold note...
|
2024-06-07 23:59:02 +00:00
|
|
|
|
if (holdNote.hitNote && !holdNote.missedNote && holdNote.sustainLength > 0)
|
2023-06-27 21:22:51 +00:00
|
|
|
|
{
|
|
|
|
|
// Grant the player health.
|
2024-06-07 23:59:02 +00:00
|
|
|
|
if (!isBotPlayMode)
|
|
|
|
|
{
|
|
|
|
|
health += Constants.HEALTH_HOLD_BONUS_PER_SECOND * elapsed;
|
|
|
|
|
songScore += Std.int(Constants.SCORE_HOLD_BONUS_PER_SECOND * elapsed);
|
|
|
|
|
}
|
2024-06-11 04:40:43 +00:00
|
|
|
|
|
2024-06-07 23:59:02 +00:00
|
|
|
|
// Make sure the player keeps singing while the note is held by the bot.
|
|
|
|
|
if (isBotPlayMode && currentStage != null && currentStage.getBoyfriend() != null && currentStage.getBoyfriend().isSinging())
|
|
|
|
|
{
|
|
|
|
|
currentStage.getBoyfriend().holdTimer = 0;
|
|
|
|
|
}
|
2023-06-27 21:22:51 +00:00
|
|
|
|
}
|
2023-07-08 05:03:46 +00:00
|
|
|
|
|
2024-01-16 03:10:42 +00:00
|
|
|
|
if (holdNote.missedNote && !holdNote.handledMiss)
|
|
|
|
|
{
|
|
|
|
|
// The player dropped a hold note.
|
|
|
|
|
holdNote.handledMiss = true;
|
|
|
|
|
|
|
|
|
|
// Mute vocals and play miss animation, but don't penalize.
|
2024-04-03 08:52:28 +00:00
|
|
|
|
// vocals.playerVolume = 0;
|
|
|
|
|
// if (currentStage != null && currentStage.getBoyfriend() != null) currentStage.getBoyfriend().playSingAnimation(holdNote.noteData.getDirection(), true);
|
2024-01-16 03:10:42 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Spitting out the input for ravy 🙇♂️!!
|
|
|
|
|
*/
|
|
|
|
|
var inputSpitter:Array<ScoreInput> = [];
|
|
|
|
|
|
2023-07-27 00:03:31 +00:00
|
|
|
|
function handleSkippedNotes():Void
|
|
|
|
|
{
|
|
|
|
|
for (note in playerStrumline.notes.members)
|
|
|
|
|
{
|
2023-07-27 01:34:38 +00:00
|
|
|
|
if (note == null || note.hasBeenHit) continue;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS;
|
|
|
|
|
|
2023-12-14 21:56:20 +00:00
|
|
|
|
if (Conductor.instance.songPosition > hitWindowEnd)
|
2023-07-27 00:03:31 +00:00
|
|
|
|
{
|
|
|
|
|
// We have passed this note.
|
|
|
|
|
// Flag the note for deletion without actually penalizing the player.
|
|
|
|
|
note.handledMiss = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-27 01:34:38 +00:00
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
// Respawns notes that were b
|
2023-07-27 01:34:38 +00:00
|
|
|
|
playerStrumline.handleSkippedNotes();
|
|
|
|
|
opponentStrumline.handleSkippedNotes();
|
2023-07-27 00:03:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* PreciseInputEvents are put into a queue between update() calls,
|
|
|
|
|
* and then processed here.
|
|
|
|
|
*/
|
|
|
|
|
function processInputQueue():Void
|
|
|
|
|
{
|
|
|
|
|
if (inputPressQueue.length + inputReleaseQueue.length == 0) return;
|
|
|
|
|
|
|
|
|
|
// Ignore inputs during cutscenes.
|
|
|
|
|
if (isInCutscene || disableKeys)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
inputPressQueue = [];
|
|
|
|
|
inputReleaseQueue = [];
|
|
|
|
|
return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// Generate a list of notes within range.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
var notesInRange:Array<NoteSprite> = playerStrumline.getNotesMayHit();
|
2023-06-27 22:06:33 +00:00
|
|
|
|
var holdNotesInRange:Array<SustainTrail> = playerStrumline.getHoldNotesHitOrMissed();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
var notesByDirection:Array<Array<NoteSprite>> = [[], [], [], []];
|
|
|
|
|
|
|
|
|
|
for (note in notesInRange)
|
|
|
|
|
notesByDirection[note.direction].push(note);
|
|
|
|
|
|
|
|
|
|
while (inputPressQueue.length > 0)
|
2023-03-02 09:20:03 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var input:PreciseInputEvent = inputPressQueue.shift();
|
2023-03-02 09:20:03 +00:00
|
|
|
|
|
2023-06-27 00:40:26 +00:00
|
|
|
|
playerStrumline.pressKey(input.noteDirection);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var notesInDirection:Array<NoteSprite> = notesByDirection[input.noteDirection];
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (!Constants.GHOST_TAPPING && notesInDirection.length == 0)
|
2023-03-18 19:47:23 +00:00
|
|
|
|
{
|
2023-06-27 17:43:42 +00:00
|
|
|
|
// Pressed a wrong key with no notes nearby.
|
|
|
|
|
// Perform a ghost miss (anti-spam).
|
|
|
|
|
ghostNoteMiss(input.noteDirection, notesInRange.length > 0);
|
|
|
|
|
|
|
|
|
|
// Play the strumline animation.
|
|
|
|
|
playerStrumline.playPress(input.noteDirection);
|
2024-05-19 05:47:36 +00:00
|
|
|
|
trace('PENALTY Score: ${songScore}');
|
2023-03-18 19:47:23 +00:00
|
|
|
|
}
|
2024-05-19 05:47:36 +00:00
|
|
|
|
else if (Constants.GHOST_TAPPING && (!playerStrumline.mayGhostTap()) && notesInDirection.length == 0)
|
2023-03-18 19:47:23 +00:00
|
|
|
|
{
|
2024-05-19 05:47:36 +00:00
|
|
|
|
// Pressed a wrong key with notes visible on-screen.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
// Perform a ghost miss (anti-spam).
|
2023-06-22 05:41:01 +00:00
|
|
|
|
ghostNoteMiss(input.noteDirection, notesInRange.length > 0);
|
|
|
|
|
|
|
|
|
|
// Play the strumline animation.
|
|
|
|
|
playerStrumline.playPress(input.noteDirection);
|
2024-05-19 05:47:36 +00:00
|
|
|
|
trace('PENALTY Score: ${songScore}');
|
|
|
|
|
}
|
|
|
|
|
else if (notesInDirection.length == 0)
|
|
|
|
|
{
|
|
|
|
|
// Press a key with no penalty.
|
|
|
|
|
|
|
|
|
|
// Play the strumline animation.
|
|
|
|
|
playerStrumline.playPress(input.noteDirection);
|
|
|
|
|
trace('NO PENALTY Score: ${songScore}');
|
2023-03-18 19:47:23 +00:00
|
|
|
|
}
|
2024-05-19 05:47:36 +00:00
|
|
|
|
else
|
2023-03-18 19:47:23 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Choose the first note, deprioritizing low priority notes.
|
|
|
|
|
var targetNote:Null<NoteSprite> = notesInDirection.find((note) -> !note.lowPriority);
|
|
|
|
|
if (targetNote == null) targetNote = notesInDirection[0];
|
|
|
|
|
if (targetNote == null) continue;
|
|
|
|
|
|
|
|
|
|
// Judge and hit the note.
|
2023-07-27 01:34:38 +00:00
|
|
|
|
trace('Hit note! ${targetNote.noteData}');
|
2023-06-22 05:41:01 +00:00
|
|
|
|
goodNoteHit(targetNote, input);
|
2024-05-19 05:47:36 +00:00
|
|
|
|
trace('Score: ${songScore}');
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
notesInDirection.remove(targetNote);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// Play the strumline animation.
|
|
|
|
|
playerStrumline.playConfirm(input.noteDirection);
|
2023-03-18 19:47:23 +00:00
|
|
|
|
}
|
2023-03-02 09:20:03 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
while (inputReleaseQueue.length > 0)
|
|
|
|
|
{
|
|
|
|
|
var input:PreciseInputEvent = inputReleaseQueue.shift();
|
|
|
|
|
|
|
|
|
|
// Play the strumline animation.
|
|
|
|
|
playerStrumline.playStatic(input.noteDirection);
|
2023-06-27 00:40:26 +00:00
|
|
|
|
|
|
|
|
|
playerStrumline.releaseKey(input.noteDirection);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function goodNoteHit(note:NoteSprite, input:PreciseInputEvent):Void
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-03-01 13:13:06 +00:00
|
|
|
|
// Calculate the input latency (do this as late as possible).
|
|
|
|
|
// trace('Compare: ${PreciseInputManager.getCurrentTimestamp()} - ${input.timestamp}');
|
|
|
|
|
var inputLatencyNs:Int64 = PreciseInputManager.getCurrentTimestamp() - input.timestamp;
|
|
|
|
|
var inputLatencyMs:Float = inputLatencyNs.toFloat() / Constants.NS_PER_MS;
|
|
|
|
|
// trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
|
|
|
|
|
|
|
|
|
|
// Get the offset and compensate for input latency.
|
|
|
|
|
// Round inward (trim remainder) for consistency.
|
|
|
|
|
var noteDiff:Int = Std.int(Conductor.instance.songPosition - note.noteData.time - inputLatencyMs);
|
|
|
|
|
|
|
|
|
|
var score = Scoring.scoreNote(noteDiff, PBOT1);
|
|
|
|
|
var daRating = Scoring.judgeNote(noteDiff, PBOT1);
|
|
|
|
|
|
|
|
|
|
var healthChange = 0.0;
|
2024-05-08 12:26:17 +00:00
|
|
|
|
var isComboBreak = false;
|
2024-03-01 13:13:06 +00:00
|
|
|
|
switch (daRating)
|
|
|
|
|
{
|
|
|
|
|
case 'sick':
|
|
|
|
|
healthChange = Constants.HEALTH_SICK_BONUS;
|
2024-05-08 12:26:17 +00:00
|
|
|
|
isComboBreak = Constants.JUDGEMENT_SICK_COMBO_BREAK;
|
2024-03-01 13:13:06 +00:00
|
|
|
|
case 'good':
|
|
|
|
|
healthChange = Constants.HEALTH_GOOD_BONUS;
|
2024-05-08 12:26:17 +00:00
|
|
|
|
isComboBreak = Constants.JUDGEMENT_GOOD_COMBO_BREAK;
|
2024-03-01 13:13:06 +00:00
|
|
|
|
case 'bad':
|
|
|
|
|
healthChange = Constants.HEALTH_BAD_BONUS;
|
2024-05-08 12:26:17 +00:00
|
|
|
|
isComboBreak = Constants.JUDGEMENT_BAD_COMBO_BREAK;
|
2024-03-01 13:13:06 +00:00
|
|
|
|
case 'shit':
|
2024-05-08 12:26:17 +00:00
|
|
|
|
isComboBreak = Constants.JUDGEMENT_SHIT_COMBO_BREAK;
|
2024-03-01 13:13:06 +00:00
|
|
|
|
healthChange = Constants.HEALTH_SHIT_BONUS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the note hit event.
|
2024-05-15 12:46:08 +00:00
|
|
|
|
var event:HitNoteScriptEvent = new HitNoteScriptEvent(note, healthChange, score, daRating, isComboBreak, Highscore.tallies.combo + 1, noteDiff,
|
|
|
|
|
daRating == 'sick');
|
2023-07-08 05:03:46 +00:00
|
|
|
|
dispatchEvent(event);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-07-08 05:03:46 +00:00
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
|
if (event.eventCanceled) return;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-05-08 12:26:17 +00:00
|
|
|
|
Highscore.tallies.totalNotesHit++;
|
|
|
|
|
// Display the hit on the strums
|
|
|
|
|
playerStrumline.hitNote(note, !isComboBreak);
|
2024-05-15 12:46:08 +00:00
|
|
|
|
if (event.doesNotesplash) playerStrumline.playNoteSplash(note.noteData.getDirection());
|
2024-05-08 12:26:17 +00:00
|
|
|
|
if (note.isHoldNote && note.holdNoteSprite != null) playerStrumline.playNoteHoldCover(note.holdNoteSprite);
|
|
|
|
|
vocals.playerVolume = 1;
|
|
|
|
|
|
2024-03-01 13:13:06 +00:00
|
|
|
|
// Display the combo meter and add the calculation to the score.
|
2024-05-08 12:26:17 +00:00
|
|
|
|
applyScore(event.score, event.judgement, event.healthChange, event.isComboBreak);
|
|
|
|
|
popUpScore(event.judgement);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Called when a note leaves the screen and is considered missed by the player.
|
|
|
|
|
* @param note
|
2023-06-02 19:35:01 +00:00
|
|
|
|
*/
|
2024-03-01 13:13:06 +00:00
|
|
|
|
function onNoteMiss(note:NoteSprite, playSound:Bool = false, healthChange:Float):Void
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2024-02-15 22:25:28 +00:00
|
|
|
|
// If we are here, we already CALLED the onNoteMiss script hook!
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (!isPracticeMode)
|
2023-06-02 19:35:01 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// messy copy paste rn lol
|
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
var indices:Array<Int> = [];
|
|
|
|
|
for (i in 0...pressArray.length)
|
|
|
|
|
{
|
|
|
|
|
if (pressArray[i]) indices.push(i);
|
|
|
|
|
}
|
|
|
|
|
if (indices.length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (i in 0...indices.length)
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
t: Std.int(Conductor.instance.songPosition),
|
2023-06-22 05:41:01 +00:00
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
t: Std.int(Conductor.instance.songPosition),
|
2023-06-22 05:41:01 +00:00
|
|
|
|
d: -1,
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vocals.playerVolume = 0;
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-05-08 12:26:17 +00:00
|
|
|
|
if (Highscore.tallies.combo != 0) if (Highscore.tallies.combo >= 10) comboPopUps.displayCombo(0);
|
2024-01-16 03:10:42 +00:00
|
|
|
|
|
2024-05-08 12:26:17 +00:00
|
|
|
|
applyScore(-10, 'miss', healthChange, true);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-02-15 22:25:28 +00:00
|
|
|
|
if (playSound)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
vocals.playerVolume = 0;
|
2024-03-23 21:50:48 +00:00
|
|
|
|
FunkinSound.playOnce(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.5, 0.6));
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-06-02 19:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* Called when a player presses a key with no note present.
|
|
|
|
|
* Scripts can modify the amount of health/score lost, whether player animations or sounds are used,
|
|
|
|
|
* or even cancel the event entirely.
|
2023-06-08 20:30:45 +00:00
|
|
|
|
*
|
|
|
|
|
* @param direction
|
|
|
|
|
* @param hasPossibleNotes
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function ghostNoteMiss(direction:NoteDirection, hasPossibleNotes:Bool = true):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
|
|
|
|
var event:GhostMissNoteScriptEvent = new GhostMissNoteScriptEvent(direction, // Direction missed in.
|
|
|
|
|
hasPossibleNotes, // Whether there was a note you could have hit.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
- 1 * Constants.HEALTH_MISS_PENALTY, // How much health to add (negative).
|
2023-01-23 00:55:30 +00:00
|
|
|
|
- 10 // Amount of score to add (negative).
|
|
|
|
|
);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips animations and penalties. Neat!
|
2023-01-23 03:25:45 +00:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
health += event.healthChange;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
songScore += event.scoreChange;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-03-02 09:20:03 +00:00
|
|
|
|
if (!isPracticeMode)
|
|
|
|
|
{
|
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-03-18 19:47:23 +00:00
|
|
|
|
var indices:Array<Int> = [];
|
|
|
|
|
for (i in 0...pressArray.length)
|
|
|
|
|
{
|
|
|
|
|
if (pressArray[i]) indices.push(i);
|
|
|
|
|
}
|
|
|
|
|
for (i in 0...indices.length)
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
t: Std.int(Conductor.instance.songPosition),
|
2023-03-18 19:47:23 +00:00
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-02 09:20:03 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
|
|
if (event.playSound)
|
|
|
|
|
{
|
2023-05-25 22:34:26 +00:00
|
|
|
|
vocals.playerVolume = 0;
|
2024-03-23 21:50:48 +00:00
|
|
|
|
FunkinSound.playOnce(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Debug keys. Disabled while in cutscenes.
|
|
|
|
|
*/
|
|
|
|
|
function debugKeyShit():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if !debug
|
|
|
|
|
perfectMode = false;
|
|
|
|
|
#else
|
|
|
|
|
if (FlxG.keys.justPressed.H) camHUD.visible = !camHUD.visible;
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-04-24 20:00:50 +00:00
|
|
|
|
#if CHART_EDITOR_SUPPORTED
|
2023-11-16 05:02:42 +00:00
|
|
|
|
// Open the stage editor overlaying the current state.
|
|
|
|
|
if (controls.DEBUG_STAGE)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
|
|
|
|
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
|
|
|
|
|
disableKeys = true;
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
openSubState(new StageOffsetSubState());
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-16 05:02:42 +00:00
|
|
|
|
// Redirect to the chart editor playing the current song.
|
|
|
|
|
if (controls.DEBUG_CHART)
|
|
|
|
|
{
|
2024-05-08 12:30:47 +00:00
|
|
|
|
disableKeys = true;
|
|
|
|
|
persistentUpdate = false;
|
2024-06-10 14:53:32 +00:00
|
|
|
|
if (isChartingMode)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music?.pause();
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlxG.switchState(() -> new ChartEditorState(
|
|
|
|
|
{
|
|
|
|
|
targetSongId: currentSong.id,
|
|
|
|
|
}));
|
|
|
|
|
}
|
2023-11-16 05:02:42 +00:00
|
|
|
|
}
|
2024-04-24 20:00:50 +00:00
|
|
|
|
#end
|
2023-11-16 05:02:42 +00:00
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// 1: End the song immediately.
|
2024-02-27 00:03:04 +00:00
|
|
|
|
if (FlxG.keys.justPressed.ONE) endSong(true);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// 2: Gain 10% health.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (FlxG.keys.justPressed.TWO) health += 0.1 * Constants.HEALTH_MAX;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// 3: Lose 5% health.
|
2023-06-27 17:43:42 +00:00
|
|
|
|
if (FlxG.keys.justPressed.THREE) health -= 0.05 * Constants.HEALTH_MAX;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
// 9: Toggle the old icon.
|
|
|
|
|
if (FlxG.keys.justPressed.NINE) iconP1.toggleOldIcon();
|
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-07-27 01:34:38 +00:00
|
|
|
|
// PAGEUP: Skip forward two sections.
|
|
|
|
|
// SHIFT+PAGEUP: Skip forward twenty sections.
|
|
|
|
|
if (FlxG.keys.justPressed.PAGEUP) changeSection(FlxG.keys.pressed.SHIFT ? 20 : 2);
|
|
|
|
|
// PAGEDOWN: Skip backward two section. Doesn't replace notes.
|
|
|
|
|
// SHIFT+PAGEDOWN: Skip backward twenty sections.
|
|
|
|
|
if (FlxG.keys.justPressed.PAGEDOWN) changeSection(FlxG.keys.pressed.SHIFT ? -20 : -2);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.B) trace(inputSpitter.join('\n'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-05-08 12:26:17 +00:00
|
|
|
|
* Handles applying health, score, and ratings.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
*/
|
2024-05-08 12:26:17 +00:00
|
|
|
|
function applyScore(score:Int, daRating:String, healthChange:Float, isComboBreak:Bool)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
switch (daRating)
|
|
|
|
|
{
|
|
|
|
|
case 'sick':
|
|
|
|
|
Highscore.tallies.sick += 1;
|
|
|
|
|
case 'good':
|
|
|
|
|
Highscore.tallies.good += 1;
|
|
|
|
|
case 'bad':
|
|
|
|
|
Highscore.tallies.bad += 1;
|
|
|
|
|
case 'shit':
|
|
|
|
|
Highscore.tallies.shit += 1;
|
2024-05-08 12:26:17 +00:00
|
|
|
|
case 'miss':
|
|
|
|
|
Highscore.tallies.missed += 1;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2024-03-01 13:13:06 +00:00
|
|
|
|
health += healthChange;
|
2024-01-16 03:10:42 +00:00
|
|
|
|
if (isComboBreak)
|
|
|
|
|
{
|
|
|
|
|
// Break the combo, but don't increment tallies.misses.
|
2024-03-28 04:19:57 +00:00
|
|
|
|
if (Highscore.tallies.combo >= 10) comboPopUps.displayCombo(0);
|
|
|
|
|
Highscore.tallies.combo = 0;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2024-01-16 03:10:42 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.combo++;
|
|
|
|
|
if (Highscore.tallies.combo > Highscore.tallies.maxCombo) Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
|
|
|
|
}
|
2024-05-08 12:26:17 +00:00
|
|
|
|
songScore += score;
|
|
|
|
|
}
|
2024-01-16 03:10:42 +00:00
|
|
|
|
|
2024-05-08 12:26:17 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handles rating popups when a note is hit.
|
|
|
|
|
*/
|
|
|
|
|
function popUpScore(daRating:String, ?combo:Int):Void
|
|
|
|
|
{
|
|
|
|
|
if (daRating == 'miss')
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-05-08 12:26:17 +00:00
|
|
|
|
// If daRating is 'miss', that means we made a mistake and should not continue.
|
|
|
|
|
FlxG.log.warn('popUpScore judged a note as a miss!');
|
|
|
|
|
// TODO: Remove this.
|
|
|
|
|
// comboPopUps.displayRating('miss');
|
|
|
|
|
return;
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2024-05-08 12:26:17 +00:00
|
|
|
|
if (combo == null) combo = Highscore.tallies.combo;
|
2023-07-27 00:03:31 +00:00
|
|
|
|
|
2023-03-02 09:20:03 +00:00
|
|
|
|
if (!isPracticeMode)
|
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Input splitter uses old input system, make it pull from the precise input queue directly.
|
2023-03-02 09:20:03 +00:00
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2023-03-18 19:47:23 +00:00
|
|
|
|
var indices:Array<Int> = [];
|
|
|
|
|
for (i in 0...pressArray.length)
|
|
|
|
|
{
|
|
|
|
|
if (pressArray[i]) indices.push(i);
|
|
|
|
|
}
|
|
|
|
|
if (indices.length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (i in 0...indices.length)
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
t: Std.int(Conductor.instance.songPosition),
|
2023-03-18 19:47:23 +00:00
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
2023-12-14 21:56:20 +00:00
|
|
|
|
t: Std.int(Conductor.instance.songPosition),
|
2023-03-18 19:47:23 +00:00
|
|
|
|
d: -1,
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-02 09:20:03 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
comboPopUps.displayRating(daRating);
|
2024-05-08 12:26:17 +00:00
|
|
|
|
if (combo >= 10 || combo == 0) comboPopUps.displayCombo(combo);
|
2024-04-16 00:36:38 +00:00
|
|
|
|
|
|
|
|
|
vocals.playerVolume = 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handle keyboard inputs during cutscenes.
|
|
|
|
|
* This includes advancing conversations and skipping videos.
|
|
|
|
|
* @param elapsed Time elapsed since last game update.
|
|
|
|
|
*/
|
|
|
|
|
function handleCutsceneKeys(elapsed:Float):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-28 05:19:08 +00:00
|
|
|
|
if (isGamePaused) return;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentConversation != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-28 05:19:08 +00:00
|
|
|
|
// Pause/unpause may conflict with advancing the conversation!
|
|
|
|
|
if (controls.CUTSCENE_ADVANCE && !justUnpaused)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-28 19:51:39 +00:00
|
|
|
|
currentConversation.advanceConversation();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2024-02-28 05:19:08 +00:00
|
|
|
|
else if (controls.PAUSE && !justUnpaused)
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-02-28 19:51:39 +00:00
|
|
|
|
currentConversation.pauseMusic();
|
|
|
|
|
|
2024-02-28 05:19:08 +00:00
|
|
|
|
var pauseSubState:FlxSubState = new PauseSubState({mode: Conversation});
|
|
|
|
|
|
|
|
|
|
persistentUpdate = false;
|
2024-03-17 02:20:22 +00:00
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2024-02-28 05:19:08 +00:00
|
|
|
|
pauseSubState.camera = camCutscene;
|
|
|
|
|
openSubState(pauseSubState);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (VideoCutscene.isPlaying())
|
|
|
|
|
{
|
|
|
|
|
// This is a video cutscene.
|
2024-02-28 05:19:08 +00:00
|
|
|
|
if (controls.PAUSE && !justUnpaused)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-28 08:53:36 +00:00
|
|
|
|
VideoCutscene.pauseVideo();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-28 05:19:08 +00:00
|
|
|
|
var pauseSubState:FlxSubState = new PauseSubState({mode: Cutscene});
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-28 05:19:08 +00:00
|
|
|
|
persistentUpdate = false;
|
2024-03-17 02:20:22 +00:00
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2024-02-28 05:19:08 +00:00
|
|
|
|
pauseSubState.camera = camCutscene;
|
|
|
|
|
openSubState(pauseSubState);
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handle logic for actually skipping a video cutscene after it has been held.
|
|
|
|
|
*/
|
|
|
|
|
function skipVideoCutscene():Void
|
|
|
|
|
{
|
|
|
|
|
VideoCutscene.finishVideo();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* End the song. Handle saving high scores and transitioning to the results screen.
|
2024-02-27 00:03:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Broadcasts an `onSongEnd` event, which can be cancelled to prevent the song from ending (for a cutscene or something).
|
|
|
|
|
* Remember to call `endSong` again when the song should actually end!
|
|
|
|
|
* @param rightGoddamnNow If true, don't play the fancy animation where you zoom onto Girlfriend. Used after a cutscene.
|
2023-06-22 05:41:01 +00:00
|
|
|
|
*/
|
2024-02-27 00:03:04 +00:00
|
|
|
|
public function endSong(rightGoddamnNow:Bool = false):Void
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-04-02 01:59:53 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.volume = 0;
|
2024-02-27 00:03:04 +00:00
|
|
|
|
vocals.volume = 0;
|
|
|
|
|
mayPauseGame = false;
|
|
|
|
|
|
|
|
|
|
// Check if any events want to prevent the song from ending.
|
|
|
|
|
var event = new ScriptEvent(SONG_END, true);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#if sys
|
|
|
|
|
// spitter for ravy, teehee!!
|
2023-10-21 05:04:50 +00:00
|
|
|
|
var writer = new json2object.JsonWriter<Array<ScoreInput>>();
|
|
|
|
|
var output = writer.write(inputSpitter, ' ');
|
2023-06-22 05:41:01 +00:00
|
|
|
|
sys.io.File.saveContent("./scores.json", output);
|
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
deathCounter = 0;
|
2024-02-27 00:03:04 +00:00
|
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
|
// TODO: This line of code makes me sad, but you can't really fix it without a breaking migration.
|
|
|
|
|
// `easy`, `erect`, `normal-pico`, etc.
|
|
|
|
|
var suffixedDifficulty = (currentVariation != Constants.DEFAULT_VARIATION
|
|
|
|
|
&& currentVariation != 'erect') ? '$currentDifficulty-${currentVariation}' : currentDifficulty;
|
|
|
|
|
|
2024-04-02 01:59:53 +00:00
|
|
|
|
var isNewHighscore = false;
|
2024-06-11 04:40:43 +00:00
|
|
|
|
var prevScoreData:Null<SaveScoreData> = Save.instance.getSongScore(currentSong.id, suffixedDifficulty);
|
2024-04-02 01:59:53 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentSong != null && currentSong.validScore)
|
|
|
|
|
{
|
|
|
|
|
// crackhead double thingie, sets whether was new highscore, AND saves the song!
|
2023-10-17 04:38:28 +00:00
|
|
|
|
var data =
|
|
|
|
|
{
|
|
|
|
|
score: songScore,
|
|
|
|
|
tallies:
|
|
|
|
|
{
|
|
|
|
|
sick: Highscore.tallies.sick,
|
|
|
|
|
good: Highscore.tallies.good,
|
|
|
|
|
bad: Highscore.tallies.bad,
|
|
|
|
|
shit: Highscore.tallies.shit,
|
|
|
|
|
missed: Highscore.tallies.missed,
|
|
|
|
|
combo: Highscore.tallies.combo,
|
|
|
|
|
maxCombo: Highscore.tallies.maxCombo,
|
|
|
|
|
totalNotesHit: Highscore.tallies.totalNotesHit,
|
|
|
|
|
totalNotes: Highscore.tallies.totalNotes,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-05 02:18:40 +00:00
|
|
|
|
// adds current song data into the tallies for the level (story levels)
|
|
|
|
|
Highscore.talliesLevel = Highscore.combineTallies(Highscore.tallies, Highscore.talliesLevel);
|
|
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
|
if (!isPracticeMode && !isBotPlayMode)
|
2023-10-17 04:38:28 +00:00
|
|
|
|
{
|
2024-06-11 04:40:43 +00:00
|
|
|
|
isNewHighscore = Save.instance.isSongHighScore(currentSong.id, suffixedDifficulty, data);
|
|
|
|
|
|
|
|
|
|
// If no high score is present, save both score and rank.
|
|
|
|
|
// If score or rank are better, save the highest one.
|
|
|
|
|
// If neither are higher, nothing will change.
|
|
|
|
|
Save.instance.applySongRank(currentSong.id, suffixedDifficulty, data);
|
|
|
|
|
|
|
|
|
|
if (isNewHighscore)
|
|
|
|
|
{
|
|
|
|
|
#if newgrounds
|
|
|
|
|
NGio.postScore(score, currentSong.id);
|
|
|
|
|
#end
|
|
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PlayStatePlaylist.isStoryMode)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-04-02 01:59:53 +00:00
|
|
|
|
isNewHighscore = false;
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
PlayStatePlaylist.campaignScore += songScore;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Pop the next song ID from the list.
|
|
|
|
|
// Returns null if the list is empty.
|
|
|
|
|
var targetSongId:String = PlayStatePlaylist.playlistSongIds.shift();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (targetSongId == null)
|
|
|
|
|
{
|
|
|
|
|
if (currentSong.validScore)
|
|
|
|
|
{
|
|
|
|
|
NGio.unlockMedal(60961);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-10-03 23:14:46 +00:00
|
|
|
|
var data =
|
2023-10-17 04:38:28 +00:00
|
|
|
|
{
|
|
|
|
|
score: PlayStatePlaylist.campaignScore,
|
|
|
|
|
tallies:
|
|
|
|
|
{
|
2024-05-18 00:26:34 +00:00
|
|
|
|
// TODO: Sum up the values for the whole week!
|
2023-10-17 04:38:28 +00:00
|
|
|
|
sick: 0,
|
|
|
|
|
good: 0,
|
|
|
|
|
bad: 0,
|
|
|
|
|
shit: 0,
|
|
|
|
|
missed: 0,
|
|
|
|
|
combo: 0,
|
|
|
|
|
maxCombo: 0,
|
|
|
|
|
totalNotesHit: 0,
|
|
|
|
|
totalNotes: 0,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-04 21:37:42 +00:00
|
|
|
|
if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data))
|
2023-10-17 04:38:28 +00:00
|
|
|
|
{
|
2024-03-04 21:37:42 +00:00
|
|
|
|
Save.instance.setLevelScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data);
|
2023-10-17 04:38:28 +00:00
|
|
|
|
#if newgrounds
|
|
|
|
|
NGio.postScore(score, 'Level ${PlayStatePlaylist.campaignId}');
|
|
|
|
|
#end
|
2024-04-02 01:59:53 +00:00
|
|
|
|
isNewHighscore = true;
|
2023-10-17 04:38:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
|
if (isSubState)
|
|
|
|
|
{
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-27 00:03:04 +00:00
|
|
|
|
if (rightGoddamnNow)
|
|
|
|
|
{
|
2024-04-02 01:59:53 +00:00
|
|
|
|
moveToResultsScreen(isNewHighscore);
|
2024-02-27 00:03:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-02 01:59:53 +00:00
|
|
|
|
zoomIntoResultsScreen(isNewHighscore);
|
2024-02-27 00:03:04 +00:00
|
|
|
|
}
|
2023-07-26 20:52:58 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var difficulty:String = '';
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('Loading next song ($targetSongId : $difficulty)');
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-04-04 07:31:44 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.stop();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
vocals.stop();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Softcode this cutscene.
|
2023-09-08 21:46:44 +00:00
|
|
|
|
if (currentSong.id == 'eggnog')
|
2023-06-22 05:41:01 +00:00
|
|
|
|
{
|
2024-02-22 23:55:24 +00:00
|
|
|
|
var blackBG:FunkinSprite = new FunkinSprite(-FlxG.width * FlxG.camera.zoom, -FlxG.height * FlxG.camera.zoom);
|
|
|
|
|
blackBG.makeSolidColor(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK);
|
|
|
|
|
blackBG.scrollFactor.set();
|
|
|
|
|
add(blackBG);
|
2023-06-22 05:41:01 +00:00
|
|
|
|
camHUD.visible = false;
|
|
|
|
|
isInCutscene = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-03-23 21:50:48 +00:00
|
|
|
|
FunkinSound.playOnce(Paths.sound('Lights_Shut_off'), function() {
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// no camFollow so it centers on horror tree
|
2023-09-08 21:46:44 +00:00
|
|
|
|
var targetSong:Song = SongRegistry.instance.fetchEntry(targetSongId);
|
2024-02-17 04:48:43 +00:00
|
|
|
|
LoadingState.loadPlayState(
|
2024-02-06 00:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
targetSong: targetSong,
|
|
|
|
|
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
2024-02-06 02:35:58 +00:00
|
|
|
|
targetVariation: currentVariation,
|
2024-02-17 04:48:43 +00:00
|
|
|
|
cameraFollowPoint: cameraFollowPoint.getPosition(),
|
2024-02-06 00:46:11 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
2024-02-17 04:48:43 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var targetSong:Song = SongRegistry.instance.fetchEntry(targetSongId);
|
|
|
|
|
LoadingState.loadPlayState(
|
|
|
|
|
{
|
|
|
|
|
targetSong: targetSong,
|
|
|
|
|
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
|
|
|
|
targetVariation: currentVariation,
|
|
|
|
|
cameraFollowPoint: cameraFollowPoint.getPosition(),
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-07-26 20:52:58 +00:00
|
|
|
|
if (isSubState)
|
|
|
|
|
{
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-27 00:03:04 +00:00
|
|
|
|
if (rightGoddamnNow)
|
|
|
|
|
{
|
2024-05-18 00:26:34 +00:00
|
|
|
|
moveToResultsScreen(isNewHighscore, prevScoreData);
|
2024-02-27 00:03:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-18 00:26:34 +00:00
|
|
|
|
zoomIntoResultsScreen(isNewHighscore, prevScoreData);
|
2024-02-27 00:03:04 +00:00
|
|
|
|
}
|
2023-07-26 20:52:58 +00:00
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
|
public override function close():Void
|
|
|
|
|
{
|
2023-07-27 01:34:38 +00:00
|
|
|
|
criticalFailure = true; // Stop game updates.
|
2023-07-26 20:52:58 +00:00
|
|
|
|
performCleanup();
|
|
|
|
|
super.close();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Perform necessary cleanup before leaving the PlayState.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function performCleanup():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-03-10 23:35:41 +00:00
|
|
|
|
// If the camera is being tweened, stop it.
|
|
|
|
|
cancelAllCameraTweens();
|
|
|
|
|
|
2024-03-27 03:24:59 +00:00
|
|
|
|
// Dispatch the destroy event.
|
|
|
|
|
dispatchEvent(new ScriptEvent(DESTROY, false));
|
|
|
|
|
|
2024-02-28 08:01:20 +00:00
|
|
|
|
if (currentConversation != null)
|
|
|
|
|
{
|
|
|
|
|
remove(currentConversation);
|
|
|
|
|
currentConversation.kill();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (currentChart != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// TODO: Uncache the song.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-05 02:19:24 +00:00
|
|
|
|
if (overrideMusic)
|
2023-08-04 20:15:07 +00:00
|
|
|
|
{
|
2024-03-05 02:19:24 +00:00
|
|
|
|
// Stop the music. Do NOT destroy it, something still references it!
|
2024-03-26 23:38:42 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.pause();
|
2024-03-05 02:19:24 +00:00
|
|
|
|
if (vocals != null)
|
|
|
|
|
{
|
|
|
|
|
vocals.pause();
|
|
|
|
|
remove(vocals);
|
|
|
|
|
}
|
2023-08-04 20:15:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-05 02:19:24 +00:00
|
|
|
|
// Stop and destroy the music.
|
2024-03-26 23:38:42 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.pause();
|
2024-02-05 18:35:30 +00:00
|
|
|
|
if (vocals != null)
|
|
|
|
|
{
|
2024-02-28 05:19:08 +00:00
|
|
|
|
vocals.destroy();
|
2024-02-05 18:35:30 +00:00
|
|
|
|
remove(vocals);
|
|
|
|
|
}
|
2023-08-04 20:15:07 +00:00
|
|
|
|
}
|
2023-07-27 01:34:38 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Remove reference to stage and remove sprites from it to save memory.
|
|
|
|
|
if (currentStage != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
remove(currentStage);
|
|
|
|
|
currentStage.kill();
|
|
|
|
|
currentStage = null;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
GameOverSubState.reset();
|
2024-02-28 19:51:39 +00:00
|
|
|
|
PauseSubState.reset();
|
2023-06-22 05:41:01 +00:00
|
|
|
|
|
|
|
|
|
// Clear the static reference to this state.
|
|
|
|
|
instance = null;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-02-27 00:03:04 +00:00
|
|
|
|
* Play the camera zoom animation and then move to the results screen once it's done.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2024-05-18 00:26:34 +00:00
|
|
|
|
function zoomIntoResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
|
2023-06-16 21:37:56 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
trace('WENT TO RESULTS SCREEN!');
|
2023-06-16 21:37:56 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Stop camera zooming on beat.
|
|
|
|
|
cameraZoomRate = 0;
|
2023-06-16 21:37:56 +00:00
|
|
|
|
|
2024-05-09 16:51:03 +00:00
|
|
|
|
// Cancel camera and scroll tweening if it's active.
|
2024-03-10 23:35:41 +00:00
|
|
|
|
cancelAllCameraTweens();
|
2024-05-10 20:23:35 +00:00
|
|
|
|
cancelScrollSpeedTweens();
|
2024-03-10 23:35:41 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// If the opponent is GF, zoom in on the opponent.
|
|
|
|
|
// Else, if there is no GF, zoom in on BF.
|
|
|
|
|
// Else, zoom in on GF.
|
|
|
|
|
var targetDad:Bool = currentStage.getDad() != null && currentStage.getDad().characterId == 'gf';
|
|
|
|
|
var targetBF:Bool = currentStage.getGirlfriend() == null && !targetDad;
|
2023-06-16 21:37:56 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
if (targetBF)
|
2023-06-16 21:37:56 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.camera.follow(currentStage.getBoyfriend(), null, 0.05);
|
2023-06-16 21:37:56 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
else if (targetDad)
|
2023-06-16 21:37:56 +00:00
|
|
|
|
{
|
2023-06-22 05:41:01 +00:00
|
|
|
|
FlxG.camera.follow(currentStage.getDad(), null, 0.05);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlxG.camera.follow(currentStage.getGirlfriend(), null, 0.05);
|
2023-06-16 21:37:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-25 03:50:19 +00:00
|
|
|
|
// TODO: Make target offset configurable.
|
|
|
|
|
// In the meantime, we have to replace the zoom animation with a fade out.
|
|
|
|
|
FlxG.camera.targetOffset.y -= 350;
|
|
|
|
|
FlxG.camera.targetOffset.x += 20;
|
|
|
|
|
|
|
|
|
|
// Replace zoom animation with a fade out for now.
|
2024-06-08 00:02:54 +00:00
|
|
|
|
FlxG.camera.fade(FlxColor.BLACK, 0.6);
|
2024-04-25 03:50:19 +00:00
|
|
|
|
|
|
|
|
|
FlxTween.tween(camHUD, {alpha: 0}, 0.6,
|
|
|
|
|
{
|
|
|
|
|
onComplete: function(_) {
|
2024-05-18 00:26:34 +00:00
|
|
|
|
moveToResultsScreen(isNewHighscore, prevScoreData);
|
2024-04-25 03:50:19 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2023-06-16 21:37:56 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
// Zoom in on Girlfriend (or BF if no GF)
|
|
|
|
|
new FlxTimer().start(0.8, function(_) {
|
|
|
|
|
if (targetBF)
|
|
|
|
|
{
|
|
|
|
|
currentStage.getBoyfriend().animation.play('hey');
|
|
|
|
|
}
|
|
|
|
|
else if (targetDad)
|
|
|
|
|
{
|
|
|
|
|
currentStage.getDad().animation.play('cheer');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentStage.getGirlfriend().animation.play('cheer');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Zoom over to the Results screen.
|
2024-04-25 03:50:19 +00:00
|
|
|
|
// TODO: Re-enable this.
|
|
|
|
|
/*
|
|
|
|
|
FlxTween.tween(FlxG.camera, {zoom: 1200}, 1.1,
|
|
|
|
|
{
|
|
|
|
|
ease: FlxEase.expoIn,
|
|
|
|
|
});
|
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
});
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* Move to the results screen right goddamn now.
|
|
|
|
|
*/
|
2024-05-18 00:26:34 +00:00
|
|
|
|
function moveToResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
|
2024-02-27 00:03:04 +00:00
|
|
|
|
{
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
vocals.stop();
|
|
|
|
|
camHUD.alpha = 1;
|
2024-03-05 02:18:40 +00:00
|
|
|
|
|
|
|
|
|
var talliesToUse:Tallies = PlayStatePlaylist.isStoryMode ? Highscore.talliesLevel : Highscore.tallies;
|
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
var res:ResultState = new ResultState(
|
|
|
|
|
{
|
|
|
|
|
storyMode: PlayStatePlaylist.isStoryMode,
|
2024-05-30 09:25:51 +00:00
|
|
|
|
songId: currentChart.song.id,
|
|
|
|
|
difficultyId: currentDifficulty,
|
2024-07-04 02:50:39 +00:00
|
|
|
|
characterId: currentChart.characters.player,
|
2024-02-27 00:03:04 +00:00
|
|
|
|
title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'),
|
2024-05-18 00:26:34 +00:00
|
|
|
|
prevScoreData: prevScoreData,
|
2024-04-02 01:59:53 +00:00
|
|
|
|
scoreData:
|
|
|
|
|
{
|
2024-04-06 06:06:06 +00:00
|
|
|
|
score: PlayStatePlaylist.isStoryMode ? PlayStatePlaylist.campaignScore : songScore,
|
2024-04-02 01:59:53 +00:00
|
|
|
|
tallies:
|
|
|
|
|
{
|
2024-04-06 06:06:06 +00:00
|
|
|
|
sick: talliesToUse.sick,
|
|
|
|
|
good: talliesToUse.good,
|
|
|
|
|
bad: talliesToUse.bad,
|
|
|
|
|
shit: talliesToUse.shit,
|
|
|
|
|
missed: talliesToUse.missed,
|
|
|
|
|
combo: talliesToUse.combo,
|
|
|
|
|
maxCombo: talliesToUse.maxCombo,
|
|
|
|
|
totalNotesHit: talliesToUse.totalNotesHit,
|
|
|
|
|
totalNotes: talliesToUse.totalNotes,
|
2024-04-02 01:59:53 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
isNewHighscore: isNewHighscore
|
2024-02-27 00:03:04 +00:00
|
|
|
|
});
|
2024-06-02 03:36:57 +00:00
|
|
|
|
this.persistentDraw = false;
|
2024-02-27 00:03:04 +00:00
|
|
|
|
openSubState(res);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Pauses music and vocals easily.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
public function pauseMusic():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-05-01 03:24:43 +00:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.pause();
|
|
|
|
|
if (vocals != null) vocals.pause();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resets the camera's zoom level and focus point.
|
|
|
|
|
*/
|
2024-03-10 23:35:41 +00:00
|
|
|
|
public function resetCamera(?resetZoom:Bool = true, ?cancelTweens:Bool = true):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-03-10 23:35:41 +00:00
|
|
|
|
// Cancel camera tweens if any are active.
|
|
|
|
|
if (cancelTweens)
|
2024-02-28 06:29:40 +00:00
|
|
|
|
{
|
2024-03-10 23:35:41 +00:00
|
|
|
|
cancelAllCameraTweens();
|
2024-02-28 06:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-08 00:26:17 +00:00
|
|
|
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, Constants.DEFAULT_CAMERA_FOLLOW_RATE);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
FlxG.camera.targetOffset.set();
|
2024-02-28 06:29:40 +00:00
|
|
|
|
|
|
|
|
|
if (resetZoom)
|
|
|
|
|
{
|
2024-03-16 15:38:10 +00:00
|
|
|
|
resetCameraZoom();
|
2024-02-28 06:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
|
// Snap the camera to the follow point immediately.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 19:34:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* Sets the camera follow point's position and tweens the camera there.
|
|
|
|
|
*/
|
|
|
|
|
public function tweenCameraToPosition(?x:Float, ?y:Float, ?duration:Float, ?ease:Null<Float->Float>):Void
|
|
|
|
|
{
|
|
|
|
|
cameraFollowPoint.setPosition(x, y);
|
|
|
|
|
tweenCameraToFollowPoint(duration, ease);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 06:29:40 +00:00
|
|
|
|
/**
|
|
|
|
|
* Disables camera following and tweens the camera to the follow point manually.
|
|
|
|
|
*/
|
2024-03-10 23:35:41 +00:00
|
|
|
|
public function tweenCameraToFollowPoint(?duration:Float, ?ease:Null<Float->Float>):Void
|
2024-02-28 06:29:40 +00:00
|
|
|
|
{
|
|
|
|
|
// Cancel the current tween if it's active.
|
2024-03-10 23:35:41 +00:00
|
|
|
|
cancelCameraFollowTween();
|
|
|
|
|
|
|
|
|
|
if (duration == 0)
|
|
|
|
|
{
|
|
|
|
|
// Instant movement. Just reset the camera to force it to the follow point.
|
|
|
|
|
resetCamera(false, false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Disable camera following for the duration of the tween.
|
|
|
|
|
FlxG.camera.target = null;
|
|
|
|
|
|
|
|
|
|
// Follow tween! Caching it so we can cancel/pause it later if needed.
|
|
|
|
|
var followPos:FlxPoint = cameraFollowPoint.getPosition() - FlxPoint.weak(FlxG.camera.width * 0.5, FlxG.camera.height * 0.5);
|
|
|
|
|
cameraFollowTween = FlxTween.tween(FlxG.camera.scroll, {x: followPos.x, y: followPos.y}, duration,
|
|
|
|
|
{
|
|
|
|
|
ease: ease,
|
|
|
|
|
onComplete: function(_) {
|
|
|
|
|
resetCamera(false, false); // Re-enable camera following when the tween is complete.
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cancelCameraFollowTween()
|
|
|
|
|
{
|
2024-02-28 06:29:40 +00:00
|
|
|
|
if (cameraFollowTween != null)
|
|
|
|
|
{
|
|
|
|
|
cameraFollowTween.cancel();
|
|
|
|
|
}
|
2024-03-10 23:35:41 +00:00
|
|
|
|
}
|
2024-02-28 06:29:40 +00:00
|
|
|
|
|
2024-03-10 23:35:41 +00:00
|
|
|
|
/**
|
2024-03-16 15:38:10 +00:00
|
|
|
|
* Tweens the camera zoom to the desired amount.
|
2024-03-10 23:35:41 +00:00
|
|
|
|
*/
|
2024-03-28 18:05:38 +00:00
|
|
|
|
public function tweenCameraZoom(?zoom:Float, ?duration:Float, ?direct:Bool, ?ease:Null<Float->Float>):Void
|
2024-03-10 23:35:41 +00:00
|
|
|
|
{
|
|
|
|
|
// Cancel the current tween if it's active.
|
|
|
|
|
cancelCameraZoomTween();
|
2024-02-28 06:29:40 +00:00
|
|
|
|
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Direct mode: Set zoom directly.
|
|
|
|
|
// Stage mode: Set zoom as a multiplier of the current stage's default zoom.
|
|
|
|
|
var targetZoom = zoom * (direct ? FlxCamera.defaultZoom : stageZoom);
|
2024-03-10 23:35:41 +00:00
|
|
|
|
|
2024-03-28 18:05:38 +00:00
|
|
|
|
if (duration == 0)
|
2024-03-10 23:35:41 +00:00
|
|
|
|
{
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Instant zoom. No tween needed.
|
|
|
|
|
currentCameraZoom = targetZoom;
|
2024-03-10 23:35:41 +00:00
|
|
|
|
}
|
2024-03-28 18:05:38 +00:00
|
|
|
|
else
|
2024-03-10 23:35:41 +00:00
|
|
|
|
{
|
2024-03-28 18:05:38 +00:00
|
|
|
|
// Zoom tween! Caching it so we can cancel/pause it later if needed.
|
|
|
|
|
cameraZoomTween = FlxTween.tween(this, {currentCameraZoom: targetZoom}, duration, {ease: ease});
|
2024-03-10 23:35:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cancelCameraZoomTween()
|
|
|
|
|
{
|
|
|
|
|
if (cameraZoomTween != null)
|
|
|
|
|
{
|
|
|
|
|
cameraZoomTween.cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cancel all active camera tweens simultaneously.
|
|
|
|
|
*/
|
|
|
|
|
public function cancelAllCameraTweens()
|
|
|
|
|
{
|
|
|
|
|
cancelCameraFollowTween();
|
|
|
|
|
cancelCameraZoomTween();
|
2024-02-28 06:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 16:17:09 +00:00
|
|
|
|
var prevScrollTargets:Array<Dynamic> = []; // used to snap scroll speed when things go unruely
|
|
|
|
|
|
2024-05-09 16:51:03 +00:00
|
|
|
|
/**
|
2024-05-10 20:23:35 +00:00
|
|
|
|
* The magical function that shall tween the scroll speed.
|
2024-05-09 16:51:03 +00:00
|
|
|
|
*/
|
2024-05-10 20:23:35 +00:00
|
|
|
|
public function tweenScrollSpeed(?speed:Float, ?duration:Float, ?ease:Null<Float->Float>, strumlines:Array<String>):Void
|
2024-05-09 16:51:03 +00:00
|
|
|
|
{
|
|
|
|
|
// Cancel the current tween if it's active.
|
2024-05-10 20:23:35 +00:00
|
|
|
|
cancelScrollSpeedTweens();
|
2024-05-15 16:17:09 +00:00
|
|
|
|
|
|
|
|
|
// Snap to previous event value to prevent the tween breaking when another event cancels the previous tween.
|
|
|
|
|
for (i in prevScrollTargets)
|
|
|
|
|
{
|
2024-05-15 16:24:04 +00:00
|
|
|
|
var value:Float = i[0];
|
|
|
|
|
var strum:Strumline = Reflect.getProperty(this, i[1]);
|
2024-05-15 16:17:09 +00:00
|
|
|
|
strum.scrollSpeed = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// for next event, clean array.
|
|
|
|
|
prevScrollTargets = [];
|
|
|
|
|
|
2024-05-10 20:23:35 +00:00
|
|
|
|
for (i in strumlines)
|
2024-05-09 16:51:03 +00:00
|
|
|
|
{
|
2024-05-10 20:23:35 +00:00
|
|
|
|
var value:Float = speed;
|
|
|
|
|
var strum:Strumline = Reflect.getProperty(this, i);
|
|
|
|
|
|
|
|
|
|
if (duration == 0)
|
|
|
|
|
{
|
|
|
|
|
strum.scrollSpeed = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
scrollSpeedTweens.push(FlxTween.tween(strum,
|
|
|
|
|
{
|
|
|
|
|
'scrollSpeed': value
|
|
|
|
|
}, duration, {ease: ease}));
|
|
|
|
|
}
|
2024-05-15 16:17:09 +00:00
|
|
|
|
// make sure charts dont break if the charter is dumb and stupid
|
|
|
|
|
prevScrollTargets.push([value, i]);
|
2024-05-09 16:51:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 20:23:35 +00:00
|
|
|
|
public function cancelScrollSpeedTweens()
|
2024-05-09 16:51:03 +00:00
|
|
|
|
{
|
2024-05-10 20:23:35 +00:00
|
|
|
|
for (tween in scrollSpeedTweens)
|
2024-05-09 16:51:03 +00:00
|
|
|
|
{
|
2024-05-10 20:23:35 +00:00
|
|
|
|
if (tween != null)
|
|
|
|
|
{
|
|
|
|
|
tween.cancel();
|
|
|
|
|
}
|
2024-05-09 16:51:03 +00:00
|
|
|
|
}
|
2024-05-10 20:37:46 +00:00
|
|
|
|
scrollSpeedTweens = [];
|
2024-05-09 16:51:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-13 05:29:46 +00:00
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-01-23 00:55:30 +00:00
|
|
|
|
/**
|
2023-06-22 05:41:01 +00:00
|
|
|
|
* Jumps forward or backward a number of sections in the song.
|
|
|
|
|
* Accounts for BPM changes, does not prevent death from skipped notes.
|
|
|
|
|
* @param sections The number of sections to jump, negative to go backwards.
|
2023-01-23 00:55:30 +00:00
|
|
|
|
*/
|
2023-06-22 05:41:01 +00:00
|
|
|
|
function changeSection(sections:Int):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
|
{
|
2024-02-27 00:03:04 +00:00
|
|
|
|
// FlxG.sound.music.pause();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
var targetTimeSteps:Float = Conductor.instance.currentStepTime + (Conductor.instance.stepsPerMeasure * sections);
|
2023-12-14 21:56:20 +00:00
|
|
|
|
var targetTimeMs:Float = Conductor.instance.getStepTimeInMs(targetTimeSteps);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2024-02-27 00:03:04 +00:00
|
|
|
|
// Don't go back in time to before the song started.
|
|
|
|
|
targetTimeMs = Math.max(0, targetTimeMs);
|
|
|
|
|
|
2024-03-29 02:33:50 +00:00
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.time = targetTimeMs;
|
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-07-27 00:03:31 +00:00
|
|
|
|
handleSkippedNotes();
|
2024-02-27 00:03:04 +00:00
|
|
|
|
SongEventRegistry.handleSkippedEvents(songEvents, Conductor.instance.songPosition);
|
2023-07-27 00:03:31 +00:00
|
|
|
|
// regenNoteData(FlxG.sound.music.time);
|
2023-06-02 19:35:01 +00:00
|
|
|
|
|
2024-04-25 03:50:19 +00:00
|
|
|
|
Conductor.instance.update(FlxG.sound?.music?.time ?? 0.0);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
2023-06-22 05:41:01 +00:00
|
|
|
|
resyncVocals();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
}
|
2023-06-22 05:41:01 +00:00
|
|
|
|
#end
|
2021-08-27 22:08:01 +00:00
|
|
|
|
}
|