Moved plugins folder to appdata.

Added config to disable plugins
This commit is contained in:
Alessandro Proto 2023-07-27 20:17:42 +02:00
parent f7d4b728f5
commit 3326d0e73d
3 changed files with 6 additions and 10 deletions

View file

@ -1,5 +1,6 @@
{
"EngineMode": 0,
"SafeMode": false,
"Window": {
"Scale": 2
},

View file

@ -112,7 +112,6 @@ public class Capy64 : Game
private readonly InputManager _inputManager;
private RenderTarget2D renderTarget;
private readonly GraphicsDeviceManager _graphics;
private IServiceProvider _serviceProvider;
private ulong _totalTicks = 0;
private int tickrate = 0;
private int everyTick => 60 / tickrate;
@ -122,7 +121,7 @@ public class Capy64 : Game
Instance = this;
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
//Content.RootDirectory = "Content";
IsMouseVisible = true;
EventEmitter = new();
@ -131,11 +130,6 @@ public class Capy64 : Game
Drawing = new();
}
public void ConfigureServices(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public void SetEngineMode(EngineMode mode)
{
switch (mode)
@ -265,7 +259,9 @@ public class Capy64 : Game
Audio = new Audio();
NativePlugins = GetNativePlugins();
Plugins = PluginLoader.LoadAllPlugins("plugins", _serviceProvider);
var safeMode = Configuration.GetValue("SafeMode", false);
if (!safeMode)
Plugins = PluginLoader.LoadAllPlugins(Path.Combine(AssetsPath, "plugins"));
EventEmitter.RaiseInit();
@ -284,7 +280,6 @@ public class Capy64 : Game
foreach (var type in types)
{
var instance = (IComponent)Activator.CreateInstance(type, this);
//var instance = (IComponent)ActivatorUtilities.CreateInstance(_serviceProvider, type)!;
plugins.Add(instance);
}

View file

@ -32,7 +32,7 @@ internal class PluginLoader
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(path)));
}
public static List<IComponent> LoadAllPlugins(string pluginsPath, IServiceProvider provider)
public static List<IComponent> LoadAllPlugins(string pluginsPath)
{
if (!Directory.Exists(pluginsPath))
Directory.CreateDirectory(pluginsPath);