Geoffrey Horsington 4 years ago
commit
5979fa4c28

+ 512 - 0
.gitignore

@@ -0,0 +1,512 @@
+
+# Created by https://www.gitignore.io/api/visualstudio,csharp
+# Edit at https://www.gitignore.io/?templates=visualstudio,csharp
+
+### Csharp ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+### VisualStudio ###
+
+# User-specific files
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+
+# Mono auto generated files
+
+# Build results
+
+# Visual Studio 2015/2017 cache/options directory
+# Uncomment if you have tasks that create the project's static files in wwwroot
+
+# Visual Studio 2017 auto generated files
+
+# MSTest test Results
+
+# NUnit
+
+# Build Results of an ATL Project
+
+# Benchmark Results
+
+# .NET Core
+
+# StyleCop
+
+# Files built by Visual Studio
+
+# Chutzpah Test files
+
+# Visual C++ cache files
+
+# Visual Studio profiler
+
+# Visual Studio Trace Files
+
+# TFS 2012 Local Workspace
+
+# Guidance Automation Toolkit
+
+# ReSharper is a .NET coding add-in
+
+# JustCode is a .NET coding add-in
+
+# TeamCity is a build add-in
+
+# DotCover is a Code Coverage Tool
+
+# AxoCover is a Code Coverage Tool
+
+# Visual Studio code coverage results
+
+# NCrunch
+
+# MightyMoose
+
+# Web workbench (sass)
+
+# Installshield output folder
+
+# DocProject is a documentation generator add-in
+
+# Click-Once directory
+
+# Publish Web Output
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+
+# NuGet Packages
+# NuGet Symbol Packages
+# The packages folder can be ignored because of Package Restore
+# except build/, which is used as an MSBuild target.
+# Uncomment if necessary however generally it will be regenerated when needed
+# NuGet v3's project.json files produces more ignorable files
+
+# Microsoft Azure Build Output
+
+# Microsoft Azure Emulator
+
+# Windows Store app package directories and files
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+# but keep track of directories ending in .cache
+
+# Others
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+
+# RIA/Silverlight projects
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+
+# SQL Server files
+
+# Business Intelligence projects
+
+# Microsoft Fakes
+
+# GhostDoc plugin setting file
+
+# Node.js Tools for Visual Studio
+
+# Visual Studio 6 build log
+
+# Visual Studio 6 workspace options file
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+
+# Visual Studio LightSwitch build output
+
+# Paket dependency manager
+
+# FAKE - F# Make
+
+# CodeRush personal settings
+
+# Python Tools for Visual Studio (PTVS)
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+
+# Telerik's JustMock configuration file
+
+# BizTalk build output
+
+# OpenCover UI analysis results
+
+# Azure Stream Analytics local run output
+
+# MSBuild Binary and Structured Log
+
+# NVidia Nsight GPU debugger configuration file
+
+# MFractors (Xamarin productivity tool) working folder
+
+# Local History for Visual Studio
+
+# BeatPulse healthcheck temp database
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+
+# End of https://www.gitignore.io/api/visualstudio,csharp

+ 54 - 0
AllMaidsInPrivateMode.Patcher/AllMaidsInPrivateMode.Patcher.csproj

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AllMaidsInPrivateMode.Patcher</RootNamespace>
+    <AssemblyName>AllMaidsInPrivateMode.Patcher</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Assembly-CSharp">
+      <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Mono.Cecil">
+      <HintPath>..\lib\Mono.Cecil.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.Core" />
+    <Reference Include="UnityEngine">
+      <HintPath>..\lib\UnityEngine.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Patcher.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="..\NeighPatcher\NeighPatcher.projitems" Label="Shared" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 45 - 0
AllMaidsInPrivateMode.Patcher/Patcher.cs

