diff --git a/source/funkin/game/NoteGroup.hx b/source/funkin/game/NoteGroup.hx index c822cd81..35c3ca02 100644 --- a/source/funkin/game/NoteGroup.hx +++ b/source/funkin/game/NoteGroup.hx @@ -8,6 +8,14 @@ class NoteGroup extends FlxTypedGroup { var i:Int = 0; var __currentlyLooping:Bool = false; + /** + * Preallocates the members array with nulls, but if theres anything before it clears it + **/ + public inline function preallocate(len:Int) { + members = cast new haxe.ds.Vector(len); + length = len; + } + public inline function addNotes(notes:Array) { for(e in notes) add(e); sortNotes(); diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 6f5f62e9..98c10c1a 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -97,18 +97,41 @@ class StrumLine extends FlxTypedGroup { } public function generate(strumLine:ChartStrumLine, ?startTime:Float) { + // TODO: implement double generate call support if needed + + var total = 0; if (strumLine.notes != null) for(note in strumLine.notes) { if (startTime != null && startTime > note.time) continue; - notes.add(new Note(this, note, false)); + total++; + + if (note.sLen > Conductor.stepCrochet * 0.75) { + var len:Float = note.sLen; + while(len > 10) { + total++; + len -= Math.min(len, Conductor.stepCrochet); + } + } + } + + notes.preallocate(total); + notes.length = total; + + var il = 0; + + if (strumLine.notes != null) for(note in strumLine.notes) { + if (startTime != null && startTime > note.time) + continue; + + notes.members[total-(il++)-1] = new Note(this, note, false); if (note.sLen > Conductor.stepCrochet * 0.75) { var len:Float = note.sLen; var curLen:Float = 0; while(len > 10) { curLen = Math.min(len, Conductor.stepCrochet); - notes.add(new Note(this, note, true, curLen, note.sLen - len)); + notes.members[total-(il++)-1] = new Note(this, note, true, curLen, note.sLen - len); len -= curLen; } } @@ -248,6 +271,12 @@ class StrumLine extends FlxTypedGroup { add(createStrum(i)); } + override function destroy() { + super.destroy(); + if(startingPos != null) + startingPos.put(); + } + /** * Creates a strum and returns the created strum (needs to be added manually). * @param i Index of the strum diff --git a/source/openfl/utils/Assets.hx b/source/openfl/utils/Assets.hx index f2f2edf4..f28eea05 100644 --- a/source/openfl/utils/Assets.hx +++ b/source/openfl/utils/Assets.hx @@ -48,8 +48,6 @@ class Assets { public static var cache:IAssetCache = new AssetCache(); - public static var forceAssetLibrary:LimeAssetLibrary = null; - @:noCompletion private static var dispatcher:EventDispatcher #if !macro = new EventDispatcher() #end; private static var libraryBindings:Map = new Map(); @@ -78,9 +76,6 @@ class Assets **/ public static function exists(id:String, type:AssetType = null):Bool { - if(forceAssetLibrary != null) { - return forceAssetLibrary.exists(id, cast type); - } #if lime return LimeAssets.exists(id, cast type); #else @@ -265,9 +260,6 @@ class Assets **/ public static function getPath(id:String):String { - if(forceAssetLibrary != null) { - return forceAssetLibrary.getPath(id); - } #if lime return LimeAssets.getPath(id); #else @@ -325,9 +317,6 @@ class Assets **/ public static function getText(id:String):String { - if(forceAssetLibrary != null) { - return forceAssetLibrary.getText(id); - } #if lime return LimeAssets.getText(id); #else