2022-03-08 03:13:53 -05:00
|
|
|
|
package funkin.play;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
|
2023-06-13 01:04:29 -04:00
|
|
|
|
import flixel.sound.FlxSound;
|
2023-06-06 17:38:31 -04:00
|
|
|
|
import funkin.ui.story.StoryMenuState;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
import flixel.addons.display.FlxPieDial;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
2020-10-25 16:51:06 -04:00
|
|
|
|
import flixel.FlxCamera;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
import flixel.FlxObject;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
|
import flixel.FlxState;
|
2020-10-09 17:24:20 -04:00
|
|
|
|
import flixel.FlxSubState;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
|
import flixel.input.keyboard.FlxKey;
|
2020-10-05 05:48:30 -04:00
|
|
|
|
import flixel.math.FlxMath;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
import flixel.math.FlxPoint;
|
2021-01-16 17:21:06 -05:00
|
|
|
|
import flixel.math.FlxRect;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
import flixel.text.FlxText;
|
2020-10-05 14:24:51 -04:00
|
|
|
|
import flixel.tweens.FlxEase;
|
2020-10-03 15:32:15 -04:00
|
|
|
|
import flixel.tweens.FlxTween;
|
2020-10-05 16:32:41 -04:00
|
|
|
|
import flixel.ui.FlxBar;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
import flixel.util.FlxColor;
|
2020-10-05 01:13:12 -04:00
|
|
|
|
import flixel.util.FlxSort;
|
2020-10-03 15:32:15 -04:00
|
|
|
|
import flixel.util.FlxTimer;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
import funkin.audio.VoicesGroup;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
import funkin.Highscore.Tallies;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
import funkin.modding.events.ScriptEvent;
|
|
|
|
|
import funkin.modding.events.ScriptEventDispatcher;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
import funkin.Note;
|
2022-04-18 20:39:41 -04:00
|
|
|
|
import funkin.play.character.BaseCharacter;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
import funkin.play.cutscene.VanillaCutscenes;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
import funkin.play.cutscene.VideoCutscene;
|
|
|
|
|
import funkin.play.event.SongEventData.SongEventParser;
|
2022-07-06 21:49:42 -04:00
|
|
|
|
import funkin.play.scoring.Scoring;
|
2022-09-22 06:34:03 -04:00
|
|
|
|
import funkin.play.song.Song;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
import funkin.play.song.SongData.SongDataParser;
|
2023-01-27 02:38:37 -05:00
|
|
|
|
import funkin.play.song.SongData.SongEventData;
|
2022-09-22 06:34:03 -04:00
|
|
|
|
import funkin.play.song.SongData.SongNoteData;
|
|
|
|
|
import funkin.play.song.SongData.SongPlayableChar;
|
|
|
|
|
import funkin.play.song.SongValidator;
|
2022-03-08 03:13:53 -05:00
|
|
|
|
import funkin.play.stage.Stage;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
import funkin.play.stage.StageData.StageDataParser;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
import funkin.play.Strumline.StrumlineArrow;
|
|
|
|
|
import funkin.play.Strumline.StrumlineStyle;
|
2022-03-08 03:13:53 -05:00
|
|
|
|
import funkin.ui.PopUpStuff;
|
|
|
|
|
import funkin.ui.PreferencesMenu;
|
2023-06-01 18:52:58 -04:00
|
|
|
|
import funkin.ui.stageBuildShit.StageOffsetSubState;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
import funkin.util.Constants;
|
2023-03-18 15:47:23 -04:00
|
|
|
|
import funkin.util.SerializerUtil;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
import funkin.util.SortUtil;
|
2022-03-09 10:29:03 -05:00
|
|
|
|
import lime.ui.Haptic;
|
2021-03-22 10:09:46 -04:00
|
|
|
|
#if discord_rpc
|
2021-03-21 16:29:47 -04:00
|
|
|
|
import Discord.DiscordClient;
|
|
|
|
|
#end
|
|
|
|
|
|
2023-06-02 15:35:01 -04: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,
|
|
|
|
|
/**
|
|
|
|
|
* The character to play as.
|
|
|
|
|
* @default `bf`, or the first character in the song's character list.
|
|
|
|
|
*/
|
|
|
|
|
?targetCharacter:String,
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
/**
|
|
|
|
|
* The gameplay state, where all the rhythm gaming happens.
|
|
|
|
|
*/
|
2022-08-16 20:26:34 -04:00
|
|
|
|
class PlayState extends MusicBeatState
|
2020-10-03 02:50:15 -04:00
|
|
|
|
{
|
2023-01-22 19:55:30 -05: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 15:35:01 -04:00
|
|
|
|
* There should be only one PlayState in existance at a time, we can use a singleton.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
|
|
|
|
public static var instance:PlayState = null;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04: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-22 19:55:30 -05:00
|
|
|
|
*/
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The currently selected stage.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentSong:Song = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The currently selected difficulty.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The player character being used for this level, as a character ID.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentPlayerId:String = 'bf';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-01-27 02:38:37 -05:00
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The currently active Stage. This is the object containing all the props.
|
2023-01-27 02:38:37 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentStage:Stage = null;
|
2023-01-27 02:38:37 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
/**
|
|
|
|
|
* Data for the current difficulty for the current song.
|
|
|
|
|
* Includes chart data, scroll speed, and other information.
|
2023-02-21 20:58:15 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentChart(get, null):SongDifficulty;
|
2023-01-27 02:38:37 -05:00
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The internal ID of the currently active Stage.
|
|
|
|
|
* Used to retrieve the data required to build the `currentStage`.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var currentStageId(get, null):String;
|
2023-01-22 19:55:30 -05: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 15:35:01 -04:00
|
|
|
|
public var needsReset:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The current 'Blueball Counter' to display in the pause menu.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
* Resets when you beat a song or go back to the main menu.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var deathCounter:Int = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The player's current health.
|
|
|
|
|
* The default maximum health is 2.0, and the default starting health is 1.0.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var health:Float = 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The player's current score.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var songScore:Int = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* An empty FlxObject contained in the scene.
|
|
|
|
|
* The current gameplay camera will be centered on this object. Tween its position to move the camera smoothly.
|
2023-06-09 15:34:56 -04:00
|
|
|
|
*
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* This is an FlxSprite for two reasons:
|
|
|
|
|
* 1. It needs to be an object in the scene for the camera to be configured to follow it.
|
|
|
|
|
* 2. It needs to be an FlxSprite to allow a graphic (optionally, for debug purposes) to be drawn on it.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var cameraFollowPoint:FlxSprite = new FlxSprite(0, 0);
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The camera follow point from the last stage.
|
|
|
|
|
* Used to persist the position of the `cameraFollowPosition` between levels.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var previousCameraFollowPoint:FlxSprite = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
/**
|
|
|
|
|
* The current camera zoom level.
|
2023-06-09 15:34:56 -04:00
|
|
|
|
*
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The camera zoom is increased every beat, and lerped back to this value every frame, creating a smooth 'zoom-in' effect.
|
|
|
|
|
* Defaults to 1.05 but may be larger or smaller depending on the current stage,
|
|
|
|
|
* and may be changed by the `ZoomCamera` song event.
|
|
|
|
|
*/
|
|
|
|
|
public var defaultCameraZoom:Float = FlxCamera.defaultZoom * 1.05;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The current HUD camera zoom level.
|
2023-06-09 15:34:56 -04:00
|
|
|
|
*
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* The camera zoom is increased every beat, and lerped back to this value every frame, creating a smooth 'zoom-in' effect.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var defaultHUDCameraZoom:Float = FlxCamera.defaultZoom * 1.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* Intensity of the gameplay camera zoom.
|
|
|
|
|
* @default `1.5%`
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var cameraZoomIntensity:Float = Constants.DEFAULT_ZOOM_INTENSITY;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* Intensity of the HUD camera zoom.
|
|
|
|
|
* @default `3.0%`
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public var hudCameraZoomIntensity:Float = Constants.DEFAULT_ZOOM_INTENSITY * 2.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* How many beats (quarter notes) between camera zooms.
|
|
|
|
|
* @default One camera zoom per measure (four beats).
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04: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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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-22 19:55:30 -05: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.
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* The Array containing the notes that are not currently on the screen.
|
|
|
|
|
* The `update()` function regularly shifts these out to add new notes to the screen.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var inactiveNotes:Array<Note>;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
/**
|
|
|
|
|
* The Array containing the upcoming song events.
|
|
|
|
|
* The `update()` function regularly shifts these out to trigger events.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var songEvents:Array<SongEventData>;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If true, the player is allowed to pause the game.
|
|
|
|
|
* Disabled during the ending of a song.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var mayPauseGame:Bool = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The displayed value of the player's health.
|
|
|
|
|
* Used to provide smooth animations based on linear interpolation of the player's health.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var healthLerp:Float = 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
/**
|
|
|
|
|
* How long the user has held the "Skip Video Cutscene" button for.
|
|
|
|
|
*/
|
|
|
|
|
var skipHeldTimer:Float = 0;
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
/**
|
|
|
|
|
* Forcibly disables all update logic while the game moves back to the Menu state.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* This is used only when a critical error occurs and the game absolutely cannot continue.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var criticalFailure:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
/**
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* False as long as the countdown has not finished yet.
|
|
|
|
|
*/
|
|
|
|
|
var startingSong:Bool = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A group of audio tracks, used to play the song's vocals.
|
2023-02-21 20:58:15 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var vocals:VoicesGroup;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
/**
|
|
|
|
|
* RENDER OBJECTS
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* The SpriteGroup containing the notes that are currently on the screen or are about to be on the screen.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var activeNotes:FlxTypedGroup<Note> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The FlxText which displays the current score.
|
|
|
|
|
*/
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var scoreText:FlxText;
|
2023-01-22 19:55:30 -05: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`.
|
|
|
|
|
*/
|
|
|
|
|
public var healthBarBG:FlxSprite;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
public var enemyStrumline:Strumline;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
public var camGame:FlxCamera;
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
/**
|
|
|
|
|
* The camera which contains, and controls visibility of, a video cutscene.
|
|
|
|
|
*/
|
|
|
|
|
public var camCutscene:FlxCamera;
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var skipTimer:FlxPieDial;
|
|
|
|
|
|
2023-01-22 19:55:30 -05: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-22 22:25:45 -05:00
|
|
|
|
var isGamePaused(get, never):Bool;
|
2023-01-22 19:55:30 -05: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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
var gfSpeed:Int = 1;
|
|
|
|
|
var generatedMusic:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
var grpNoteSplashes:FlxTypedGroup<NoteSplash>;
|
|
|
|
|
var comboPopUps:PopUpStuff;
|
|
|
|
|
var perfectMode:Bool = false;
|
|
|
|
|
var previousFrameTime:Int = 0;
|
|
|
|
|
var songTime:Float = 0;
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Discord RPC variables
|
2023-02-21 20:58:15 -05:00
|
|
|
|
var storyDifficultyText:String = '';
|
|
|
|
|
var iconRPC:String = '';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
var songLength:Float = 0;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
var detailsText:String = '';
|
|
|
|
|
var detailsPausedText:String = '';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
|
2023-06-02 15:35:01 -04: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;
|
|
|
|
|
|
|
|
|
|
public function new(params:PlayStateParams)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
super();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (params == null && lastParams == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
throw 'PlayState constructor called with no available parameters.';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
else if (params == null)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: PlayState constructor called with no parameters. Reusing previous parameters.');
|
|
|
|
|
params = lastParams;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lastParams = params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentSong = params.targetSong;
|
|
|
|
|
if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty;
|
|
|
|
|
if (params.targetCharacter != null) currentPlayerId = params.targetCharacter;
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public override function create():Void
|
|
|
|
|
{
|
|
|
|
|
super.create();
|
|
|
|
|
|
|
|
|
|
if (instance != null)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: PlayState instance already exists. This should not happen.');
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
instance = this;
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
// TODO: Do this in the loading state.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
currentSong.cacheCharts(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns null if the song failed to load or doesn't have the selected difficulty.
|
|
|
|
|
if (currentChart == null)
|
|
|
|
|
{
|
|
|
|
|
criticalFailure = true;
|
|
|
|
|
|
|
|
|
|
var message:String = 'There was a critical error. Click OK to return to the main menu.';
|
|
|
|
|
|
|
|
|
|
if (currentSong == null)
|
|
|
|
|
{
|
|
|
|
|
message = 'The was a critical error loading this song\'s chart. Click OK to return to the main menu.';
|
|
|
|
|
}
|
|
|
|
|
else if (currentDifficulty == null)
|
|
|
|
|
{
|
|
|
|
|
message = 'The was a critical error selecting a difficulty for this song. Click OK to return to the main menu.';
|
|
|
|
|
}
|
|
|
|
|
else if (currentSong.getDifficulty(currentDifficulty) == null)
|
|
|
|
|
{
|
|
|
|
|
message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty. Click OK to return to the main menu.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lime.app.Application.current.window.alert(message, 'Error loading PlayState');
|
|
|
|
|
FlxG.switchState(new MainMenuState());
|
|
|
|
|
return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Displays the camera follow point as a sprite for debug purposes.
|
|
|
|
|
// TODO: Put this on a toggle?
|
|
|
|
|
cameraFollowPoint.makeGraphic(8, 8, 0xFF00FF00);
|
|
|
|
|
cameraFollowPoint.visible = false;
|
|
|
|
|
cameraFollowPoint.zIndex = 1000000;
|
|
|
|
|
|
|
|
|
|
// 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-01-22 22:25:45 -05:00
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.stop();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// Prepare the current song to be played.
|
|
|
|
|
if (currentChart != null)
|
|
|
|
|
{
|
|
|
|
|
currentChart.cacheInst();
|
2023-06-02 15:35:01 -04:00
|
|
|
|
currentChart.cacheVocals(currentPlayerId);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize stage stuff.
|
|
|
|
|
initCameras();
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Conductor.mapTimeChanges(currentChart.timeChanges);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
Conductor.update(-5000);
|
|
|
|
|
|
|
|
|
|
// Once the song is loaded, we can continue and initialize the stage.
|
|
|
|
|
|
|
|
|
|
var healthBarYPos:Float = PreferencesMenu.getPref('downscroll') ? FlxG.height * 0.1 : FlxG.height * 0.9;
|
|
|
|
|
healthBarBG = new FlxSprite(0, healthBarYPos).loadGraphic(Paths.image('healthBar'));
|
|
|
|
|
healthBarBG.screenCenter(X);
|
|
|
|
|
healthBarBG.scrollFactor.set(0, 0);
|
|
|
|
|
add(healthBarBG);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
add(healthBar);
|
|
|
|
|
|
|
|
|
|
initStage();
|
|
|
|
|
initCharacters();
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
initDiscord();
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
// Configure camera follow point.
|
|
|
|
|
if (previousCameraFollowPoint != null)
|
|
|
|
|
{
|
|
|
|
|
cameraFollowPoint.setPosition(previousCameraFollowPoint.x, previousCameraFollowPoint.y);
|
|
|
|
|
previousCameraFollowPoint = null;
|
|
|
|
|
}
|
|
|
|
|
add(cameraFollowPoint);
|
|
|
|
|
|
|
|
|
|
comboPopUps = new PopUpStuff();
|
|
|
|
|
comboPopUps.cameras = [camHUD];
|
|
|
|
|
add(comboPopUps);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
buildStrumlines();
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
grpNoteSplashes = new FlxTypedGroup<NoteSplash>();
|
|
|
|
|
|
|
|
|
|
var noteSplash:NoteSplash = new NoteSplash(100, 100, 0);
|
|
|
|
|
grpNoteSplashes.add(noteSplash);
|
|
|
|
|
noteSplash.alpha = 0.1;
|
|
|
|
|
|
|
|
|
|
add(grpNoteSplashes);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
generateSong();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
resetCamera();
|
|
|
|
|
|
|
|
|
|
FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
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);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
scoreText.scrollFactor.set();
|
|
|
|
|
add(scoreText);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Skip Video Cutscene
|
|
|
|
|
skipTimer = new FlxPieDial(16, 16, 32, FlxColor.WHITE, 36, CIRCLE, true, 24);
|
|
|
|
|
skipTimer.amount = 0;
|
|
|
|
|
skipTimer.zIndex = 1000;
|
|
|
|
|
// Renders only in video cutscene mode.
|
|
|
|
|
skipTimer.cameras = [camCutscene];
|
|
|
|
|
add(skipTimer);
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
// Attach the groups to the HUD camera so they are rendered independent of the stage.
|
|
|
|
|
grpNoteSplashes.cameras = [camHUD];
|
|
|
|
|
activeNotes.cameras = [camHUD];
|
|
|
|
|
healthBar.cameras = [camHUD];
|
|
|
|
|
healthBarBG.cameras = [camHUD];
|
|
|
|
|
iconP1.cameras = [camHUD];
|
|
|
|
|
iconP2.cameras = [camHUD];
|
|
|
|
|
scoreText.cameras = [camHUD];
|
|
|
|
|
leftWatermarkText.cameras = [camHUD];
|
|
|
|
|
rightWatermarkText.cameras = [camHUD];
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
// Starting song!
|
2023-01-22 19:55:30 -05:00
|
|
|
|
startingSong = true;
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
// TODO: Softcode cutscenes.
|
|
|
|
|
// TODO: Alternatively: make a song script that allows startCountdown to be called,
|
|
|
|
|
// then cancels the countdown, hides the UI, plays the cutscene,
|
|
|
|
|
// then calls PlayState.startCountdown later?
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
switch (currentSong.songId.toLowerCase())
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
case 'winter-horrorland':
|
2023-01-22 19:55:30 -05:00
|
|
|
|
VanillaCutscenes.playHorrorStartCutscene();
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// This one is softcoded now WOOOO!
|
|
|
|
|
// case 'senpai' | 'roses' | 'thorns':
|
|
|
|
|
// schoolIntro(doof);
|
|
|
|
|
// case 'ugh':
|
|
|
|
|
// VanillaCutscenes.playUghCutscene();
|
|
|
|
|
// case 'stress':
|
|
|
|
|
// VanillaCutscenes.playStressCutscene();
|
|
|
|
|
// case 'guns':
|
|
|
|
|
// VanillaCutscenes.playGunsCutscene();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
default:
|
|
|
|
|
// VanillaCutscenes will call startCountdown later.
|
|
|
|
|
startCountdown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
startCountdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
this.rightWatermarkText.text = Constants.VERSION;
|
|
|
|
|
#end
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
FlxG.console.registerObject('playState', this);
|
|
|
|
|
#end
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_currentChart():SongDifficulty
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong == null || currentDifficulty == null) return null;
|
|
|
|
|
return currentSong.getDifficulty(currentDifficulty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_currentStageId():String
|
|
|
|
|
{
|
|
|
|
|
if (currentChart == null || currentChart.stage == null || currentChart.stage == '') return Constants.DEFAULT_STAGE;
|
|
|
|
|
return currentChart.stage;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initializes the game and HUD cameras.
|
|
|
|
|
*/
|
2023-02-21 20:58:15 -05:00
|
|
|
|
function initCameras():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Set the camera zoom. This gets overridden by the value in the stage data.
|
|
|
|
|
// defaultCameraZoom = FlxCamera.defaultZoom * 1.05;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
camGame = new SwagCamera();
|
|
|
|
|
camHUD = new FlxCamera();
|
|
|
|
|
camHUD.bgColor.alpha = 0;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
camCutscene = new FlxCamera();
|
|
|
|
|
camCutscene.bgColor.alpha = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
FlxG.cameras.reset(camGame);
|
|
|
|
|
FlxG.cameras.add(camHUD, false);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
FlxG.cameras.add(camCutscene, false);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
function initStage():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentChart == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
trace('Song difficulty could not be loaded.');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
loadStage(currentStageId);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
else
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Fallback.
|
|
|
|
|
loadStage('mainStage');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
function initCharacters():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong == null || currentChart == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Switch playable character by manipulating this value.
|
|
|
|
|
// TODO: How to choose which one to use for story mode?
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var playableChars:Array<String> = currentChart.getPlayableChars();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (playableChars.length == 0)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: No playable characters found for this song.');
|
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
else if (playableChars.indexOf(currentPlayerId) == -1)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
currentPlayerId = playableChars[0];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var currentCharData:SongPlayableChar = currentChart.getPlayableChar(currentPlayerId);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// GIRLFRIEND
|
|
|
|
|
//
|
|
|
|
|
var girlfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharData.girlfriend);
|
|
|
|
|
|
|
|
|
|
if (girlfriend != null)
|
|
|
|
|
{
|
|
|
|
|
girlfriend.characterType = CharacterType.GF;
|
|
|
|
|
}
|
|
|
|
|
else if (currentCharData.girlfriend != '')
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: Could not load girlfriend character with ID ${currentCharData.girlfriend}, skipping...');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Chosen GF was '' so we don't load one.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// DAD
|
|
|
|
|
//
|
|
|
|
|
var dad:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharData.opponent);
|
|
|
|
|
|
|
|
|
|
if (dad != null)
|
|
|
|
|
{
|
|
|
|
|
dad.characterType = CharacterType.DAD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// OPPONENT HEALTH ICON
|
|
|
|
|
//
|
|
|
|
|
iconP2 = new HealthIcon(currentCharData.opponent, 1);
|
|
|
|
|
iconP2.y = healthBar.y - (iconP2.height / 2);
|
2023-06-02 15:35:01 -04:00
|
|
|
|
dad.initHealthIcon(true);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
add(iconP2);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// BOYFRIEND
|
|
|
|
|
//
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var boyfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentPlayerId);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (boyfriend != null)
|
|
|
|
|
{
|
|
|
|
|
boyfriend.characterType = CharacterType.BF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// PLAYER HEALTH ICON
|
|
|
|
|
//
|
2023-06-02 15:35:01 -04:00
|
|
|
|
iconP1 = new HealthIcon(currentPlayerId, 0);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
iconP1.y = healthBar.y - (iconP1.height / 2);
|
2023-06-02 15:35:01 -04:00
|
|
|
|
boyfriend.initHealthIcon(false);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
add(iconP1);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// ADD CHARACTERS TO SCENE
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
if (currentStage != null)
|
|
|
|
|
{
|
|
|
|
|
// Characters get added to the stage, not the main scene.
|
|
|
|
|
if (girlfriend != null)
|
|
|
|
|
{
|
|
|
|
|
currentStage.addCharacter(girlfriend, GF);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
FlxG.console.registerObject('gf', girlfriend);
|
|
|
|
|
#end
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (boyfriend != null)
|
|
|
|
|
{
|
|
|
|
|
currentStage.addCharacter(boyfriend, BF);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
FlxG.console.registerObject('bf', boyfriend);
|
|
|
|
|
#end
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dad != null)
|
|
|
|
|
{
|
|
|
|
|
currentStage.addCharacter(dad, DAD);
|
|
|
|
|
// Camera starts at dad.
|
|
|
|
|
cameraFollowPoint.setPosition(dad.cameraFocusPoint.x, dad.cameraFocusPoint.y);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
FlxG.console.registerObject('dad', dad);
|
|
|
|
|
#end
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rearrange by z-indexes.
|
|
|
|
|
currentStage.refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes any references to the current stage, then clears the stage cache,
|
|
|
|
|
* then reloads all the stages.
|
2023-06-08 16:30:45 -04:00
|
|
|
|
*
|
2023-01-22 19:55:30 -05: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 16:30:45 -04:00
|
|
|
|
*
|
2023-01-22 19:55:30 -05:00
|
|
|
|
* Call this by pressing F5 on a debug build.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
override function debug_refreshModules():Void
|
2023-01-22 19:55:30 -05: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);
|
|
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.DESTROY, false);
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
|
currentStage = null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Stop the vocals.
|
|
|
|
|
if (vocals != null)
|
|
|
|
|
{
|
|
|
|
|
vocals.stop();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
super.debug_refreshModules();
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
|
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.CREATE, false);
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentSong, event);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pauses music and vocals easily.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public function pauseMusic():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
vocals.pause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads stage data from cache, assembles the props,
|
|
|
|
|
* and adds it to the state.
|
2023-06-08 16:30:45 -04:00
|
|
|
|
* @param id
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
function loadStage(id:String):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
currentStage = StageDataParser.fetchStage(id);
|
|
|
|
|
|
|
|
|
|
if (currentStage != null)
|
|
|
|
|
{
|
|
|
|
|
// Actually create and position the sprites.
|
|
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.CREATE, false);
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Apply camera zoom level from stage data.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
defaultCameraZoom = currentStage.camZoom;
|
|
|
|
|
|
|
|
|
|
// Add the stage to the scene.
|
|
|
|
|
this.add(currentStage);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
FlxG.console.registerObject('stage', currentStage);
|
|
|
|
|
#end
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// lolol
|
|
|
|
|
lime.app.Application.current.window.alert('Nice job, you ignoramus. $id isn\'t a real stage.\nI\'m falling back to the default so the game doesn\'t shit itself.',
|
|
|
|
|
'Stage Error');
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initDiscord():Void
|
|
|
|
|
{
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
storyDifficultyText = difficultyString();
|
|
|
|
|
iconRPC = currentSong.player2;
|
|
|
|
|
|
|
|
|
|
// To avoid having duplicate images in Discord assets
|
|
|
|
|
switch (iconRPC)
|
|
|
|
|
{
|
|
|
|
|
case 'senpai-angry':
|
|
|
|
|
iconRPC = 'senpai';
|
|
|
|
|
case 'monster-christmas':
|
|
|
|
|
iconRPC = 'monster';
|
|
|
|
|
case 'mom-car':
|
|
|
|
|
iconRPC = 'mom';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
|
2023-06-02 15:35:01 -04:00
|
|
|
|
detailsText = isStoryMode ? 'Story Mode: Week $storyWeek' : 'Freeplay';
|
|
|
|
|
detailsPausedText = 'Paused - $detailsText';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// Updating Discord Rich Presence.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startSong():Void
|
|
|
|
|
{
|
|
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_START));
|
|
|
|
|
|
|
|
|
|
startingSong = false;
|
|
|
|
|
|
|
|
|
|
previousFrameTime = FlxG.game.ticks;
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (!isGamePaused && currentChart != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
currentChart.playInst(1.0, false);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlxG.sound.music.onComplete = endSong;
|
|
|
|
|
trace('Playing vocals...');
|
2023-06-13 01:04:29 -04:00
|
|
|
|
add(vocals);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
vocals.play();
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Song duration in a float, useful for the time left feature
|
|
|
|
|
songLength = FlxG.sound.music.length;
|
|
|
|
|
|
|
|
|
|
// Updating Discord Rich Presence (with Time Left)
|
2023-06-02 15:35:01 -04:00
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, songLength);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
function generateSong():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
if (currentChart == null)
|
|
|
|
|
{
|
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-02 15:34:34 -04:00
|
|
|
|
// Conductor.forceBPM(currentChart.getStartingBPM());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
vocals = currentChart.buildVocals(currentPlayerId);
|
|
|
|
|
if (vocals.members.length == 0)
|
|
|
|
|
{
|
|
|
|
|
trace('WARNING: No vocals found for this song.');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the rendered note group.
|
|
|
|
|
activeNotes = new FlxTypedGroup<Note>();
|
|
|
|
|
activeNotes.zIndex = 1000;
|
|
|
|
|
add(activeNotes);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
regenNoteData();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
generatedMusic = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function regenNoteData():Void
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.combo = 0;
|
|
|
|
|
Highscore.tallies = new Tallies();
|
|
|
|
|
|
|
|
|
|
// Reset song events.
|
|
|
|
|
songEvents = currentChart.getEvents();
|
|
|
|
|
SongEventParser.resetEvents(songEvents);
|
|
|
|
|
|
|
|
|
|
// Destroy inactive notes.
|
|
|
|
|
inactiveNotes = [];
|
|
|
|
|
|
|
|
|
|
// Destroy active notes.
|
2023-01-27 02:38:37 -05:00
|
|
|
|
activeNotes.forEach(function(nt) {
|
2023-01-22 19:55:30 -05:00
|
|
|
|
nt.followsTime = false;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
FlxTween.tween(nt, {y: FlxG.height + nt.y}, 0.5,
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
ease: FlxEase.expoIn,
|
2023-01-27 02:38:37 -05:00
|
|
|
|
onComplete: function(twn) {
|
2023-01-22 22:25:45 -05:00
|
|
|
|
nt.kill();
|
|
|
|
|
activeNotes.remove(nt, true);
|
|
|
|
|
nt.destroy();
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var noteData:Array<SongNoteData> = currentChart.notes;
|
|
|
|
|
|
|
|
|
|
var oldNote:Note = null;
|
|
|
|
|
for (songNote in noteData)
|
|
|
|
|
{
|
|
|
|
|
var mustHitNote:Bool = songNote.getMustHitNote();
|
|
|
|
|
|
|
|
|
|
// TODO: Put this in the chart or something?
|
|
|
|
|
var strumlineStyle:StrumlineStyle = null;
|
|
|
|
|
switch (currentStageId)
|
|
|
|
|
{
|
|
|
|
|
case 'school':
|
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
|
case 'schoolEvil':
|
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
|
default:
|
|
|
|
|
strumlineStyle = NORMAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newNote:Note = new Note(songNote.time, songNote.data, oldNote, false, strumlineStyle);
|
|
|
|
|
newNote.mustPress = mustHitNote;
|
|
|
|
|
newNote.data.sustainLength = songNote.length;
|
|
|
|
|
newNote.data.noteKind = songNote.kind;
|
|
|
|
|
newNote.scrollFactor.set(0, 0);
|
|
|
|
|
|
|
|
|
|
// Note positioning.
|
|
|
|
|
// TODO: Make this more robust.
|
|
|
|
|
if (newNote.mustPress)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
newNote.alignToSturmlineArrow(playerStrumline.getArrow(songNote.getDirection()));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
newNote.alignToSturmlineArrow(enemyStrumline.getArrow(songNote.getDirection()));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inactiveNotes.push(newNote);
|
|
|
|
|
|
|
|
|
|
oldNote = newNote;
|
|
|
|
|
|
|
|
|
|
// Generate X sustain notes.
|
2023-06-15 00:29:40 -04:00
|
|
|
|
var sustainSections = Math.round(songNote.length / Conductor.stepLengthMs);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
for (noteIndex in 0...sustainSections)
|
|
|
|
|
{
|
2023-06-15 00:29:40 -04:00
|
|
|
|
var noteTimeOffset:Float = Conductor.stepLengthMs + (Conductor.stepLengthMs * noteIndex);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
var sustainNote:Note = new Note(songNote.time + noteTimeOffset, songNote.data, oldNote, true, strumlineStyle);
|
|
|
|
|
sustainNote.mustPress = mustHitNote;
|
|
|
|
|
sustainNote.data.noteKind = songNote.kind;
|
|
|
|
|
sustainNote.scrollFactor.set(0, 0);
|
|
|
|
|
|
|
|
|
|
if (sustainNote.mustPress)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Align with the strumline arrow.
|
|
|
|
|
sustainNote.alignToSturmlineArrow(playerStrumline.getArrow(songNote.getDirection()));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
sustainNote.alignToSturmlineArrow(enemyStrumline.getArrow(songNote.getDirection()));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inactiveNotes.push(sustainNote);
|
|
|
|
|
|
|
|
|
|
oldNote = sustainNote;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sorting is an expensive operation.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Make this more efficient.
|
|
|
|
|
// DO NOT assume it was done in the chart file. Notes created artificially by sustains are in here too.
|
|
|
|
|
inactiveNotes.sort(function(a:Note, b:Note):Int {
|
|
|
|
|
return SortUtil.byStrumtime(FlxSort.ASCENDING, a, b);
|
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
|
/**
|
|
|
|
|
**/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
override public function onFocus():Void
|
|
|
|
|
{
|
|
|
|
|
if (health > 0 && !paused && FlxG.autoPause)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (Conductor.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC, true,
|
2023-01-22 22:25:45 -05:00
|
|
|
|
songLength - Conductor.songPosition);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
else
|
2023-06-02 15:35:01 -04:00
|
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.onFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override public function onFocusLost():Void
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (health > 0 && !paused && FlxG.autoPause) DiscordClient.changePresence(detailsPausedText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
super.onFocusLost();
|
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
function resyncVocals():Void
|
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (_exiting || vocals == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
vocals.pause();
|
|
|
|
|
|
|
|
|
|
FlxG.sound.music.play();
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Conductor.update();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
vocals.time = FlxG.sound.music.time;
|
|
|
|
|
vocals.play();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public override function update(elapsed:Float):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (criticalFailure) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (FlxG.keys.justPressed.U)
|
|
|
|
|
{
|
|
|
|
|
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
|
2023-01-27 02:38:37 -05:00
|
|
|
|
disableKeys = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
persistentUpdate = false;
|
2023-06-01 18:52:58 -04:00
|
|
|
|
openSubState(new StageOffsetSubState());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateHealthBar();
|
|
|
|
|
updateScoreText();
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Handle restarting the song when needed (player death or pressing Retry)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (needsReset)
|
|
|
|
|
{
|
|
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_RETRY));
|
|
|
|
|
|
|
|
|
|
resetCamera();
|
|
|
|
|
|
|
|
|
|
persistentUpdate = true;
|
|
|
|
|
persistentDraw = true;
|
|
|
|
|
|
|
|
|
|
startingSong = true;
|
|
|
|
|
|
2023-02-22 14:46:46 -05:00
|
|
|
|
inputSpitter = [];
|
|
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
|
// Reset music properly.
|
2023-02-22 15:01:07 -05:00
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
vocals.pause();
|
|
|
|
|
FlxG.sound.music.time = 0;
|
2023-02-21 20:58:15 -05:00
|
|
|
|
vocals.time = 0;
|
|
|
|
|
|
|
|
|
|
FlxG.sound.music.volume = 1;
|
|
|
|
|
vocals.volume = 1;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
vocals.playerVolume = 1;
|
|
|
|
|
vocals.opponentVolume = 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
currentStage.resetStage();
|
|
|
|
|
|
|
|
|
|
// Delete all notes and reset the arrays.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
regenNoteData();
|
|
|
|
|
|
|
|
|
|
// Reset camera zooming
|
|
|
|
|
cameraZoomIntensity = Constants.DEFAULT_ZOOM_INTENSITY;
|
|
|
|
|
hudCameraZoomIntensity = Constants.DEFAULT_ZOOM_INTENSITY * 2.0;
|
|
|
|
|
cameraZoomRate = Constants.DEFAULT_ZOOM_RATE;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
health = 1;
|
|
|
|
|
songScore = 0;
|
|
|
|
|
Highscore.tallies.combo = 0;
|
|
|
|
|
Countdown.performCountdown(currentStageId.startsWith('school'));
|
|
|
|
|
|
|
|
|
|
needsReset = false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Update the conductor.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (startingSong)
|
|
|
|
|
{
|
|
|
|
|
if (isInCountdown)
|
|
|
|
|
{
|
|
|
|
|
Conductor.songPosition += elapsed * 1000;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (Conductor.songPosition >= 0) startSong();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// DO NOT FORGET TO REMOVE THE HARDCODE! WHEN I MAKE BETTER OFFSET SYSTEM!
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// :nerd: um ackshually it's not 13 it's 11.97278911564
|
|
|
|
|
if (Paths.SOUND_EXT == 'mp3') Conductor.offset = Constants.MP3_DELAY_MS;
|
|
|
|
|
|
|
|
|
|
Conductor.update();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (!isGamePaused)
|
|
|
|
|
{
|
|
|
|
|
songTime += FlxG.game.ticks - previousFrameTime;
|
|
|
|
|
previousFrameTime = FlxG.game.ticks;
|
|
|
|
|
|
|
|
|
|
// Interpolation type beat
|
|
|
|
|
if (Conductor.lastSongPos != Conductor.songPosition)
|
|
|
|
|
{
|
|
|
|
|
songTime = (songTime + Conductor.songPosition) / 2;
|
|
|
|
|
Conductor.lastSongPos = Conductor.songPosition;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var androidPause:Bool = false;
|
|
|
|
|
|
|
|
|
|
#if android
|
|
|
|
|
androidPause = FlxG.android.justPressed.BACK;
|
|
|
|
|
#end
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Attempt to pause the game.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if ((controls.PAUSE || androidPause) && isInCountdown && mayPauseGame)
|
|
|
|
|
{
|
|
|
|
|
var event = new PauseScriptEvent(FlxG.random.bool(1 / 1000));
|
|
|
|
|
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
if (!event.eventCanceled)
|
|
|
|
|
{
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
if (event.gitaroo)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
FlxG.switchState(new GitarooPause(
|
|
|
|
|
{
|
|
|
|
|
targetSong: currentSong,
|
|
|
|
|
targetDifficulty: currentDifficulty,
|
|
|
|
|
targetCharacter: currentPlayerId,
|
|
|
|
|
}));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var boyfriendPos:FlxPoint = new FlxPoint(0, 0);
|
|
|
|
|
|
|
|
|
|
// Prevent the game from crashing if Boyfriend isn't present.
|
|
|
|
|
if (currentStage != null && currentStage.getBoyfriend() != null)
|
|
|
|
|
{
|
|
|
|
|
boyfriendPos = currentStage.getBoyfriend().getScreenPosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var pauseSubState:FlxSubState = new PauseSubState();
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
openSubState(pauseSubState);
|
|
|
|
|
pauseSubState.camera = camHUD;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// boyfriendPos.put(); // TODO: Why is this here?
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
2023-06-02 15:35:01 -04:00
|
|
|
|
DiscordClient.changePresence(detailsPausedText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Cap health.
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (health > 2.0) health = 2.0;
|
|
|
|
|
if (health < 0.0) health = 0.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Lerp the camera zoom towards the target level.
|
2023-02-21 20:58:15 -05:00
|
|
|
|
if (subState == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
FlxG.camera.zoom = FlxMath.lerp(defaultCameraZoom, FlxG.camera.zoom, 0.95);
|
2023-06-02 15:35:01 -04:00
|
|
|
|
camHUD.zoom = FlxMath.lerp(defaultHUDCameraZoom, camHUD.zoom, 0.95);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentStage != null)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
FlxG.watch.addQuick('bfAnim', currentStage.getBoyfriend().getCurrentAnimation());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Handle GF dance speed.
|
|
|
|
|
// TODO: Add a song event for this.
|
|
|
|
|
if (currentSong.songId == 'fresh')
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
switch (Conductor.currentBeat)
|
|
|
|
|
{
|
|
|
|
|
case 16:
|
|
|
|
|
gfSpeed = 2;
|
|
|
|
|
case 48:
|
|
|
|
|
gfSpeed = 1;
|
|
|
|
|
case 80:
|
|
|
|
|
gfSpeed = 2;
|
|
|
|
|
case 112:
|
|
|
|
|
gfSpeed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Handle player death.
|
|
|
|
|
if (!isInCutscene && !disableKeys && !_exiting)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
// RESET = Quick Game Over Screen
|
|
|
|
|
if (controls.RESET)
|
|
|
|
|
{
|
|
|
|
|
health = 0;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
trace('RESET = True');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if CAN_CHEAT // brandon's a pussy
|
|
|
|
|
if (controls.CHEAT)
|
|
|
|
|
{
|
|
|
|
|
health += 1;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
trace('User is cheating!');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (health <= 0 && !isPracticeMode)
|
|
|
|
|
{
|
|
|
|
|
vocals.pause();
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
|
|
|
|
|
deathCounter += 1;
|
|
|
|
|
|
|
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.GAME_OVER));
|
|
|
|
|
|
|
|
|
|
// Disable updates, preventing animations in the background from playing.
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
#if debug
|
|
|
|
|
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;
|
|
|
|
|
#if debug
|
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
|
2023-06-01 18:52:58 -04:00
|
|
|
|
var gameOverSubState = new GameOverSubState();
|
|
|
|
|
openSubState(gameOverSubState);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
|
// Game Over doesn't get his own variable because it's only used here
|
2023-06-02 15:35:01 -04:00
|
|
|
|
DiscordClient.changePresence('Game Over - ' + detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Iterate over inactive notes.
|
|
|
|
|
while (inactiveNotes[0] != null && inactiveNotes[0].data.strumTime - Conductor.songPosition < 1800 / currentChart.scrollSpeed)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
var dunceNote:Note = inactiveNotes[0];
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (dunceNote.mustPress && !dunceNote.isSustainNote) Highscore.tallies.totalNotes++;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
activeNotes.add(dunceNote);
|
|
|
|
|
|
|
|
|
|
inactiveNotes.shift();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Iterate over active notes.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (generatedMusic && playerStrumline != null)
|
|
|
|
|
{
|
2023-01-27 02:38:37 -05:00
|
|
|
|
activeNotes.forEachAlive(function(daNote:Note) {
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if ((PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|
|
|
|
|
|| (!PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
|
|
|
|
|
{
|
|
|
|
|
daNote.active = false;
|
|
|
|
|
daNote.visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
daNote.visible = true;
|
|
|
|
|
daNote.active = true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var strumLineMid:Float = playerStrumline.y + Note.swagWidth / 2;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (daNote.followsTime)
|
|
|
|
|
{
|
|
|
|
|
daNote.y = (Conductor.songPosition - daNote.data.strumTime) * (0.45 * FlxMath.roundDecimal(currentChart.scrollSpeed, 2) * daNote.noteSpeedMulti);
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (PreferencesMenu.getPref('downscroll'))
|
|
|
|
|
{
|
|
|
|
|
daNote.y += playerStrumline.y;
|
|
|
|
|
if (daNote.isSustainNote)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (daNote.animation.curAnim.name.endsWith('end') && daNote.prevNote != null)
|
|
|
|
|
{
|
|
|
|
|
daNote.y += daNote.prevNote.height;
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
else
|
2023-06-02 15:35:01 -04:00
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
|
daNote.y += daNote.height / 2;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if ((!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
|
|
|
|
|
&& daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= strumLineMid)
|
|
|
|
|
{
|
|
|
|
|
applyClipRect(daNote);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (daNote.followsTime) daNote.y = playerStrumline.y - daNote.y;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (daNote.isSustainNote
|
|
|
|
|
&& (!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
|
|
|
|
|
&& daNote.y + daNote.offset.y * daNote.scale.y <= strumLineMid)
|
|
|
|
|
{
|
|
|
|
|
applyClipRect(daNote);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!daNote.mustPress && daNote.wasGoodHit && !daNote.tooLate)
|
|
|
|
|
{
|
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, daNote, Highscore.tallies.combo, true);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() in a module should force the CPU to miss the note.
|
|
|
|
|
// This is useful for cool shit, including but not limited to:
|
|
|
|
|
// - Making the AI ignore notes which are hazardous.
|
|
|
|
|
// - Making the AI miss notes on purpose for aesthetic reasons.
|
|
|
|
|
if (event.eventCanceled)
|
|
|
|
|
{
|
|
|
|
|
daNote.tooLate = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WIP interpolation shit? Need to fix the pause issue
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * SONG.speed[.curDiff]));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// removing this so whether the note misses or not is entirely up to Note class
|
|
|
|
|
// var noteMiss:Bool = daNote.y < -daNote.height;
|
|
|
|
|
|
|
|
|
|
// if (PreferencesMenu.getPref('downscroll'))
|
|
|
|
|
// noteMiss = daNote.y > FlxG.height;
|
|
|
|
|
|
|
|
|
|
if (daNote.isSustainNote && daNote.wasGoodHit)
|
|
|
|
|
{
|
|
|
|
|
if ((!PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|
|
|
|
|
|| (PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
|
|
|
|
|
{
|
|
|
|
|
daNote.active = false;
|
|
|
|
|
daNote.visible = false;
|
|
|
|
|
|
|
|
|
|
daNote.kill();
|
|
|
|
|
activeNotes.remove(daNote, true);
|
|
|
|
|
daNote.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (daNote.wasGoodHit)
|
|
|
|
|
{
|
|
|
|
|
daNote.active = false;
|
|
|
|
|
daNote.visible = false;
|
|
|
|
|
|
|
|
|
|
daNote.kill();
|
|
|
|
|
activeNotes.remove(daNote, true);
|
|
|
|
|
daNote.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (daNote.tooLate)
|
|
|
|
|
{
|
|
|
|
|
noteMiss(daNote);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Query and activate song events.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (songEvents != null && songEvents.length > 0)
|
|
|
|
|
{
|
|
|
|
|
var songEventsToActivate:Array<SongEventData> = SongEventParser.queryEvents(songEvents, Conductor.songPosition);
|
|
|
|
|
|
|
|
|
|
if (songEventsToActivate.length > 0)
|
|
|
|
|
{
|
|
|
|
|
trace('Found ${songEventsToActivate.length} event(s) to activate.');
|
|
|
|
|
for (event in songEventsToActivate)
|
|
|
|
|
{
|
2023-04-20 13:48:15 -04:00
|
|
|
|
var eventEvent:SongEventScriptEvent = new SongEventScriptEvent(event);
|
|
|
|
|
dispatchEvent(eventEvent);
|
|
|
|
|
// Calling event.cancelEvent() skips the event. Neat!
|
|
|
|
|
if (!eventEvent.eventCanceled)
|
|
|
|
|
{
|
|
|
|
|
SongEventParser.handleEvent(event);
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Handle keybinds.
|
|
|
|
|
if (!isInCutscene && !disableKeys) keyShit(true);
|
|
|
|
|
if (!isInCutscene && !disableKeys) debugKeyShit();
|
|
|
|
|
|
|
|
|
|
// Dispatch the onUpdate event to scripted elements.
|
|
|
|
|
dispatchEvent(new UpdateScriptEvent(elapsed));
|
2023-02-21 20:58:15 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static final CUTSCENE_KEYS:Array<FlxKey> = [SPACE, ESCAPE, ENTER];
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public function trySkipVideoCutscene(elapsed:Float):Void
|
2023-02-21 20:58:15 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (skipTimer == null || skipTimer.animation == null) return;
|
|
|
|
|
|
|
|
|
|
if (elapsed < 0)
|
2023-02-21 20:58:15 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
skipHeldTimer = 0.0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
skipHeldTimer += elapsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skipTimer.visible = skipHeldTimer >= 0.05;
|
|
|
|
|
skipTimer.amount = Math.min(skipHeldTimer / 1.5, 1.0);
|
|
|
|
|
|
|
|
|
|
if (skipHeldTimer >= 1.5)
|
|
|
|
|
{
|
|
|
|
|
VideoCutscene.finishVideo();
|
2023-02-21 20:58:15 -05:00
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function applyClipRect(daNote:Note):Void
|
|
|
|
|
{
|
|
|
|
|
// clipRect is applied to graphic itself so use frame Heights
|
|
|
|
|
var swagRect:FlxRect = new FlxRect(0, 0, daNote.frameWidth, daNote.frameHeight);
|
2023-02-21 20:58:15 -05:00
|
|
|
|
var strumLineMid:Float = playerStrumline.y + Note.swagWidth / 2;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (PreferencesMenu.getPref('downscroll'))
|
|
|
|
|
{
|
|
|
|
|
swagRect.height = (strumLineMid - daNote.y) / daNote.scale.y;
|
|
|
|
|
swagRect.y = daNote.frameHeight - swagRect.height;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
swagRect.y = (strumLineMid - daNote.y) / daNote.scale.y;
|
|
|
|
|
swagRect.height -= swagRect.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
daNote.clipRect = swagRect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function killCombo():Void
|
|
|
|
|
{
|
|
|
|
|
// Girlfriend gets sad if you combo break after hitting 5 notes.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentStage != null && currentStage.getGirlfriend() != null)
|
|
|
|
|
{
|
|
|
|
|
if (Highscore.tallies.combo > 5 && currentStage.getGirlfriend().hasAnimation('sad'))
|
|
|
|
|
{
|
|
|
|
|
currentStage.getGirlfriend().playAnimation('sad');
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (Highscore.tallies.combo != 0)
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.combo = comboPopUps.displayCombo(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
/**
|
|
|
|
|
* Jumps forward or backward a number of sections in the song.
|
|
|
|
|
* Accounts for BPM changes, does not prevent death from skipped notes.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
* @param sections The number of sections to jump, negative to go backwards.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
function changeSection(sections:Int):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
FlxG.sound.music.time += sections * Conductor.measureLengthMs;
|
|
|
|
|
|
|
|
|
|
Conductor.update(FlxG.sound.music.time);
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-09 15:34:56 -04:00
|
|
|
|
*
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Redo this for the new conductor.
|
|
|
|
|
var daBPM:Float = Conductor.bpm;
|
|
|
|
|
var daPos:Float = 0;
|
|
|
|
|
for (i in 0...(Std.int(Conductor.currentStep / 16 + sec)))
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var section = .getSong()[i];
|
|
|
|
|
if (section == null) continue;
|
|
|
|
|
if (section.changeBPM)
|
|
|
|
|
{
|
|
|
|
|
daBPM = .getSong()[i].bpm;
|
|
|
|
|
}
|
|
|
|
|
daPos += 4 * (1000 * 60 / daBPM);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Conductor.songPosition = FlxG.sound.music.time = daPos;
|
|
|
|
|
Conductor.songPosition += Conductor.offset;
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
resyncVocals();
|
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
function endSong():Void
|
|
|
|
|
{
|
|
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_END));
|
|
|
|
|
|
2023-02-22 14:46:46 -05:00
|
|
|
|
#if sys
|
|
|
|
|
// spitter for ravy, teehee!!
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
2023-03-18 15:47:23 -04:00
|
|
|
|
var output = SerializerUtil.toJSON(inputSpitter);
|
|
|
|
|
sys.io.File.saveContent("./scores.json", output);
|
2023-02-22 14:46:46 -05:00
|
|
|
|
#end
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
deathCounter = 0;
|
|
|
|
|
mayPauseGame = false;
|
|
|
|
|
FlxG.sound.music.volume = 0;
|
|
|
|
|
vocals.volume = 0;
|
|
|
|
|
if (currentSong != null && currentSong.validScore)
|
|
|
|
|
{
|
|
|
|
|
// crackhead double thingie, sets whether was new highscore, AND saves the song!
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Highscore.tallies.isNewHighscore = Highscore.saveScoreForDifficulty(currentSong.songId, songScore, currentDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Highscore.saveCompletionForDifficulty(currentSong.songId, Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, currentDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (PlayStatePlaylist.isStoryMode)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
PlayStatePlaylist.campaignScore += songScore;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Pop the next song ID from the list.
|
|
|
|
|
// Returns null if the list is empty.
|
|
|
|
|
var targetSongId:String = PlayStatePlaylist.playlistSongIds.shift();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (targetSongId == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
FlxG.sound.playMusic(Paths.music('freakyMenu'));
|
|
|
|
|
|
|
|
|
|
transIn = FlxTransitionableState.defaultTransIn;
|
|
|
|
|
transOut = FlxTransitionableState.defaultTransOut;
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Rework week unlock logic.
|
2023-06-01 15:59:56 -04:00
|
|
|
|
// StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentSong.validScore)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
NGio.unlockMedal(60961);
|
2023-06-02 15:35:01 -04:00
|
|
|
|
Highscore.saveWeekScoreForDifficulty(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignScore, currentDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-06 17:38:31 -04:00
|
|
|
|
// FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
FlxG.save.flush();
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
|
|
|
|
moveToResultsScreen();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var difficulty:String = '';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
trace('Loading next song ($targetSongId : $difficulty)');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
|
|
|
|
|
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
vocals.stop();
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Softcode this cutscene.
|
|
|
|
|
if (currentSong.songId == 'eggnog')
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
var blackShit:FlxSprite = new FlxSprite(-FlxG.width * FlxG.camera.zoom,
|
|
|
|
|
-FlxG.height * FlxG.camera.zoom).makeGraphic(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK);
|
|
|
|
|
blackShit.scrollFactor.set();
|
|
|
|
|
add(blackShit);
|
|
|
|
|
camHUD.visible = false;
|
|
|
|
|
isInCutscene = true;
|
|
|
|
|
|
2023-01-27 02:38:37 -05:00
|
|
|
|
FlxG.sound.play(Paths.sound('Lights_Shut_off'), function() {
|
2023-01-22 19:55:30 -05:00
|
|
|
|
// no camFollow so it centers on horror tree
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var targetSong:Song = SongDataParser.fetchSong(targetSongId);
|
|
|
|
|
|
|
|
|
|
var nextPlayState:PlayState = new PlayState(
|
|
|
|
|
{
|
|
|
|
|
targetSong: targetSong,
|
|
|
|
|
targetDifficulty: currentDifficulty,
|
|
|
|
|
targetCharacter: currentPlayerId,
|
|
|
|
|
});
|
|
|
|
|
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
|
|
|
|
LoadingState.loadAndSwitchState(nextPlayState);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var targetSong:Song = SongDataParser.fetchSong(targetSongId);
|
|
|
|
|
var nextPlayState:PlayState = new PlayState(
|
|
|
|
|
{
|
|
|
|
|
targetSong: targetSong,
|
|
|
|
|
targetDifficulty: currentDifficulty,
|
|
|
|
|
targetCharacter: currentPlayerId,
|
|
|
|
|
});
|
|
|
|
|
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
|
|
|
|
LoadingState.loadAndSwitchState(nextPlayState);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
moveToResultsScreen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Play the camera zoom animation and move to the results screen.
|
|
|
|
|
*/
|
|
|
|
|
function moveToResultsScreen():Void
|
|
|
|
|
{
|
|
|
|
|
trace('WENT TO RESULTS SCREEN!');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Stop camera zooming on beat.
|
|
|
|
|
cameraZoomRate = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04: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 = PlayState.instance.currentStage.getDad() != null && PlayState.instance.currentStage.getDad().characterId == 'gf';
|
|
|
|
|
var targetBF:Bool = PlayState.instance.currentStage.getGirlfriend() == null && !targetDad;
|
|
|
|
|
|
|
|
|
|
if (targetBF)
|
|
|
|
|
{
|
|
|
|
|
FlxG.camera.follow(PlayState.instance.currentStage.getBoyfriend(), null, 0.05);
|
|
|
|
|
FlxG.camera.targetOffset.y -= 350;
|
|
|
|
|
FlxG.camera.targetOffset.x += 20;
|
|
|
|
|
}
|
|
|
|
|
else if (targetDad)
|
|
|
|
|
{
|
|
|
|
|
FlxG.camera.follow(PlayState.instance.currentStage.getDad(), null, 0.05);
|
|
|
|
|
FlxG.camera.targetOffset.y -= 350;
|
|
|
|
|
FlxG.camera.targetOffset.x += 20;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
|
FlxG.camera.follow(PlayState.instance.currentStage.getGirlfriend(), null, 0.05);
|
|
|
|
|
FlxG.camera.targetOffset.y -= 350;
|
|
|
|
|
FlxG.camera.targetOffset.x += 20;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
FlxTween.tween(camHUD, {alpha: 0}, 0.6);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04: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');
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Zoom over to the Results screen.
|
|
|
|
|
FlxTween.tween(FlxG.camera, {zoom: 1200}, 1.1,
|
|
|
|
|
{
|
|
|
|
|
ease: FlxEase.expoIn,
|
|
|
|
|
onComplete: function(_) {
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
vocals.stop();
|
|
|
|
|
camHUD.alpha = 1;
|
|
|
|
|
var res:ResultState = new ResultState();
|
|
|
|
|
res.camera = camHUD;
|
|
|
|
|
openSubState(res);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// gives score and pops up rating
|
2023-01-22 22:25:45 -05:00
|
|
|
|
function popUpScore(strumtime:Float, daNote:Note):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
var noteDiff:Float = Math.abs(strumtime - Conductor.songPosition);
|
|
|
|
|
// boyfriend.playAnimation('hey');
|
2023-05-25 18:34:26 -04:00
|
|
|
|
vocals.playerVolume = 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
var isSick:Bool = false;
|
|
|
|
|
var score = Scoring.scoreNote(noteDiff, PBOT1);
|
|
|
|
|
var daRating = Scoring.judgeNote(noteDiff, PBOT1);
|
|
|
|
|
var healthMulti:Float = daNote.lowStakes ? 0.002 : 0.033;
|
|
|
|
|
|
|
|
|
|
if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD)
|
|
|
|
|
{
|
|
|
|
|
healthMulti *= 0; // no health on shit note
|
|
|
|
|
daRating = 'shit';
|
|
|
|
|
Highscore.tallies.shit += 1;
|
2023-03-09 12:39:56 -05:00
|
|
|
|
// score = 50;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD)
|
|
|
|
|
{
|
|
|
|
|
healthMulti *= 0.2;
|
|
|
|
|
daRating = 'bad';
|
|
|
|
|
Highscore.tallies.bad += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD)
|
|
|
|
|
{
|
|
|
|
|
healthMulti *= 0.78;
|
|
|
|
|
daRating = 'good';
|
|
|
|
|
Highscore.tallies.good += 1;
|
2023-03-09 12:39:56 -05:00
|
|
|
|
// score = 200;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isSick = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
health += healthMulti;
|
|
|
|
|
if (isSick)
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.sick += 1;
|
|
|
|
|
var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
|
|
|
|
|
noteSplash.setupNoteSplash(daNote.x, daNote.y, daNote.data.noteData);
|
|
|
|
|
// new NoteSplash(daNote.x, daNote.y, daNote.noteData);
|
|
|
|
|
grpNoteSplashes.add(noteSplash);
|
|
|
|
|
}
|
|
|
|
|
// Only add the score if you're not on practice mode
|
2023-03-02 04:20:03 -05:00
|
|
|
|
if (!isPracticeMode)
|
|
|
|
|
{
|
|
|
|
|
songScore += score;
|
|
|
|
|
|
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
2023-03-18 15:47:23 -04: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(
|
|
|
|
|
{
|
|
|
|
|
t: Std.int(Conductor.songPosition),
|
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
|
|
|
|
t: Std.int(Conductor.songPosition),
|
|
|
|
|
d: -1,
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-02 04:20:03 -05:00
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
comboPopUps.displayRating(daRating);
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (Highscore.tallies.combo >= 10 || Highscore.tallies.combo == 0) comboPopUps.displayCombo(Highscore.tallies.combo);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-22 14:46:46 -05:00
|
|
|
|
/**
|
|
|
|
|
* Spitting out the input for ravy 🙇♂️!!
|
|
|
|
|
*/
|
2023-03-18 15:47:23 -04:00
|
|
|
|
var inputSpitter:Array<ScoreInput> = [];
|
2023-02-22 14:46:46 -05:00
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
public function keyShit(test:Bool):Void
|
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (PlayState.instance == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// control arrays, order L D R U
|
|
|
|
|
var holdArray:Array<Bool> = [controls.NOTE_LEFT, controls.NOTE_DOWN, controls.NOTE_UP, controls.NOTE_RIGHT];
|
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
|
|
|
|
var releaseArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_R,
|
|
|
|
|
controls.NOTE_DOWN_R,
|
|
|
|
|
controls.NOTE_UP_R,
|
|
|
|
|
controls.NOTE_RIGHT_R
|
|
|
|
|
];
|
2023-02-22 14:46:46 -05:00
|
|
|
|
|
2023-03-02 04:20:03 -05:00
|
|
|
|
// if (pressArray.contains(true))
|
|
|
|
|
// {
|
|
|
|
|
// var lol:Array<Int> = cast pressArray;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// inputSpitter.push(Std.int(Conductor.songPosition) + ' ' + lol.join(' '));
|
2023-03-02 04:20:03 -05:00
|
|
|
|
// }
|
2023-02-22 14:46:46 -05:00
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
// HOLDS, check for sustain notes
|
|
|
|
|
if (holdArray.contains(true) && PlayState.instance.generatedMusic)
|
|
|
|
|
{
|
2023-01-27 02:38:37 -05:00
|
|
|
|
PlayState.instance.activeNotes.forEachAlive(function(daNote:Note) {
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && holdArray[daNote.data.noteData]) PlayState.instance.goodNoteHit(daNote);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PRESSES, check for note hits
|
|
|
|
|
if (pressArray.contains(true) && PlayState.instance.generatedMusic)
|
|
|
|
|
{
|
|
|
|
|
Haptic.vibrate(100, 100);
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentStage != null && currentStage.getBoyfriend() != null)
|
|
|
|
|
{
|
|
|
|
|
currentStage.getBoyfriend().holdTimer = 0;
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
var possibleNotes:Array<Note> = []; // notes that can be hit
|
|
|
|
|
var directionList:Array<Int> = []; // directions that can be hit
|
|
|
|
|
var dumbNotes:Array<Note> = []; // notes to kill later
|
|
|
|
|
|
2023-01-27 02:38:37 -05:00
|
|
|
|
PlayState.instance.activeNotes.forEachAlive(function(daNote:Note) {
|
2023-01-22 19:55:30 -05:00
|
|
|
|
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
|
|
|
|
|
{
|
|
|
|
|
if (directionList.contains(daNote.data.noteData))
|
|
|
|
|
{
|
|
|
|
|
for (coolNote in possibleNotes)
|
|
|
|
|
{
|
|
|
|
|
if (coolNote.data.noteData == daNote.data.noteData && Math.abs(daNote.data.strumTime - coolNote.data.strumTime) < 10)
|
|
|
|
|
{ // if it's the same note twice at < 10ms distance, just delete it
|
|
|
|
|
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
|
|
|
|
|
dumbNotes.push(daNote);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (coolNote.data.noteData == daNote.data.noteData && daNote.data.strumTime < coolNote.data.strumTime)
|
|
|
|
|
{ // if daNote is earlier than existing note (coolNote), replace
|
|
|
|
|
possibleNotes.remove(coolNote);
|
|
|
|
|
possibleNotes.push(daNote);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
possibleNotes.push(daNote);
|
|
|
|
|
directionList.push(daNote.data.noteData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (note in dumbNotes)
|
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
FlxG.log.add('killing dumb ass note at ' + note.data.strumTime);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
note.kill();
|
|
|
|
|
PlayState.instance.activeNotes.remove(note, true);
|
|
|
|
|
note.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
possibleNotes.sort((a, b) -> Std.int(a.data.strumTime - b.data.strumTime));
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (PlayState.instance.perfectMode) PlayState.instance.goodNoteHit(possibleNotes[0]);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
else if (possibleNotes.length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (shit in 0...pressArray.length)
|
|
|
|
|
{ // if a direction is hit that shouldn't be
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (pressArray[shit] && !directionList.contains(shit)) PlayState.instance.ghostNoteMiss(shit);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
for (coolNote in possibleNotes)
|
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (pressArray[coolNote.data.noteData]) PlayState.instance.goodNoteHit(coolNote);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// HNGGG I really want to add an option for ghost tapping
|
|
|
|
|
// L + ratio
|
|
|
|
|
for (shit in 0...pressArray.length)
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (pressArray[shit]) PlayState.instance.ghostNoteMiss(shit, false);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (PlayState.instance == null || PlayState.instance.currentStage == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
for (keyId => isPressed in pressArray)
|
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (playerStrumline == null) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
var arrow:StrumlineArrow = PlayState.instance.playerStrumline.getArrow(keyId);
|
|
|
|
|
|
|
|
|
|
if (isPressed && arrow.animation.curAnim.name != 'confirm')
|
|
|
|
|
{
|
|
|
|
|
arrow.playAnimation('pressed');
|
|
|
|
|
}
|
|
|
|
|
if (!holdArray[keyId])
|
|
|
|
|
{
|
|
|
|
|
arrow.playAnimation('static');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
/**
|
|
|
|
|
* Debug keys. Disabled while in cutscenes.
|
|
|
|
|
*/
|
|
|
|
|
public function debugKeyShit():Void
|
|
|
|
|
{
|
|
|
|
|
#if !debug
|
|
|
|
|
perfectMode = false;
|
|
|
|
|
#else
|
|
|
|
|
if (FlxG.keys.justPressed.H) camHUD.visible = !camHUD.visible;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState());
|
|
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.F5) debug_refreshModules();
|
|
|
|
|
|
|
|
|
|
// Press U to open stage ditor.
|
|
|
|
|
if (FlxG.keys.justPressed.U)
|
|
|
|
|
{
|
|
|
|
|
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
|
|
|
|
|
disableKeys = true;
|
|
|
|
|
persistentUpdate = false;
|
|
|
|
|
openSubState(new StageOffsetSubState());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
// 1: End the song immediately.
|
|
|
|
|
if (FlxG.keys.justPressed.ONE) endSong();
|
|
|
|
|
|
|
|
|
|
// 2: Gain 10% health.
|
|
|
|
|
if (FlxG.keys.justPressed.TWO) health += 0.1 * 2.0;
|
|
|
|
|
|
|
|
|
|
// 3: Lose 5% health.
|
|
|
|
|
if (FlxG.keys.justPressed.THREE) health -= 0.05 * 2.0;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
// 7: Move to the charter.
|
|
|
|
|
if (FlxG.keys.justPressed.SEVEN)
|
|
|
|
|
{
|
|
|
|
|
lime.app.Application.current.window.alert("Press ~ on the main menu to get to the editor", 'LOL');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 8: Move to the offset editor.
|
|
|
|
|
if (FlxG.keys.justPressed.EIGHT) FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState());
|
|
|
|
|
|
|
|
|
|
// 9: Toggle the old icon.
|
|
|
|
|
if (FlxG.keys.justPressed.NINE) iconP1.toggleOldIcon();
|
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
// PAGEUP: Skip forward one section.
|
|
|
|
|
// SHIFT+PAGEUP: Skip forward ten sections.
|
|
|
|
|
if (FlxG.keys.justPressed.PAGEUP) changeSection(FlxG.keys.pressed.SHIFT ? 10 : 1);
|
|
|
|
|
// PAGEDOWN: Skip backward one section. Doesn't replace notes.
|
|
|
|
|
// SHIFT+PAGEDOWN: Skip backward ten sections.
|
|
|
|
|
if (FlxG.keys.justPressed.PAGEDOWN) changeSection(FlxG.keys.pressed.SHIFT ? -10 : -1);
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.B) trace(inputSpitter.join('\n'));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 19:55:30 -05: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 16:30:45 -04:00
|
|
|
|
*
|
|
|
|
|
* @param direction
|
|
|
|
|
* @param hasPossibleNotes
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
|
|
|
|
function ghostNoteMiss(direction:funkin.noteStuff.NoteBasic.NoteType = 1, hasPossibleNotes:Bool = true):Void
|
|
|
|
|
{
|
|
|
|
|
var event:GhostMissNoteScriptEvent = new GhostMissNoteScriptEvent(direction, // Direction missed in.
|
|
|
|
|
hasPossibleNotes, // Whether there was a note you could have hit.
|
|
|
|
|
- 0.035 * 2, // How much health to add (negative).
|
|
|
|
|
- 10 // Amount of score to add (negative).
|
|
|
|
|
);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips animations and penalties. Neat!
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
health += event.healthChange;
|
|
|
|
|
|
2023-03-02 04:20:03 -05:00
|
|
|
|
if (!isPracticeMode)
|
|
|
|
|
{
|
|
|
|
|
songScore += event.scoreChange;
|
|
|
|
|
|
|
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
|
];
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
2023-03-18 15:47:23 -04: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(
|
|
|
|
|
{
|
|
|
|
|
t: Std.int(Conductor.songPosition),
|
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-02 04:20:03 -05:00
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (event.playSound)
|
|
|
|
|
{
|
2023-05-25 18:34:26 -04:00
|
|
|
|
vocals.playerVolume = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function noteMiss(note:Note):Void
|
|
|
|
|
{
|
|
|
|
|
// a MISS is when you let a note scroll past you!!
|
|
|
|
|
Highscore.tallies.missed++;
|
|
|
|
|
|
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_MISS, note, Highscore.tallies.combo, true);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
health -= 0.0775;
|
2023-03-02 04:20:03 -05:00
|
|
|
|
|
|
|
|
|
if (!isPracticeMode)
|
|
|
|
|
{
|
|
|
|
|
songScore -= 10;
|
|
|
|
|
|
|
|
|
|
// 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 15:35:01 -04:00
|
|
|
|
|
2023-03-18 15:47:23 -04: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(
|
|
|
|
|
{
|
|
|
|
|
t: Std.int(Conductor.songPosition),
|
|
|
|
|
d: indices[i],
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inputSpitter.push(
|
|
|
|
|
{
|
|
|
|
|
t: Std.int(Conductor.songPosition),
|
|
|
|
|
d: -1,
|
|
|
|
|
l: 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-02 04:20:03 -05:00
|
|
|
|
}
|
2023-05-25 18:34:26 -04:00
|
|
|
|
vocals.playerVolume = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (Highscore.tallies.combo != 0)
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.combo = comboPopUps.displayCombo(0);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (event.playSound)
|
|
|
|
|
{
|
|
|
|
|
vocals.playerVolume = 0;
|
|
|
|
|
FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
|
note.active = false;
|
|
|
|
|
note.visible = false;
|
|
|
|
|
|
|
|
|
|
note.kill();
|
|
|
|
|
activeNotes.remove(note, true);
|
|
|
|
|
note.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function goodNoteHit(note:Note):Void
|
|
|
|
|
{
|
|
|
|
|
if (!note.wasGoodHit)
|
|
|
|
|
{
|
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, note, Highscore.tallies.combo + 1, true);
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (!note.isSustainNote)
|
|
|
|
|
{
|
|
|
|
|
Highscore.tallies.combo++;
|
|
|
|
|
Highscore.tallies.totalNotesHit++;
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (Highscore.tallies.combo > Highscore.tallies.maxCombo) Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
popUpScore(note.data.strumTime, note);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playerStrumline.getArrow(note.data.noteData).playAnimation('confirm', true);
|
|
|
|
|
|
|
|
|
|
note.wasGoodHit = true;
|
2023-05-25 18:34:26 -04:00
|
|
|
|
vocals.playerVolume = 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (!note.isSustainNote)
|
|
|
|
|
{
|
|
|
|
|
note.kill();
|
|
|
|
|
activeNotes.remove(note, true);
|
|
|
|
|
note.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override function stepHit():Bool
|
|
|
|
|
{
|
|
|
|
|
// super.stepHit() returns false if a module cancelled the event.
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (!super.stepHit()) return false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (Math.abs(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset)) > 200
|
|
|
|
|
|| Math.abs(vocals.checkSyncError(Conductor.songPosition - Conductor.offset)) > 200)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
trace("VOCALS NEED RESYNC");
|
|
|
|
|
if (vocals != null) trace(vocals.checkSyncError(Conductor.songPosition - Conductor.offset));
|
|
|
|
|
trace(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
resyncVocals();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (iconP1 != null) iconP1.onStepHit(Std.int(Conductor.currentStep));
|
|
|
|
|
if (iconP2 != null) iconP2.onStepHit(Std.int(Conductor.currentStep));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override function beatHit():Bool
|
|
|
|
|
{
|
|
|
|
|
// super.beatHit() returns false if a module cancelled the event.
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (!super.beatHit()) return false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (generatedMusic)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Sort more efficiently, or less often, to improve performance.
|
|
|
|
|
activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Only zoom camera if we are zoomed by less than 35%.
|
|
|
|
|
if (FlxG.camera.zoom < (1.35 * defaultCameraZoom) && cameraZoomRate > 0 && Conductor.currentBeat % cameraZoomRate == 0)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// Zoom camera in (1.5%)
|
|
|
|
|
FlxG.camera.zoom += cameraZoomIntensity * defaultCameraZoom;
|
|
|
|
|
// Hud zooms double (3%)
|
|
|
|
|
camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// trace('Not bopping camera: ${FlxG.camera.zoom} < ${(1.35 * defaultCameraZoom)} && ${cameraZoomRate} > 0 && ${Conductor.currentBeat} % ${cameraZoomRate} == ${Conductor.currentBeat % cameraZoomRate}}');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// That combo milestones that got spoiled that one time.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
// Comes with NEAT visual and audio effects.
|
|
|
|
|
|
|
|
|
|
// bruh this var is bonkers i thot it was a function lmfaooo
|
|
|
|
|
|
|
|
|
|
// Break up into individual lines to aid debugging.
|
|
|
|
|
|
|
|
|
|
var shouldShowComboText:Bool = false;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Re-enable combo text (how to do this without sections?).
|
|
|
|
|
// if (currentSong != null)
|
|
|
|
|
// {
|
|
|
|
|
// shouldShowComboText = (Conductor.currentBeat % 8 == 7);
|
|
|
|
|
// var daSection = .getSong()[Std.int(Conductor.currentBeat / 16)];
|
|
|
|
|
// shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection);
|
|
|
|
|
// shouldShowComboText = shouldShowComboText && (Highscore.tallies.combo > 5);
|
|
|
|
|
//
|
|
|
|
|
// var daNextSection = .getSong()[Std.int(Conductor.currentBeat / 16) + 1];
|
|
|
|
|
// var isEndOfSong = .getSong().length < Std.int(Conductor.currentBeat / 16);
|
|
|
|
|
// shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection));
|
|
|
|
|
// }
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
if (shouldShowComboText)
|
|
|
|
|
{
|
2023-06-15 00:11:20 -04:00
|
|
|
|
var animShit:ComboMilestone = new ComboMilestone(-100, 300, Highscore.tallies.combo);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
animShit.scrollFactor.set(0.6, 0.6);
|
|
|
|
|
animShit.cameras = [camHUD];
|
|
|
|
|
add(animShit);
|
|
|
|
|
|
|
|
|
|
var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation
|
|
|
|
|
|
2023-06-15 00:29:40 -04:00
|
|
|
|
new FlxTimer().start(((Conductor.beatLengthMs / 1000) * 1.25) - frameShit, function(tmr) {
|
2023-01-22 19:55:30 -05:00
|
|
|
|
animShit.forceFinish();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make the characters dance on the beat
|
|
|
|
|
danceOnBeat();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles characters dancing to the beat of the current song.
|
2023-06-08 16:30:45 -04:00
|
|
|
|
*
|
2023-01-22 19:55:30 -05:00
|
|
|
|
* TODO: Move some of this logic into `Bopper.hx`
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public function danceOnBeat():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (currentStage == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Add HEY! song events to Tutorial.
|
|
|
|
|
if (Conductor.currentBeat % 16 == 15
|
2023-01-22 19:55:30 -05:00
|
|
|
|
&& currentStage.getDad().characterId == 'gf'
|
|
|
|
|
&& Conductor.currentBeat > 16
|
|
|
|
|
&& Conductor.currentBeat < 48)
|
|
|
|
|
{
|
|
|
|
|
currentStage.getBoyfriend().playAnimation('hey', true);
|
|
|
|
|
currentStage.getDad().playAnimation('cheer', true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs the strumlines for each player.
|
|
|
|
|
*/
|
|
|
|
|
function buildStrumlines():Void
|
|
|
|
|
{
|
|
|
|
|
var strumlineStyle:StrumlineStyle = NORMAL;
|
|
|
|
|
|
|
|
|
|
// TODO: Put this in the chart or something?
|
|
|
|
|
switch (currentStageId)
|
|
|
|
|
{
|
|
|
|
|
case 'school':
|
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
|
case 'schoolEvil':
|
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strumlineYPos = Strumline.getYPos();
|
|
|
|
|
|
|
|
|
|
playerStrumline = new Strumline(0, strumlineStyle, 4);
|
|
|
|
|
playerStrumline.x = 50 + FlxG.width / 2;
|
|
|
|
|
playerStrumline.y = strumlineYPos;
|
|
|
|
|
// Set the z-index so they don't appear in front of notes.
|
|
|
|
|
playerStrumline.zIndex = 100;
|
|
|
|
|
add(playerStrumline);
|
|
|
|
|
playerStrumline.cameras = [camHUD];
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (!PlayStatePlaylist.isStoryMode)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
playerStrumline.fadeInArrows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enemyStrumline = new Strumline(1, strumlineStyle, 4);
|
|
|
|
|
enemyStrumline.x = 50;
|
|
|
|
|
enemyStrumline.y = strumlineYPos;
|
|
|
|
|
// Set the z-index so they don't appear in front of notes.
|
|
|
|
|
enemyStrumline.zIndex = 100;
|
|
|
|
|
add(enemyStrumline);
|
|
|
|
|
enemyStrumline.cameras = [camHUD];
|
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (!PlayStatePlaylist.isStoryMode)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
enemyStrumline.fadeInArrows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function called before opening a new substate.
|
|
|
|
|
* @param subState The substate to open.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public override function openSubState(subState:FlxSubState):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
// If there is a substate which requires the game to continue,
|
|
|
|
|
// then make this a condition.
|
|
|
|
|
var shouldPause = true;
|
|
|
|
|
|
|
|
|
|
if (shouldPause)
|
|
|
|
|
{
|
|
|
|
|
// Pause the music.
|
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.music.pause();
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (vocals != null) vocals.pause();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Pause the countdown.
|
|
|
|
|
Countdown.pauseCountdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.openSubState(subState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function called before closing the current substate.
|
2023-06-08 16:30:45 -04:00
|
|
|
|
* @param subState
|
2023-01-22 19:55:30 -05:00
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
public override function closeSubState():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
|
|
|
|
if (isGamePaused)
|
|
|
|
|
{
|
|
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.RESUME, true);
|
|
|
|
|
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (event.eventCanceled) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (FlxG.sound.music != null && !startingSong && !isInCutscene) resyncVocals();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// Resume the countdown.
|
|
|
|
|
Countdown.resumeCountdown();
|
|
|
|
|
|
|
|
|
|
#if discord_rpc
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (startTimer.finished)
|
|
|
|
|
{
|
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, songLength - Conductor.songPosition);
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
else
|
2023-06-02 15:35:01 -04:00
|
|
|
|
{
|
|
|
|
|
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC);
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
#end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.closeSubState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepares to start the countdown.
|
|
|
|
|
* Ends any running cutscenes, creates the strumlines, and starts the countdown.
|
|
|
|
|
*/
|
2023-02-21 20:58:15 -05:00
|
|
|
|
public function startCountdown():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-02-21 20:58:15 -05:00
|
|
|
|
// If Countdown.performCountdown returns false, then the countdown was canceled by a script.
|
|
|
|
|
var result:Bool = Countdown.performCountdown(currentStageId.startsWith('school'));
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (!result) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
isInCutscene = false;
|
2023-06-02 15:35:01 -04:00
|
|
|
|
camCutscene.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
camHUD.visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override function dispatchEvent(event:ScriptEvent):Void
|
|
|
|
|
{
|
|
|
|
|
// ORDER: Module, Stage, Character, Song, Note
|
|
|
|
|
// Modules should get the first chance to cancel the event.
|
|
|
|
|
|
|
|
|
|
// super.dispatchEvent(event) dispatches event to module scripts.
|
|
|
|
|
super.dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
// Dispatch event to stage script.
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
|
|
|
|
|
|
// Dispatch event to character script(s).
|
2023-01-22 22:25:45 -05:00
|
|
|
|
if (currentStage != null) currentStage.dispatchToCharacters(event);
|
2023-06-02 15:35:01 -04:00
|
|
|
|
|
|
|
|
|
ScriptEventDispatcher.callEvent(currentSong, event);
|
|
|
|
|
|
|
|
|
|
// TODO: Dispatch event to note scripts
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the position and contents of the score display.
|
|
|
|
|
*/
|
|
|
|
|
function updateScoreText():Void
|
|
|
|
|
{
|
|
|
|
|
// TODO: Add functionality for modules to update the score text.
|
2023-06-02 15:35:01 -04:00
|
|
|
|
scoreText.text = 'Score:' + songScore;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the values of the health bar.
|
|
|
|
|
*/
|
|
|
|
|
function updateHealthBar():Void
|
|
|
|
|
{
|
|
|
|
|
healthLerp = FlxMath.lerp(healthLerp, health, 0.15);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resets the camera's zoom level and focus point.
|
|
|
|
|
*/
|
|
|
|
|
public function resetCamera():Void
|
|
|
|
|
{
|
|
|
|
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
|
|
|
|
FlxG.camera.targetOffset.set();
|
|
|
|
|
FlxG.camera.zoom = defaultCameraZoom;
|
|
|
|
|
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Perform necessary cleanup before leaving the PlayState.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
function performCleanup():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
if (currentChart != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
// TODO: Uncache the song.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove reference to stage and remove sprites from it to save memory.
|
|
|
|
|
if (currentStage != null)
|
|
|
|
|
{
|
|
|
|
|
remove(currentStage);
|
|
|
|
|
currentStage.kill();
|
|
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.DESTROY, false));
|
|
|
|
|
currentStage = null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 18:52:58 -04:00
|
|
|
|
GameOverSubState.reset();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
|
|
// Clear the static reference to this state.
|
|
|
|
|
instance = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function is called whenever Flixel switches switching to a new FlxState.
|
|
|
|
|
* @return Whether to actually switch to the new state.
|
|
|
|
|
*/
|
2023-06-02 15:35:01 -04:00
|
|
|
|
override function switchTo(nextState:FlxState):Bool
|
2023-01-22 19:55:30 -05:00
|
|
|
|
{
|
2023-06-02 15:35:01 -04:00
|
|
|
|
var result:Bool = super.switchTo(nextState);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
performCleanup();
|
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
2023-06-02 15:35:01 -04:00
|
|
|
|
return result;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
}
|
2021-08-27 18:08:01 -04:00
|
|
|
|
}
|