diff --git a/Project.xml b/Project.xml index bb7bf268..f354e597 100644 --- a/Project.xml +++ b/Project.xml @@ -2,7 +2,7 @@ - + diff --git a/buildnumber.txt b/buildnumber.txt index 398d2f0b..db7a8f44 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1965 \ No newline at end of file +1967 \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index c6858322..60b1a643 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1273,8 +1273,10 @@ class PlayState extends MusicBeatState if (health <= 0 && canDie) gameOver(); - if (generatedMusic) + if (generatedMusic) { + __updateNote_event = EventManager.get(NoteUpdateEvent); notes.forEachAlive(updateNote); + } if (!inCutscene) keyShit(); @@ -1288,6 +1290,7 @@ class PlayState extends MusicBeatState } var __updateNote_strum:Strum = null; + var __updateNote_event:NoteUpdateEvent = null; function updateNote(daNote:Note) { for(e in (daNote.mustPress ? playerStrums : cpuStrums).members) { @@ -1297,7 +1300,7 @@ class PlayState extends MusicBeatState } } - var event = PlayState.instance.scripts.event("onNoteUpdate", EventManager.get(NoteUpdateEvent).recycle(daNote, FlxG.elapsed, __updateNote_strum)); + var event = PlayState.instance.scripts.event("onNoteUpdate", __updateNote_event.recycle(daNote, FlxG.elapsed, __updateNote_strum)); if (!event.cancelled) { if (event.__updateHitWindow) { if (daNote.mustPress) diff --git a/source/funkin/scripting/EventManager.hx b/source/funkin/scripting/EventManager.hx index beb0b1eb..e10bef8e 100644 --- a/source/funkin/scripting/EventManager.hx +++ b/source/funkin/scripting/EventManager.hx @@ -1,5 +1,7 @@ package funkin.scripting; +import flixel.FlxG; +import flixel.FlxState; import funkin.scripting.events.*; class EventManager { @@ -19,4 +21,19 @@ class EventManager { return cast eventValues[index]; } + + public static function reset() { + for(v in eventValues) + v.destroy(); + eventValues = []; + eventKeys = []; + } + + public static function init() { + + FlxG.signals.preStateCreate.add(onStateSwitch); + } + + private static inline function onStateSwitch(newState:FlxState) + reset(); } \ No newline at end of file diff --git a/source/funkin/scripting/events/CancellableEvent.hx b/source/funkin/scripting/events/CancellableEvent.hx index 44cab794..5c0f651e 100644 --- a/source/funkin/scripting/events/CancellableEvent.hx +++ b/source/funkin/scripting/events/CancellableEvent.hx @@ -1,10 +1,10 @@ package funkin.scripting.events; -import funkin.scripting.ScriptPack; +import flixel.util.FlxDestroyUtil.IFlxDestroyable; @:allow(ScriptPack) @:autoBuild(funkin.macros.EventMacro.build()) -class CancellableEvent { +class CancellableEvent implements IFlxDestroyable { @:dox(hide) public var cancelled:Bool = false; @:dox(hide) private var __continueCalls:Bool = true; @@ -49,4 +49,8 @@ class CancellableEvent { var rep = '[${claName[claName.length-1]}${cancelled ? " (Cancelled)" : ""}]'; return rep; } + + public function destroy() { + data = null; + } } \ No newline at end of file diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index f7e01136..e6ea6cb4 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -185,7 +185,7 @@ class Main extends Sprite Assets.registerLibrary('default', lib); funkin.options.PlayerSettings.init(); - FlxG.save.bind('Save'); + FlxG.save.bind('Codename Engine'); Options.load(); Highscore.load(); @@ -206,6 +206,7 @@ class Main extends Sprite }); #end + EventManager.init(); FlxG.signals.preStateCreate.add(onStateSwitch); initTransition();