1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-07-12 06:10:23 +00:00

remove note kind logic from playstate

This commit is contained in:
lemz 2024-06-01 18:25:46 +02:00 committed by EliteMasterEric
parent 14771e72de
commit b6eda8e498
2 changed files with 23 additions and 23 deletions

View file

@ -1178,16 +1178,8 @@ class PlayState extends MusicBeatSubState
// Dispatch event to conversation script. // Dispatch event to conversation script.
ScriptEventDispatcher.callEvent(currentConversation, event); ScriptEventDispatcher.callEvent(currentConversation, event);
// Dispatch event to only the specific note script // Dispatch event to note kind scripts
if (Std.isOfType(event, NoteScriptEvent)) NoteKindManager.callEvent(event);
{
var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent);
NoteKindManager.callEvent(noteEvent.note.noteData.kind, noteEvent);
}
else // Dispatch event to all note scripts
{
NoteKindManager.callEventForAll(event);
}
} }
/** /**

View file

@ -32,23 +32,31 @@ class NoteKindManager
} }
} }
public static function callEvent(noteKind:String, event:ScriptEvent):Void /**
* Calls the given event for note kind scripts
* @param event The event
*/
public static function callEvent(event:ScriptEvent):Void
{ {
var noteKind:NoteKind = noteKinds.get(noteKind); // if it is a note script event,
// then only call the event for the specific note kind script
if (noteKind == null) if (Std.isOfType(event, NoteScriptEvent))
{ {
return; var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent);
var noteKind:NoteKind = noteKinds.get(noteEvent.note.noteData.kind);
if (noteKind != null)
{
ScriptEventDispatcher.callEvent(noteKind, event);
}
} }
else // call the event for all note kind scripts
ScriptEventDispatcher.callEvent(noteKind, event);
}
public static function callEventForAll(event:ScriptEvent):Void
{
for (noteKind in noteKinds.iterator())
{ {
ScriptEventDispatcher.callEvent(noteKind, event); for (noteKind in noteKinds.iterator())
{
ScriptEventDispatcher.callEvent(noteKind, event);
}
} }
} }
} }