1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-04-11 14:54:52 +00:00

Implement onSongLoaded script event (with access to notes and events)

This commit is contained in:
EliteMasterEric 2024-05-02 04:11:27 -04:00
parent 65854b2ca8
commit 23a27dd36e
2 changed files with 20 additions and 4 deletions

View file

@ -1,6 +1,7 @@
package funkin.modding.events;
import funkin.data.song.SongData.SongNoteData;
import funkin.data.song.SongData.SongEventData;
import flixel.FlxState;
import flixel.FlxSubState;
import funkin.play.notes.NoteSprite;
@ -358,6 +359,8 @@ class SongLoadScriptEvent extends ScriptEvent
*/
public var notes(default, set):Array<SongNoteData>;
public var events(default, set):Array<SongEventData>;
public var id(default, null):String;
public var difficulty(default, null):String;
@ -368,12 +371,19 @@ class SongLoadScriptEvent extends ScriptEvent
return this.notes;
}
public function new(id:String, difficulty:String, notes:Array<SongNoteData>):Void
function set_events(events:Array<SongEventData>):Array<SongEventData>
{
this.events = events;
return this.events;
}
public function new(id:String, difficulty:String, notes:Array<SongNoteData>, events:Array<SongEventData>):Void
{
super(SONG_LOADED, false);
this.id = id;
this.difficulty = difficulty;
this.notes = notes;
this.events = events;
}
public override function toString():String

View file

@ -1831,15 +1831,21 @@ class PlayState extends MusicBeatSubState
Highscore.tallies.combo = 0;
Highscore.tallies = new Tallies();
// Reset song events.
songEvents = currentChart.getEvents();
var event:SongLoadScriptEvent = new SongLoadScriptEvent(currentChart.song.id, currentChart.difficulty, currentChart.notes.copy(), currentChart.getEvents());
dispatchEvent(event);
var builtNoteData = event.notes;
var builtEventData = event.events;
songEvents = builtEventData;
SongEventRegistry.resetEvents(songEvents);
// Reset the notes on each strumline.
var playerNoteData:Array<SongNoteData> = [];
var opponentNoteData:Array<SongNoteData> = [];
for (songNote in currentChart.notes)
for (songNote in builtNoteData)
{
var strumTime:Float = songNote.time;
if (strumTime < startTime) continue; // Skip notes that are before the start time.