add test plugin

This commit is contained in:
zznty
2024-10-11 12:24:02 +07:00
parent 25981da0fe
commit 8f7fef8857
4 changed files with 46 additions and 1 deletions

View File

@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CringeBootstrap.Abstraction
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CringePlugins", "CringePlugins\CringePlugins.csproj", "{16F4D4BF-D363-4C71-8364-ACD0D63B0AE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\TestPlugin.csproj", "{C1670878-2301-4AE5-ABD3-5C4D0882CB02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -36,5 +38,9 @@ Global
{16F4D4BF-D363-4C71-8364-ACD0D63B0AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16F4D4BF-D363-4C71-8364-ACD0D63B0AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16F4D4BF-D363-4C71-8364-ACD0D63B0AE8}.Release|Any CPU.Build.0 = Release|Any CPU
{C1670878-2301-4AE5-ABD3-5C4D0882CB02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1670878-2301-4AE5-ABD3-5C4D0882CB02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1670878-2301-4AE5-ABD3-5C4D0882CB02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1670878-2301-4AE5-ABD3-5C4D0882CB02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -2,9 +2,9 @@
using System.Reflection;
using System.Runtime.Loader;
using CringeBootstrap.Abstractions;
using CringeLauncher.Utils;
using CringePlugins.Utils;
using HarmonyLib;
using VRage;
using VRage.FileSystem;
using VRage.Game;
using VRage.Game.Common;
@@ -115,6 +115,9 @@ public static class IntrospectionPatches
.ToArray();
}
[HarmonyPrefix, HarmonyPatch(typeof(MyXmlSerializerManager), nameof(MyXmlSerializerManager.RegisterFromAssembly))]
private static bool XmlManagerRegisterPrefix(Assembly assembly) => AssemblyLoadContext.GetLoadContext(assembly) is ICoreLoadContext;
private static void Register<TAttribute, TCreatedObjectBase>(MyObjectFactory<TAttribute, TCreatedObjectBase> factory, Assembly assembly)
where TAttribute : MyFactoryTagAttribute where TCreatedObjectBase : class
{

22
TestPlugin/Plugin.cs Normal file
View File

@@ -0,0 +1,22 @@
using NLog;
using VRage.Plugins;
namespace TestPlugin;
public class Plugin : IPlugin
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public void Dispose()
{
}
public void Init(object gameInstance)
{
Log.Info("Test Plugin init");
}
public void Update()
{
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.3.4" ExcludeAssets="runtime" />
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.*" ExcludeAssets="runtime" />
</ItemGroup>
</Project>