1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-05 14:24:28 +00:00
Funkin/source/funkin/util/plugins/ReloadAssetsDebugPlugin.hx

39 lines
811 B
Haxe

package funkin.util.plugins;
import flixel.FlxBasic;
/**
* A plugin which adds functionality to press `F5` to reload all game assets, then reload the current state.
* This is useful for hot reloading assets during development.
*/
class ReloadAssetsDebugPlugin extends FlxBasic
{
public function new()
{
super();
}
public static function initialize():Void
{
FlxG.plugins.addPlugin(new ReloadAssetsDebugPlugin());
}
public override function update(elapsed:Float):Void
{
super.update(elapsed);
if (FlxG.keys.justPressed.F5)
{
funkin.modding.PolymodHandler.forceReloadAssets();
// Create a new instance of the current state, so old data is cleared.
FlxG.resetState();
}
}
public override function destroy():Void
{
super.destroy();
}
}