mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Rename IPlugin to IComponent
This commit is contained in:
parent
dba8f8c600
commit
9dd01041d0
21 changed files with 30 additions and 37 deletions
|
@ -18,7 +18,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
|
||||
namespace Capy64.API;
|
||||
|
||||
public interface IPlugin
|
||||
public interface IComponent
|
||||
{
|
||||
void ConfigureServices(IServiceCollection services) { }
|
||||
void LuaInit(Lua L) { }
|
|
@ -41,8 +41,8 @@ public class Capy64 : Game, IGame
|
|||
"Capy64");
|
||||
public static Capy64 Instance { get; private set; }
|
||||
public Capy64 Game => this;
|
||||
public IList<IPlugin> NativePlugins { get; private set; }
|
||||
public IList<IPlugin> Plugins { get; private set; }
|
||||
public IList<IComponent> NativePlugins { get; private set; }
|
||||
public IList<IComponent> Plugins { get; private set; }
|
||||
public int Width { get; set; } = 400;
|
||||
public int Height { get; set; } = 300;
|
||||
public float Scale { get; set; } = 2f;
|
||||
|
@ -159,18 +159,18 @@ public class Capy64 : Game, IGame
|
|||
base.Initialize();
|
||||
}
|
||||
|
||||
private List<IPlugin> GetNativePlugins()
|
||||
private List<IComponent> GetNativePlugins()
|
||||
{
|
||||
var iType = typeof(IPlugin);
|
||||
var iType = typeof(IComponent);
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => iType.IsAssignableFrom(p) && !p.IsInterface);
|
||||
|
||||
var plugins = new List<IPlugin>();
|
||||
var plugins = new List<IComponent>();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
var instance = (IPlugin)ActivatorUtilities.CreateInstance(_serviceProvider, type)!;
|
||||
var instance = (IComponent)ActivatorUtilities.CreateInstance(_serviceProvider, type)!;
|
||||
plugins.Add(instance);
|
||||
}
|
||||
return plugins;
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace Capy64;
|
|||
public interface IGame
|
||||
{
|
||||
Capy64 Game { get; }
|
||||
IList<IPlugin> NativePlugins { get; }
|
||||
IList<IPlugin> Plugins { get; }
|
||||
IList<IComponent> NativePlugins { get; }
|
||||
IList<IComponent> Plugins { get; }
|
||||
GameWindow Window { get; }
|
||||
Drawing Drawing { get; }
|
||||
Audio Audio { get; }
|
||||
|
|
|
@ -27,7 +27,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Integrations;
|
||||
|
||||
public class DiscordIntegration : IPlugin
|
||||
public class DiscordIntegration : IComponent
|
||||
{
|
||||
public DiscordRpcClient Client { get; private set; }
|
||||
private readonly IConfiguration _configuration;
|
||||
|
|
|
@ -33,21 +33,21 @@ internal class PluginLoader
|
|||
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(path)));
|
||||
}
|
||||
|
||||
public static List<IPlugin> LoadAllPlugins(string pluginsPath, IServiceProvider provider)
|
||||
public static List<IComponent> LoadAllPlugins(string pluginsPath, IServiceProvider provider)
|
||||
{
|
||||
if (!Directory.Exists(pluginsPath))
|
||||
Directory.CreateDirectory(pluginsPath);
|
||||
|
||||
var plugins = new List<IPlugin>();
|
||||
var plugins = new List<IComponent>();
|
||||
foreach (var fileName in Directory.GetFiles(pluginsPath).Where(q => q.EndsWith(".dll")))
|
||||
{
|
||||
var assembly = LoadPlugin(fileName);
|
||||
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
if (typeof(IPlugin).IsAssignableFrom(type))
|
||||
if (typeof(IComponent).IsAssignableFrom(type))
|
||||
{
|
||||
IPlugin result = ActivatorUtilities.CreateInstance(provider, type) as IPlugin;
|
||||
IComponent result = ActivatorUtilities.CreateInstance(provider, type) as IComponent;
|
||||
plugins.Add(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ using static Capy64.Core.Audio;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class Audio : IPlugin
|
||||
public class Audio : IComponent
|
||||
{
|
||||
private const int queueLimit = 8;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class Event : IPlugin
|
||||
public class Event : IComponent
|
||||
{
|
||||
private static IGame _game;
|
||||
public Event(IGame game)
|
||||
|
|
|
@ -25,7 +25,7 @@ using Capy64.Runtime.Objects;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class FileSystem : IPlugin
|
||||
public class FileSystem : IComponent
|
||||
{
|
||||
public static string DataPath = Path.Combine(Capy64.AppDataPath, "data");
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ using System.IO;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class GPU : IPlugin
|
||||
public class GPU : IComponent
|
||||
{
|
||||
|
||||
private static IGame _game;
|
||||
|
|
|
@ -28,7 +28,7 @@ using System.Threading;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
#nullable enable
|
||||
public class HTTP : IPlugin
|
||||
public class HTTP : IComponent
|
||||
{
|
||||
private static IGame _game;
|
||||
private static HttpClient _httpClient;
|
||||
|
|
|
@ -25,7 +25,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class Machine : IPlugin
|
||||
public class Machine : IComponent
|
||||
{
|
||||
private static IGame _game;
|
||||
public Machine(IGame game)
|
||||
|
@ -104,13 +104,6 @@ public class Machine : IPlugin
|
|||
{
|
||||
var newTitle = L.CheckString(1);
|
||||
|
||||
if (string.IsNullOrEmpty(newTitle))
|
||||
{
|
||||
newTitle = "Capy64 " + Capy64.Version;
|
||||
}
|
||||
|
||||
newTitle = newTitle[..Math.Min(newTitle.Length, 256)];
|
||||
|
||||
Capy64.Instance.Window.Title = newTitle;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ using System;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
public class OS : IPlugin
|
||||
public class OS : IComponent
|
||||
{
|
||||
private static IGame _game;
|
||||
public OS(IGame game)
|
||||
|
|
|
@ -26,7 +26,7 @@ using static System.Formats.Asn1.AsnWriter;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
internal class Term : IPlugin
|
||||
internal class Term : IComponent
|
||||
{
|
||||
private struct Char
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
class Timer : IPlugin
|
||||
class Timer : IComponent
|
||||
{
|
||||
private LuaRegister[] TimerLib = new LuaRegister[]
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ public class LuaState : IDisposable
|
|||
|
||||
private void InitPlugins()
|
||||
{
|
||||
var allPlugins = new List<IPlugin>(Capy64.Instance.NativePlugins);
|
||||
var allPlugins = new List<IComponent>(Capy64.Instance.NativePlugins);
|
||||
allPlugins.AddRange(Capy64.Instance.Plugins);
|
||||
foreach (var plugin in allPlugins)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
public class ObjectManager : IPlugin
|
||||
public class ObjectManager : IComponent
|
||||
{
|
||||
private static ConcurrentDictionary<nint, object> _objects = new();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Runtime.Objects;
|
||||
|
||||
public class FileHandle : IPlugin
|
||||
public class FileHandle : IComponent
|
||||
{
|
||||
public const string ObjectType = "file";
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ using System.IO;
|
|||
|
||||
namespace Capy64.Runtime.Objects;
|
||||
|
||||
public class GPUBuffer : IPlugin
|
||||
public class GPUBuffer : IComponent
|
||||
{
|
||||
public const string ObjectType = "GPUBuffer";
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Threading;
|
|||
|
||||
namespace Capy64.Runtime.Objects;
|
||||
|
||||
public class WebSocketClient : IPlugin
|
||||
public class WebSocketClient : IComponent
|
||||
{
|
||||
public const string ObjectType = "WebSocketClient";
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
internal class RuntimeManager : IPlugin
|
||||
internal class RuntimeManager : IComponent
|
||||
{
|
||||
private LuaState luaState;
|
||||
private EventEmitter emitter;
|
||||
|
|
|
@ -4,7 +4,7 @@ using KeraLua;
|
|||
|
||||
namespace ExamplePlugin;
|
||||
|
||||
public class MyPlugin : IPlugin
|
||||
public class MyPlugin : IComponent
|
||||
{
|
||||
private static IGame _game;
|
||||
public MyPlugin(IGame game)
|
||||
|
|
Loading…
Reference in a new issue