From 4949982fa840e138f972d9b878d306b824e7fb91 Mon Sep 17 00:00:00 2001 From: John Gross Date: Thu, 5 Jan 2017 02:49:43 -0800 Subject: [PATCH] Plugin system working, Windows service and command system in progress --- NLog.config | 5 +- TestPlugin/Commands.cs | 25 +++++++ TestPlugin/{Class1.cs => Plugin.cs} | 1 + TestPlugin/TestPlugin.csproj | 3 +- Torch.API/PluginAttribute.cs | 8 ++- Torch.API/Torch.API.csproj | 3 + Torch.Client/Torch.Client.csproj | 15 ++++ Torch.Server/Program.cs | 36 ++++++++++ Torch.Server/Torch.Server.csproj | 20 ++++-- Torch.Server/TorchServer.cs | 21 ++++-- Torch.Server/TorchService.cs | 8 ++- Torch.sln | 5 ++ Torch/Commands/Command.cs | 52 ++++++++++++-- Torch/Commands/CommandAttribute.cs | 12 ++-- Torch/Commands/CommandContext.cs | 14 ++-- .../{CommandSystem.cs => CommandManager.cs} | 71 +++++++++---------- Torch/Commands/CommandModule.cs | 3 +- Torch/Commands/CommandTree.cs | 14 ++-- Torch/MultiplayerManager.cs | 11 ++- Torch/PluginManager.cs | 25 +++++-- Torch/Reflection.cs | 66 +++++++++-------- Torch/Torch.csproj | 23 +++++- Torch/TorchBase.cs | 7 ++ Torch/TorchPluginBase.cs | 36 +++++----- 24 files changed, 352 insertions(+), 132 deletions(-) create mode 100644 TestPlugin/Commands.cs rename TestPlugin/{Class1.cs => Plugin.cs} (90%) rename Torch/Commands/{CommandSystem.cs => CommandManager.cs} (50%) diff --git a/NLog.config b/NLog.config index 7586678..078af4e 100644 --- a/NLog.config +++ b/NLog.config @@ -3,12 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - + + + \ No newline at end of file diff --git a/TestPlugin/Commands.cs b/TestPlugin/Commands.cs new file mode 100644 index 0000000..7141749 --- /dev/null +++ b/TestPlugin/Commands.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Torch.Commands; + +namespace TestPlugin +{ + [Category("admin", "tools")] + public class Commands : CommandModule + { + [Command("Ban", "Bans a player from the game")] + public void Ban() + { + Context.Torch.Multiplayer.SendMessage("Boop!"); + } + + [Command("Unban", "Unbans a player from the game")] + public void Unban() + { + Context.Torch.Multiplayer.SendMessage("Beep!"); + } + } +} diff --git a/TestPlugin/Class1.cs b/TestPlugin/Plugin.cs similarity index 90% rename from TestPlugin/Class1.cs rename to TestPlugin/Plugin.cs index 9096c95..b276bce 100644 --- a/TestPlugin/Class1.cs +++ b/TestPlugin/Plugin.cs @@ -9,6 +9,7 @@ using VRage.Plugins; namespace TestPlugin { + [Plugin("Test Plugin", "1.3.3.7", "fed85d8d-8a29-4ab0-9869-4ad121f99d04")] public class Plugin : TorchPluginBase { /// diff --git a/TestPlugin/TestPlugin.csproj b/TestPlugin/TestPlugin.csproj index 944eaf4..24445bb 100644 --- a/TestPlugin/TestPlugin.csproj +++ b/TestPlugin/TestPlugin.csproj @@ -44,7 +44,8 @@ - + + diff --git a/Torch.API/PluginAttribute.cs b/Torch.API/PluginAttribute.cs index d5b3984..fd177c9 100644 --- a/Torch.API/PluginAttribute.cs +++ b/Torch.API/PluginAttribute.cs @@ -9,12 +9,14 @@ namespace Torch.API public class PluginAttribute : Attribute { public string Name { get; } - public bool Reloadable { get; } + public Version Version { get; } + public Guid Guid { get; } - public PluginAttribute(string name, bool reloadable = false) + public PluginAttribute(string name, string version, string guid) { Name = name; - Reloadable = reloadable; + Version = Version.Parse(version); + Guid = Guid.Parse(guid); } } } diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj index 4df395a..15d2e32 100644 --- a/Torch.API/Torch.API.csproj +++ b/Torch.API/Torch.API.csproj @@ -34,6 +34,7 @@ ..\packages\NLog.4.4.1\lib\net45\NLog.dll + True @@ -52,10 +53,12 @@ C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.dll + False False ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Library.dll + False diff --git a/Torch.Client/Torch.Client.csproj b/Torch.Client/Torch.Client.csproj index f1a2378..27926f5 100644 --- a/Torch.Client/Torch.Client.csproj +++ b/Torch.Client/Torch.Client.csproj @@ -43,13 +43,16 @@ C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Game.dll + False False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Graphics.dll + False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\SpaceEngineers.Game.dll + False @@ -64,26 +67,33 @@ C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.dll + False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Game.dll + False False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Input.dll + False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Library.dll + False False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Math.dll + False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Render.dll + False C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Render11.dll + False @@ -123,13 +133,18 @@ {fba5d932-6254-4a1e-baf4-e229fa94e3c2} Torch.API + True {7E01635C-3B67-472E-BCD6-C5539564F214} Torch + True + + copy "$(SolutionDir)NLog.config" "$(TargetDir)" +