mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-11-28 23:35:54 +00:00
Implement onSongLoaded script event (with access to notes and events)
This commit is contained in:
parent
65854b2ca8
commit
23a27dd36e
|
|
@ -1,6 +1,7 @@
|
||||||
package funkin.modding.events;
|
package funkin.modding.events;
|
||||||
|
|
||||||
import funkin.data.song.SongData.SongNoteData;
|
import funkin.data.song.SongData.SongNoteData;
|
||||||
|
import funkin.data.song.SongData.SongEventData;
|
||||||
import flixel.FlxState;
|
import flixel.FlxState;
|
||||||
import flixel.FlxSubState;
|
import flixel.FlxSubState;
|
||||||
import funkin.play.notes.NoteSprite;
|
import funkin.play.notes.NoteSprite;
|
||||||
|
|
@ -358,6 +359,8 @@ class SongLoadScriptEvent extends ScriptEvent
|
||||||
*/
|
*/
|
||||||
public var notes(default, set):Array<SongNoteData>;
|
public var notes(default, set):Array<SongNoteData>;
|
||||||
|
|
||||||
|
public var events(default, set):Array<SongEventData>;
|
||||||
|
|
||||||
public var id(default, null):String;
|
public var id(default, null):String;
|
||||||
|
|
||||||
public var difficulty(default, null):String;
|
public var difficulty(default, null):String;
|
||||||
|
|
@ -368,12 +371,19 @@ class SongLoadScriptEvent extends ScriptEvent
|
||||||
return this.notes;
|
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);
|
super(SONG_LOADED, false);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
|
this.events = events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function toString():String
|
public override function toString():String
|
||||||
|
|
|
||||||
|
|
@ -1831,15 +1831,21 @@ class PlayState extends MusicBeatSubState
|
||||||
Highscore.tallies.combo = 0;
|
Highscore.tallies.combo = 0;
|
||||||
Highscore.tallies = new Tallies();
|
Highscore.tallies = new Tallies();
|
||||||
|
|
||||||
// Reset song events.
|
var event:SongLoadScriptEvent = new SongLoadScriptEvent(currentChart.song.id, currentChart.difficulty, currentChart.notes.copy(), currentChart.getEvents());
|
||||||
songEvents = currentChart.getEvents();
|
|
||||||
|
dispatchEvent(event);
|
||||||
|
|
||||||
|
var builtNoteData = event.notes;
|
||||||
|
var builtEventData = event.events;
|
||||||
|
|
||||||
|
songEvents = builtEventData;
|
||||||
SongEventRegistry.resetEvents(songEvents);
|
SongEventRegistry.resetEvents(songEvents);
|
||||||
|
|
||||||
// Reset the notes on each strumline.
|
// Reset the notes on each strumline.
|
||||||
var playerNoteData:Array<SongNoteData> = [];
|
var playerNoteData:Array<SongNoteData> = [];
|
||||||
var opponentNoteData:Array<SongNoteData> = [];
|
var opponentNoteData:Array<SongNoteData> = [];
|
||||||
|
|
||||||
for (songNote in currentChart.notes)
|
for (songNote in builtNoteData)
|
||||||
{
|
{
|
||||||
var strumTime:Float = songNote.time;
|
var strumTime:Float = songNote.time;
|
||||||
if (strumTime < startTime) continue; // Skip notes that are before the start time.
|
if (strumTime < startTime) continue; // Skip notes that are before the start time.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue