diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 3b098be14..da343f43f 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1178,16 +1178,8 @@ class PlayState extends MusicBeatSubState // Dispatch event to conversation script. ScriptEventDispatcher.callEvent(currentConversation, event); - // Dispatch event to only the specific note script - if (Std.isOfType(event, NoteScriptEvent)) - { - var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); - NoteKindManager.callEvent(noteEvent.note.noteData.kind, noteEvent); - } - else // Dispatch event to all note scripts - { - NoteKindManager.callEventForAll(event); - } + // Dispatch event to note kind scripts + NoteKindManager.callEvent(event); } /** diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 0de1a0a33..6efd601c7 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -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 (noteKind == null) + // if it is a note script event, + // then only call the event for the specific note kind script + 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); + } } - - ScriptEventDispatcher.callEvent(noteKind, event); - } - - public static function callEventForAll(event:ScriptEvent):Void - { - for (noteKind in noteKinds.iterator()) + else // call the event for all note kind scripts { - ScriptEventDispatcher.callEvent(noteKind, event); + for (noteKind in noteKinds.iterator()) + { + ScriptEventDispatcher.callEvent(noteKind, event); + } } } }