diff --git a/modloader/Doorstop/Doorstop.cs b/modloader/Doorstop/Doorstop.cs deleted file mode 100644 index 5472ce6..0000000 --- a/modloader/Doorstop/Doorstop.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.IO; - -namespace Doorstop -{ - class Entrypoint - { - public static void Start() - { - File.WriteAllText("doorstop_hello.log", "Hello from Unity!");; - } - } -} \ No newline at end of file diff --git a/modloader/Doorstop/Doorstop.csproj b/modloader/Doorstop/Doorstop.csproj deleted file mode 100644 index 8e57642..0000000 --- a/modloader/Doorstop/Doorstop.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net35 - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/.signature.p7s b/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/.signature.p7s deleted file mode 100755 index eea9c6d..0000000 Binary files a/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/.signature.p7s and /dev/null differ diff --git a/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3.nupkg b/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3.nupkg deleted file mode 100755 index a858a1d..0000000 Binary files a/modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3.nupkg and /dev/null differ diff --git a/modloader/NuGet.Config b/modloader/NuGet.Config new file mode 100644 index 0000000..1864ded --- /dev/null +++ b/modloader/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/modloader/Plugin.cs b/modloader/Plugin.cs new file mode 100644 index 0000000..8a476fd --- /dev/null +++ b/modloader/Plugin.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Mono.Cecil; + +namespace modloader +{ + public static class Patcher + { + public static IEnumerable TargetDLLs => GetDLLs(); + + public static IEnumerable GetDLLs() + { + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)), "replace"); + + if (Directory.Exists(path)) + { + foreach (string assembly in Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly)) + { + Console.WriteLine("Found Assembly replacement at " + assembly); + string fileName = Path.GetFileName(assembly); + yield return fileName; + } + } + } + + // Patches the assemblies + public static void Patch(ref AssemblyDefinition assembly) + { + Console.WriteLine("Replacing " + assembly.FullName); + + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)), "replace"); + if (Directory.Exists(path)) + { + assembly = AssemblyDefinition.ReadAssembly(Path.Combine(path, assembly.Name.Name + ".dll")); + } + else + { + Console.WriteLine("Replacment path is gone??? No game Assembles will be patched!"); + } + } + } +} diff --git a/modloader/modloader.csproj b/modloader/modloader.csproj new file mode 100644 index 0000000..85c2ec5 --- /dev/null +++ b/modloader/modloader.csproj @@ -0,0 +1,22 @@ + + + + net35 + modloader + My first plugin + 1.0.0 + true + latest + + + + + + + + + + + + + diff --git a/modloader/modloader.sln b/modloader/modloader.sln index d7970b5..3ba1e72 100644 --- a/modloader/modloader.sln +++ b/modloader/modloader.sln @@ -1,6 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doorstop", "Doorstop\Doorstop.csproj", "{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}" +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "modloader", "modloader.csproj", "{E4FAB302-FC55-4F05-81DE-B43652B4AA13}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -8,9 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Release|Any CPU.Build.0 = Release|Any CPU + {E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1F587C02-7DCD-4A3A-8F81-A54ABCCB9808} EndGlobalSection EndGlobal