2022-09-06 04:59:54 +00:00
|
|
|
package funkin.play.song;
|
|
|
|
|
2022-09-07 23:07:08 +00:00
|
|
|
import funkin.play.song.SongData.SongDataParser;
|
|
|
|
import funkin.play.song.SongData.SongMetadata;
|
|
|
|
|
2022-09-06 04:59:54 +00:00
|
|
|
/**
|
|
|
|
* This is a data structure managing information about the current song.
|
|
|
|
* This structure is created when the game starts, and includes all the data
|
|
|
|
* from the `metadata.json` file.
|
|
|
|
* It also includes the chart data, but only when this is the currently loaded song.
|
|
|
|
*
|
|
|
|
* It also receives script events; scripted classes which extend this class
|
|
|
|
* can be used to perform custom gameplay behaviors only on specific songs.
|
|
|
|
*/
|
2022-09-07 23:07:08 +00:00
|
|
|
class Song // implements IPlayStateScriptedClass
|
2022-09-06 04:59:54 +00:00
|
|
|
{
|
|
|
|
public var songId(default, null):String;
|
|
|
|
|
|
|
|
public var songName(get, null):String;
|
|
|
|
|
|
|
|
final _metadata:SongMetadata;
|
2022-09-07 23:07:08 +00:00
|
|
|
|
|
|
|
// final _chartData:SongChartData;
|
2022-09-06 04:59:54 +00:00
|
|
|
|
|
|
|
public function new(id:String)
|
|
|
|
{
|
2022-09-07 23:07:08 +00:00
|
|
|
this.songId = id;
|
2022-09-06 04:59:54 +00:00
|
|
|
|
2022-09-07 23:07:08 +00:00
|
|
|
_metadata = SongDataParser.parseSongMetadata(songId);
|
2022-09-06 04:59:54 +00:00
|
|
|
if (_metadata == null)
|
|
|
|
{
|
|
|
|
throw 'Could not find song data for songId: $songId';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_songName():String
|
|
|
|
{
|
|
|
|
if (_metadata == null)
|
|
|
|
return null;
|
|
|
|
return _metadata.name;
|
|
|
|
}
|
2022-09-07 23:07:08 +00:00
|
|
|
|
|
|
|
public function toString():String
|
|
|
|
{
|
|
|
|
return 'Song($songId)';
|
|
|
|
}
|
2022-09-06 04:59:54 +00:00
|
|
|
}
|