1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 00:34:40 +00:00
Funkin/source/funkin/play/song/Song.hx

48 lines
1.1 KiB
Haxe
Raw Normal View History

2022-09-06 04:59:54 +00:00
package funkin.play.song;
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.
*/
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;
// final _chartData:SongChartData;
2022-09-06 04:59:54 +00:00
public function new(id:String)
{
this.songId = id;
2022-09-06 04:59:54 +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;
}
public function toString():String
{
return 'Song($songId)';
}
2022-09-06 04:59:54 +00:00
}