@@ -0,0 +1,45 @@
+using System.Collections.Generic;
+using System.Reflection;
+using MaidStatus;
+using Mono.Cecil;
+using NeighPatcher;
+using PrivateMaidMode;
+
+namespace AllMaidsInPrivateMode.Patcher
+{
+    public static class Patcher
+    {
+        public static readonly string[] TargetAssemblyNames = { "Assembly-CSharp.dll" };
+
+        public static void Patch(AssemblyDefinition ad)
+        {
+            NeighPatcher.NeighPatcher.PatchAll(ad, "AllMaidsInPrivateMode.Patcher.Hooks");
+        }
+    }
+
+    public static class Hooks
+    {
+        [NeighPatch("Assembly-CSharp", "PrivateMaidMode.PrivateCharaSelectMain", "OnCall")]
+        public static void OnCreate()
+        {
+            var field = typeof(PrivateCharaSelectMain).GetField("<>f__mg$cache0",
+                                                                BindingFlags.Static | BindingFlags.NonPublic);
+
+            field.SetValue(
+                null, new uGUICharacterSelectManager.CallBackMaidList(uGUICharacterSelectManager.DefaultMaidList));
+        }
+
+        [NeighPatch("Assembly-CSharp", "PrivateMaidMode.PrivateModeMgr", "CreateListData")]
+        public static void OnCreateListData(ref List<Maid> ___maidList)
+        {
+            var characterMgr = GameMain.Instance.CharacterMgr;
+            for (var i = 0; i < characterMgr.GetStockMaidCount(); i++)
+            {
+                var stockMaid = characterMgr.GetStockMaid(i);
+                var status = stockMaid.status;
+                if (status.specialRelation != SpecialRelation.Married)
+                    ___maidList.Add(stockMaid);
+            }
+        }
+    }
+}

+ 36 - 0
AllMaidsInPrivateMode.Patcher/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AllMaidsInPrivateMode.Patcher")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AllMaidsInPrivateMode.Patcher")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("ebf82671-4403-4b5f-aed1-17a8a91a9ba0")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 31 - 0
COM3D2.NeighPack.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29215.179
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AllMaidsInPrivateMode.Patcher", "AllMaidsInPrivateMode.Patcher\AllMaidsInPrivateMode.Patcher.csproj", "{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "NeighPatcher", "NeighPatcher\NeighPatcher.shproj", "{6F6241C4-DA3E-4AD7-80EB-F605E848F6DA}"
+EndProject
+Global
+	GlobalSection(SharedMSBuildProjectFiles) = preSolution
+		NeighPatcher\NeighPatcher.projitems*{6f6241c4-da3e-4ad7-80eb-f605e848f6da}*SharedItemsImports = 13
+		NeighPatcher\NeighPatcher.projitems*{ebf82671-4403-4b5f-aed1-17a8a91a9ba0}*SharedItemsImports = 4
+	EndGlobalSection
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{EBF82671-4403-4B5F-AED1-17A8A91A9BA0}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {2CF02965-1D9A-448E-991F-B28C4885842C}
+	EndGlobalSection
+EndGlobal

+ 118 - 0
NeighPatcher/NeighPatcher.cs

@@ -0,0 +1,118 @@
+using System;
+using System.Linq;
+using System.Reflection;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+
+namespace NeighPatcher
+{
+    [AttributeUsage(AttributeTargets.Method)]
+    internal class NeighPatchAttribute : Attribute
+    {
+        public string[] ArgTypes;
+        public string AssemblyName;
+        public string MethodName;
+        public string TypeName;
+
+        public NeighPatchAttribute(string assemblyName, string typeName, string methodName, params string[] argTypes)
+        {
+            AssemblyName = assemblyName;
+            TypeName = typeName;
+            MethodName = methodName;
+            ArgTypes = argTypes;
+        }
+    }
+
+    internal static class NeighPatcher
+    {
+        public static void PatchAll(AssemblyDefinition targetAssembly, string patchTypeName)
+        {
+            var hookAd = AssemblyDefinition.ReadAssembly(Assembly.GetExecutingAssembly().Location);
+            var patchType = hookAd.MainModule.GetType(patchTypeName);
+
+            Console.WriteLine($"[NeighPatcher] Patching {targetAssembly.Name.Name} with {patchType.FullName}");
+
+            foreach (var methodDefinition in patchType.Methods.Where(m => m.HasCustomAttributes))
+            {
+                var patchAttributes = methodDefinition
+                                     .CustomAttributes
+                                     .Where(c => c.HasConstructorArguments &&
+                                                 c.Constructor.DeclaringType.Name == nameof(NeighPatchAttribute))
+                                     .ToList();
+
+                if (patchAttributes.Count == 0)
+                    continue;
+
+                Console.WriteLine(
+                    $"[NeighPatcher] Applying {methodDefinition.FullName} with {patchAttributes.Count} patch attributes");
+
+                var patchAttrs = patchAttributes.Select(p => new NeighPatchAttribute(
+                                                            p.ConstructorArguments[0].Value as string,
+                                                            p.ConstructorArguments[1].Value as string,
+                                                            p.ConstructorArguments[2].Value as string,
+                                                            ((CustomAttributeArgument[])p.ConstructorArguments[3].Value)
+                                                           .Select(c => c.Value as string).ToArray())).ToList();
+
+                foreach (var neighPatchAttribute in patchAttrs)
+                {
+                    Console.WriteLine(
+                        $"[NeighPatcher] Patching [{neighPatchAttribute.AssemblyName}]{neighPatchAttribute.TypeName}::{neighPatchAttribute.MethodName} with {neighPatchAttribute.ArgTypes.Length} arg types");
+
+                    if (targetAssembly.Name.Name != neighPatchAttribute.AssemblyName)
+                        continue;
+
+                    var t = targetAssembly.MainModule.GetType(neighPatchAttribute.TypeName);
+
+                    Console.WriteLine($"[NeighPatcher] Found type {t}");
+
+                    var method = t?.Methods.FirstOrDefault(m => m.Name == neighPatchAttribute.MethodName &&
+                                                                (neighPatchAttribute.ArgTypes.Length == 0 ||
+                                                                 neighPatchAttribute.ArgTypes.Length != 0 &&
+                                                                 neighPatchAttribute.ArgTypes.Length ==
+                                                                 m.Parameters.Count &&
+                                                                 m.Parameters.Select(p => p.ParameterType.FullName)
+                                                                  .SequenceEqual(neighPatchAttribute.ArgTypes)));
+
+                    Console.WriteLine($"[NeighPatcher] Found method {method}");
+
+                    if (method == null)
+                        continue;
+
+                    var il = method.Body.GetILProcessor();
+                    var ins = method.Body.Instructions.First();
+
+                    foreach (var mParam in methodDefinition.Parameters)
+                        if (mParam.Name == "__instance")
+                            il.InsertBefore(ins, il.Create(OpCodes.Ldarg_0));
+                        else if (mParam.Name.StartsWith("___"))
+                        {
+                            string realName = mParam.Name.Substring(3);
+                            var targetField = t.Fields.FirstOrDefault(ff => ff.Name == realName);
+                            if (targetField == null)
+                                throw new Exception($"Field {realName} not found from type {t.FullName}!");
+
+                            if (!method.IsStatic)
+                            {
+                                il.InsertBefore(ins, il.Create(OpCodes.Ldarg_0));
+                                il.InsertBefore(ins, il.Create(OpCodes.Ldflda, targetField));
+                            }
+                            else
+                                il.InsertBefore(ins, il.Create(OpCodes.Ldsflda, targetField));
+                        }
+                        else
+                        {
+                            var pIndex = method.Parameters.FirstOrDefault(p => p.Name == mParam.Name);
+
+                            if (pIndex == null)
+                                throw new Exception(
+                                    $"Parameter with name {mParam.Name} does not exist in {method.FullName}");
+                            il.InsertBefore(ins, il.Create(OpCodes.Ldarg, pIndex));
+                        }
+
+                    il.InsertBefore(
+                        ins, il.Create(OpCodes.Call, targetAssembly.MainModule.ImportReference(methodDefinition)));
+                }
+            }
+        }
+    }
+}

+ 14 - 0
NeighPatcher/NeighPatcher.projitems

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+    <HasSharedItems>true</HasSharedItems>
+    <SharedGUID>6f6241c4-da3e-4ad7-80eb-f605e848f6da</SharedGUID>
+  </PropertyGroup>
+  <PropertyGroup Label="Configuration">
+    <Import_RootNamespace>NeighPatcher</Import_RootNamespace>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildThisFileDirectory)NeighPatcher.cs" />
+  </ItemGroup>
+</Project>

+ 13 - 0
NeighPatcher/NeighPatcher.shproj

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>6f6241c4-da3e-4ad7-80eb-f605e848f6da</ProjectGuid>
+    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+  </PropertyGroup>
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
+  <PropertyGroup />
+  <Import Project="NeighPatcher.projitems" Label="Shared" />
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
+</Project>

BIN
lib/Assembly-CSharp.dll


BIN
lib/ExIni.dll


BIN
lib/Mono.Cecil.dll


BIN
lib/UnityEngine.dll


BIN
lib/UnityInjector.dll