Compare commits

...

50 Commits

Author SHA1 Message Date
12d607c42e Update version number 2024-11-27 11:41:33 +08:00
de8f444b4e Update 2024-11-27 11:40:32 +08:00
6de5607c6a Update 2024-05-27 00:58:41 +08:00
5c8958b3a5 Update 2024-05-27 00:56:28 +08:00
52eb232c34 Update 2024-05-27 00:49:50 +08:00
62ee9c5fde Update Version num 2024-05-27 00:36:25 +08:00
20a9d88cf2 Update 2024-05-27 00:28:04 +08:00
f243cec5e0 Update 2024-04-17 16:35:35 +08:00
665853e920 Update 2024-04-17 16:29:24 +08:00
cf8ad00bd3 Update 2024-04-13 11:19:19 +08:00
e57400fa98 Update 2024-04-13 10:32:58 +08:00
3130218b8f Update 2024-04-09 11:30:15 +08:00
8fc8411ced Update 2024-04-09 11:26:00 +08:00
816f1a14f1 Update 2024-04-08 13:15:51 +08:00
7863c7bd2e Update 2024-04-08 13:00:30 +08:00
d224f78065 Update 2024-04-08 12:55:41 +08:00
7e96c4528c Update 2024-04-08 11:17:44 +08:00
f7caaaadaf Depend on EFTApi and refactor code 2024-04-08 10:45:58 +08:00
d75de1aa04 Update 2023-02-27 12:33:56 +08:00
df9523912a Update 2023-02-27 07:42:12 +08:00
ff494a568c Update 2023-02-01 19:33:52 +08:00
18d44bcd35 Update 2023-01-29 02:29:21 +08:00
98d557f8e3 Update 2023-01-15 04:42:28 +08:00
4944c33cc8 Update 2023-01-14 00:30:56 +08:00
f33247bfac Update 2023-01-13 18:22:27 +08:00
86401f86ae Update 2023-01-05 08:50:05 +08:00
28377e19a1 Update 2023-01-05 08:49:45 +08:00
6cebf091a5 Update 2023-01-05 08:49:34 +08:00
a980b6c71b Update 2023-01-05 08:10:04 +08:00
a276adeedb Update 2022-11-21 23:02:45 +08:00
42381ace29 Update 2022-11-07 11:03:15 +08:00
87b4bef91f Update 2022-11-07 10:17:07 +08:00
6021aa664c Update 2022-10-29 13:08:40 +08:00
3becac4bb8 Update 2022-10-27 03:38:50 +08:00
4fb633526c Update 2022-10-26 10:28:01 +08:00
98be2c5331 Update 2022-10-26 10:27:36 +08:00
86237eb31d Update 2022-10-26 10:06:24 +08:00
ddc6db59a1 Update 2022-10-19 10:52:25 +08:00
fc0a11fd65 Update 2022-10-19 10:48:12 +08:00
e6308df25f Update 2022-10-17 23:29:49 +08:00
8d025bad3a Update 2022-10-17 23:24:05 +08:00
74ec6ed775 Update 2022-10-17 22:34:46 +08:00
6721410da4 Update 2022-10-17 21:41:22 +08:00
4c5f9b4998 Update 2022-10-15 15:53:31 +08:00
b86f5edf5d Update 2022-10-15 13:09:46 +08:00
9ef8b5952e Update 2022-10-15 13:09:17 +08:00
120090b2b8 Update 2022-10-15 13:05:36 +08:00
4e85b5a21f Update 2022-10-15 13:05:00 +08:00
539ab18f3a Update 2022-10-13 10:14:01 +08:00
fe88c316b9 Update 2022-10-13 08:50:40 +08:00
23 changed files with 584 additions and 599 deletions

6
Build/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

108
Build/Build.csproj Normal file
View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.2.0.321\build\net46\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.321\build\net46\LibGit2Sharp.NativeBinaries.props')" />
<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>{890B32EA-1CB9-45FB-918A-A8A66558FD6F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Build</RootNamespace>
<AssemblyName>Build</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="CopyBuildAssembly, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CopyBuildAssembly.1.0.0\lib\net472\CopyBuildAssembly.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.29.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<HintPath>..\packages\LibGit2Sharp.0.29.0\lib\net472\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.5\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.5\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.5\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.5\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="SevenZipSharp, Version=1.6.1.23, Culture=neutral, PublicKeyToken=c8ff6ba0184838bb, processorArchitecture=MSIL">
<HintPath>..\packages\Squid-Box.SevenZipSharp.1.6.1.23\lib\net472\SevenZipSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="localized\en.json" />
<None Include="localized\zh.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HideDress\HideDress.csproj">
<Project>{e5dd6484-115e-4104-aadf-e5610ee4f397}</Project>
<Name>HideDress</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.321\build\net46\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.2.0.321\build\net46\LibGit2Sharp.NativeBinaries.props'))" />
<Error Condition="!Exists('..\packages\CopyBuildAssembly.1.0.0\build\CopyBuildAssembly.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CopyBuildAssembly.1.0.0\build\CopyBuildAssembly.targets'))" />
<Error Condition="!Exists('..\packages\7z.Libs.23.01.0\build\net\7z.Libs.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\7z.Libs.23.01.0\build\net\7z.Libs.targets'))" />
</Target>
<Import Project="..\packages\CopyBuildAssembly.1.0.0\build\CopyBuildAssembly.targets" Condition="Exists('..\packages\CopyBuildAssembly.1.0.0\build\CopyBuildAssembly.targets')" />
<Import Project="..\packages\7z.Libs.23.01.0\build\net\7z.Libs.targets" Condition="Exists('..\packages\7z.Libs.23.01.0\build\net\7z.Libs.targets')" />
<PropertyGroup>
<PostBuildEvent>xcopy $(ProjectDir)localized\ $(TargetDir)localized\ /E /Y
start $(TargetPath) $(ConfigurationName) $(SolutionDir)</PostBuildEvent>
</PropertyGroup>
</Project>

49
Build/Program.cs Normal file
View File

@ -0,0 +1,49 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using CopyBuildAssembly;
// ReSharper disable ClassNeverInstantiated.Global
namespace Build
{
internal class Program
{
private static void Main(string[] args)
{
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var arg = args.ElementAtOrDefault(0);
var sha = Copy.GetTipSha(args.ElementAtOrDefault(1));
const string modPath =
@"R:\Battlestate Games\Client.0.15.5.1.33420\BepInEx\plugins\kmyuhkyuk-HideDress";
const string versionName = "1.3.1";
var releaseName = $"{new DirectoryInfo(modPath).Name}-(Release_{versionName}).7z";
try
{
Copy.CopyFolder(arg, "Release", Path.Combine(baseDirectory, "localized"),
Path.Combine(modPath, "localized"));
Copy.CopyAssembly(arg, "Release", baseDirectory, modPath, new[]
{
"HideDress"
}, sha);
Copy.GenerateSevenZip(arg, "Release", modPath, releaseName, @"BepInEx\plugins", Array.Empty<string>(),
Array.Empty<string>(), new[] { Path.Combine(baseDirectory, "ReadMe.txt") }, Array.Empty<string>());
}
catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadKey();
Process.GetCurrentProcess().Kill();
}
}
}
}

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Build")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Build")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("890b32ea-1cb9-45fb-918a-a8a66558fd6f")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

3
Build/ReadMe.txt Normal file
View File

@ -0,0 +1,3 @@
This Mod Require EFTApi(https://hub.sp-tarkov.com/files/file/1215-eft-api), You need to install it to work
此模组依赖EFTApi(https://hub.sp-tarkov.com/files/file/1215-eft-api), 你需要安装它才能运行

10
Build/localized/en.json Normal file
View File

@ -0,0 +1,10 @@
{
"HideDress": "Hide Dress",
"Hide Dress Settings": "Hide Dress Settings",
"Hide Dress Part Settings": "Hide Dress Part Settings",
"Keyboard Shortcut Settings": "Keyboard Shortcut Settings",
"Update Hide Player Dress": "Update Hide Player Dress",
"Update Hide Other Player Dress": "Update Hide Other Player Dress",
"Player": "Player",
"Other Player": "Other Player"
}

10
Build/localized/zh.json Normal file
View File

@ -0,0 +1,10 @@
{
"HideDress": "隐藏服饰",
"Hide Dress Settings": "隐藏服饰设置",
"Hide Dress Part Settings": "隐藏服饰部位设置",
"Keyboard Shortcut Settings": "快捷键设置",
"Update Hide Player Dress": "更新隐藏玩家服饰",
"Update Hide Other Player Dress": "更新隐藏其他玩家服饰",
"Player": "玩家",
"Other Player": "其他玩家"
}

9
Build/packages.config Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="7z.Libs" version="23.01.0" targetFramework="net472" />
<package id="CopyBuildAssembly" version="1.0.0" targetFramework="net472" />
<package id="LibGit2Sharp" version="0.29.0" targetFramework="net472" />
<package id="LibGit2Sharp.NativeBinaries" version="2.0.321" targetFramework="net472" />
<package id="Mono.Cecil" version="0.11.5" targetFramework="net472" />
<package id="Squid-Box.SevenZipSharp" version="1.6.1.23" targetFramework="net472" />
</packages>

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkinHide", "SkinHide\SkinHide.csproj", "{E5DD6484-115E-4104-AADF-E5610EE4F397}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HideDress", "HideDress\HideDress.csproj", "{E5DD6484-115E-4104-AADF-E5610EE4F397}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{890B32EA-1CB9-45FB-918A-A8A66558FD6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{E5DD6484-115E-4104-AADF-E5610EE4F397}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5DD6484-115E-4104-AADF-E5610EE4F397}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5DD6484-115E-4104-AADF-E5610EE4F397}.Release|Any CPU.Build.0 = Release|Any CPU
{890B32EA-1CB9-45FB-918A-A8A66558FD6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{890B32EA-1CB9-45FB-918A-A8A66558FD6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{890B32EA-1CB9-45FB-918A-A8A66558FD6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{890B32EA-1CB9-45FB-918A-A8A66558FD6F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,50 @@
namespace HideDress.Attributes
{
// ReSharper disable InvalidXmlDocComment
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable NotAccessedField.Global
/// <summary>
/// You can copy this file to any project and bind Attribute to Plugin
/// </summary>
/// <remarks>
/// <see cref="EFTConfigurationPlugin" /> will auto search Attribute by name and fields
/// </remarks>
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class EFTConfigurationPluginAttributes : System.Attribute
{
/// <summary>
/// Your Mod URL From Aki Hub Mod page
/// </summary>
public string ModURL;
/// <summary>
/// Never displayed Plugin
/// </summary>
/// <remarks>
/// Copy <see cref="System.ComponentModel.BrowsableAttribute" />
/// </remarks>
public bool HidePlugin;
/// <summary>
/// Keep plugins displayed with not any setting
/// </summary>
/// <remarks>
/// It prioritizes lower than <see cref="HidePlugin" />
/// </remarks>
public bool AlwaysDisplay;
/// <summary>
/// Localized folder, Combine Path from bind attribute plugin dll directory
/// </summary>
public string LocalizedPath;
public EFTConfigurationPluginAttributes(string modURL, string localizedPath = "localized",
bool hidePlugin = false, bool alwaysDisplay = false)
{
ModURL = modURL;
LocalizedPath = localizedPath;
HidePlugin = hidePlugin;
AlwaysDisplay = alwaysDisplay;
}
}
}

View File

@ -7,8 +7,8 @@
<ProjectGuid>{E5DD6484-115E-4104-AADF-E5610EE4F397}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SkinHide</RootNamespace>
<AssemblyName>SkinHide</AssemblyName>
<RootNamespace>HideDress</RootNamespace>
<AssemblyName>HideDress</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
@ -41,9 +41,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Aki.Reflection">
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
@ -51,38 +48,32 @@
<Reference Include="BepInEx">
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
<Reference Include="EFTApi">
<HintPath>..\..\EFTApi\Build\bin\Current\EFTApi.dll</HintPath>
</Reference>
<Reference Include="EFTReflection">
<HintPath>..\..\EFTApi\Build\bin\Current\EFTReflection.dll</HintPath>
</Reference>
<Reference Include="Sirenix.Serialization, Version=3.0.4.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Patches\PlayerPatch.cs" />
<Compile Include="Patches\PlayerModelViewPatch.cs" />
<Compile Include="SkinHidePlugin.cs" />
<Compile Include="Attributes\EFTConfigurationPluginAttributes.cs" />
<Compile Include="Models\ReflectionModel.cs" />
<Compile Include="Models\SettingsModel.cs" />
<Compile Include="Models\HideDressModel.cs" />
<Compile Include="HideDressPlugin.cs" />
<Compile Include="Patches\PlayerModelViewShow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\RefHelp.cs" />
</ItemGroup>
<ItemGroup>
<None Include="kmyuhkyuk.pfx" />

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=patches/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using BepInEx;
using EFT;
using EFT.Visual;
using HideDress.Attributes;
using HideDress.Models;
using static EFTApi.EFTHelpers;
namespace HideDress
{
[BepInPlugin("com.kmyuhkyuk.HideDress", "HideDress", "1.3.1")]
[BepInDependency("com.kmyuhkyuk.EFTApi", "1.2.1")]
[EFTConfigurationPluginAttributes("https://hub.sp-tarkov.com/files/file/654-hide-dress")]
public partial class HideDressPlugin : BaseUnityPlugin
{
private void Awake()
{
SettingsModel.Create(Config);
}
private void Start()
{
ReflectionModel.Instance.PlayerModelViewShow.Add(this, nameof(PlayerModelViewShow));
}
private void Update()
{
var player = _PlayerHelper.Player;
var world = _GameWorldHelper.GameWorld;
var settingsModel = SettingsModel.Instance;
var hideDressModel = HideDressModel.Instance;
if (settingsModel.KeyUpdatePlayerHideDressShortcut.Value.IsDown())
{
settingsModel.KeyUpdatePlayerHideDress.Value = !settingsModel.KeyUpdatePlayerHideDress.Value;
}
if (settingsModel.KeyUpdateOtherPlayerHideDressShortcut.Value.IsDown())
{
settingsModel.KeyUpdateOtherPlayerHideDress.Value = !settingsModel.KeyUpdateOtherPlayerHideDress.Value;
}
if (settingsModel.KeyUpdatePlayerHideDress.Value && hideDressModel.PlayerModelViewBody)
{
EnabledPartDress(hideDressModel.PlayerModelViewBody, settingsModel.KeyPlayerHideDressPart.Value);
}
if (settingsModel.KeyUpdatePlayerHideDress.Value && player)
{
EnabledPartDress(player.PlayerBody, settingsModel.KeyPlayerHideDressPart.Value);
}
if (settingsModel.KeyUpdateOtherPlayerHideDress.Value && world)
{
foreach (var otherPlayer in _GameWorldHelper.AllOtherPlayer)
{
if (!otherPlayer)
continue;
EnabledPartDress(otherPlayer.PlayerBody, settingsModel.KeyOtherPlayerHideDressPart.Value);
}
}
}
private static void EnabledPartDress(PlayerBody playerBody, HideDressModel.DressPart dressPart)
{
var reflectionModel = ReflectionModel.Instance;
var slotViews = reflectionModel.RefSlotViews.GetValue(playerBody);
var slotList = reflectionModel.RefSlotList.GetValue(slotViews);
var dressList = new List<Dress>();
foreach (var slot in slotList)
{
var dresses = reflectionModel.RefDresses.GetValue(slot);
if (dresses == null)
continue;
foreach (var dress in dresses)
{
dressList.Add(dress);
}
}
switch (dressPart)
{
case HideDressModel.DressPart.Both:
EnabledDress(dressList, false);
EnabledSkinDress(dressList, false);
break;
case HideDressModel.DressPart.Dress:
EnabledDress(dressList, false);
EnabledSkinDress(dressList, true);
break;
case HideDressModel.DressPart.SkinDress:
EnabledDress(dressList, true);
EnabledSkinDress(dressList, false);
break;
case HideDressModel.DressPart.None:
EnabledDress(dressList, true);
EnabledSkinDress(dressList, true);
break;
default:
throw new ArgumentOutOfRangeException(nameof(dressPart), dressPart, null);
}
}
private static void EnabledDress(IEnumerable<Dress> dressEnumerable, bool enabled)
{
foreach (var dress in dressEnumerable)
{
var dressType = dress.GetType();
if (dressType != typeof(Dress))
continue;
foreach (var renderer in ReflectionModel.Instance.RefRenderers.GetValue(dress))
{
renderer.enabled = enabled;
}
}
}
private static void EnabledSkinDress(IEnumerable<Dress> dressEnumerable, bool enabled)
{
foreach (var dress in dressEnumerable)
{
var dressType = dress.GetType();
if (dressType != typeof(SkinDress) && dressType != typeof(ArmBandView))
continue;
dress.gameObject.SetActive(enabled);
}
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using EFT;
namespace HideDress.Models
{
internal class HideDressModel
{
private static readonly Lazy<HideDressModel> Lazy = new Lazy<HideDressModel>(() => new HideDressModel());
public static HideDressModel Instance => Lazy.Value;
public PlayerBody PlayerModelViewBody;
public enum DressPart
{
Both,
Dress,
SkinDress,
None
}
private HideDressModel()
{
}
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections;
using EFT;
using EFT.UI;
using EFT.Visual;
using EFTReflection;
using UnityEngine;
namespace HideDress.Models
{
internal class ReflectionModel
{
private static readonly Lazy<ReflectionModel> Lazy = new Lazy<ReflectionModel>(() => new ReflectionModel());
public static ReflectionModel Instance => Lazy.Value;
public readonly RefHelper.FieldRef<PlayerBody, object> RefSlotViews;
public readonly RefHelper.FieldRef<object, IList> RefSlotList;
public readonly RefHelper.FieldRef<object, Dress[]> RefDresses;
public readonly RefHelper.FieldRef<Dress, Renderer[]> RefRenderers;
public readonly RefHelper.HookRef PlayerModelViewShow;
private ReflectionModel()
{
RefSlotViews = RefHelper.FieldRef<PlayerBody, object>.Create("SlotViews");
RefSlotList = RefHelper.FieldRef<object, IList>.Create(RefSlotViews.FieldType, "list_0");
RefDresses =
RefHelper.FieldRef<object, Dress[]>.Create(RefSlotList.FieldType.GetGenericArguments()[0], "Dresses");
RefRenderers = RefHelper.FieldRef<Dress, Renderer[]>.Create("Renderers");
PlayerModelViewShow = RefHelper.HookRef.Create(typeof(PlayerModelView),
x => x.Name == "Show" && x.GetParameters()[0].ParameterType != typeof(Profile));
}
}
}

View File

@ -0,0 +1,54 @@
using System.Diagnostics.CodeAnalysis;
using BepInEx.Configuration;
namespace HideDress.Models
{
internal class SettingsModel
{
public static SettingsModel Instance { get; private set; }
public readonly ConfigEntry<bool> KeyUpdatePlayerHideDress;
public readonly ConfigEntry<bool> KeyUpdateOtherPlayerHideDress;
public readonly ConfigEntry<HideDressModel.DressPart> KeyPlayerHideDressPart;
public readonly ConfigEntry<HideDressModel.DressPart> KeyOtherPlayerHideDressPart;
public readonly ConfigEntry<KeyboardShortcut> KeyUpdatePlayerHideDressShortcut;
public readonly ConfigEntry<KeyboardShortcut> KeyUpdateOtherPlayerHideDressShortcut;
[SuppressMessage("ReSharper", "RedundantTypeArgumentsOfMethod")]
private SettingsModel(ConfigFile configFile)
{
const string hideDressSettings = "Hide Dress Settings";
const string hideDressPartSettings = "Hide Dress Part Settings";
const string shortcutSettings = "Keyboard Shortcut Settings";
KeyUpdatePlayerHideDress = configFile.Bind<bool>(hideDressSettings, "Update Hide Player Dress", false);
KeyUpdateOtherPlayerHideDress =
configFile.Bind<bool>(hideDressSettings, "Update Hide Other Player Dress", false);
KeyPlayerHideDressPart =
configFile.Bind<HideDressModel.DressPart>(hideDressPartSettings, "Player",
HideDressModel.DressPart.Both);
KeyOtherPlayerHideDressPart =
configFile.Bind<HideDressModel.DressPart>(hideDressPartSettings, "Other Player",
HideDressModel.DressPart.Both);
KeyUpdatePlayerHideDressShortcut =
configFile.Bind<KeyboardShortcut>(shortcutSettings, "Update Hide Player Dress",
KeyboardShortcut.Empty);
KeyUpdateOtherPlayerHideDressShortcut =
configFile.Bind<KeyboardShortcut>(shortcutSettings, "Update Hide Other Player Dress",
KeyboardShortcut.Empty);
}
// ReSharper disable once UnusedMethodReturnValue.Global
public static SettingsModel Create(ConfigFile configFile)
{
if (Instance != null)
return Instance;
return Instance = new SettingsModel(configFile);
}
}
}

View File

@ -0,0 +1,16 @@
using System.Threading.Tasks;
using EFT.UI;
using HideDress.Models;
namespace HideDress
{
public partial class HideDressPlugin
{
private static async void PlayerModelViewShow(Task __result, PlayerModelView __instance)
{
await __result;
HideDressModel.Instance.PlayerModelViewBody = __instance.PlayerBody;
}
}
}

View File

@ -1,15 +1,14 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("kmyuhkyuk-SkinHide")]
[assembly: AssemblyTitle("kmyuhkyuk-HideDress")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("https://hub.sp-tarkov.com/files/file/583-skin-hide")]
[assembly: AssemblyProduct("SkinHide")]
[assembly: AssemblyCompany("https://hub.sp-tarkov.com/files/file/654-hide-dress")]
[assembly: AssemblyProduct("HideDress")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.5.0")]
[assembly: AssemblyFileVersion("1.2.5.0")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]

View File

@ -1,6 +1,6 @@
# SkinHide
# HideDress
Hide Player and Bot all Gear
Hide your or other player dress
## How build the source
1. Dowload or Clone the branch

View File

@ -1,25 +0,0 @@
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using System.Reflection;
using System.Threading.Tasks;
using EFT;
using EFT.UI;
namespace SkinHide.Patches
{
public class PlayerModelViewPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(PlayerModelView).GetMethod("method_0", PatchConstants.PrivateFlags);
}
[PatchPostfix]
private static async void PatchPostfix(Task __result, PlayerModelView __instance)
{
await __result;
SkinHidePlugin.PlayerModelView = __instance.PlayerBody;
}
}
}

View File

@ -1,50 +0,0 @@
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using System.Reflection;
using System.Threading.Tasks;
using Comfort.Common;
using EFT;
namespace SkinHide.Patches
{
public class PlayerPatch : ModulePatch
{
private static bool? Is231Up;
protected override MethodBase GetTargetMethod()
{
return typeof(Player).GetMethod("Init", PatchConstants.PrivateFlags);
}
[PatchPostfix]
private async static void PatchPostfix(Task __result, Player __instance)
{
await __result;
if (!Is231Up.HasValue)
{
Is231Up = typeof(Player).GetProperty("IsYourPlayer").GetSetMethod() == null;
}
bool isyouplayer;
if ((bool)Is231Up)
{
isyouplayer = __instance.IsYourPlayer;
}
else
{
isyouplayer = __instance == Singleton<GameWorld>.Instance.AllPlayers[0];
}
if (isyouplayer)
{
SkinHidePlugin.Player = __instance.PlayerBody;
}
else
{
SkinHidePlugin.Bot.Add(__instance.PlayerBody);
}
}
}
}

View File

@ -1,156 +0,0 @@
using BepInEx;
using BepInEx.Configuration;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using EFT;
using EFT.Visual;
using SkinHide.Patches;
using SkinHide.Utils;
namespace SkinHide
{
[BepInPlugin("com.kmyuhkyuk.SkinHide", "kmyuhkyuk-SkinHide", "1.2.5")]
public class SkinHidePlugin : BaseUnityPlugin
{
internal static PlayerBody Player;
internal static PlayerBody PlayerModelView;
internal static List<PlayerBody> Bot = new List<PlayerBody>();
private SettingsData settingsdata = new SettingsData();
private ReflectionData reflectiondata = new ReflectionData();
public enum Part
{
All,
Dress,
SkinDress
}
private void Start()
{
Logger.LogInfo("Loaded: kmyuhkyuk-SkinHide");
string SkinHideSettings = "Skin Hide Settings";
string SkinHidePartSettings = "隐藏部分设置 Skin Hide Part Settings";
string KBSSettings = "快捷键设置 Keyboard Shortcut Settings";
settingsdata.KeyPlayerSkinHide = Config.Bind<bool>(SkinHideSettings, "玩家服装隐藏 Player Skin Hide", false);
settingsdata.KeyBotSkinHide = Config.Bind<bool>(SkinHideSettings, "Bot服装隐藏 Bot Skin Hide", false);
settingsdata.KeyPlayerSkinHidePart = Config.Bind<Part>(SkinHidePartSettings, "Player", Part.All);
settingsdata.KeyBotSkinHidePart = Config.Bind<Part>(SkinHidePartSettings, "Bot", Part.All);
settingsdata.KBSPlayerSkinHide = Config.Bind<KeyboardShortcut>(KBSSettings, "玩家服装隐藏快捷键 Player Skin Hide", KeyboardShortcut.Empty);
settingsdata.KBSBotSkinHide = Config.Bind<KeyboardShortcut>(KBSSettings, "Bot服装隐藏快捷键 Bot Skin Hide", KeyboardShortcut.Empty);
new PlayerModelViewPatch().Enable();
new PlayerPatch().Enable();
reflectiondata.RefSlotViews = RefHelp.FieldRef<PlayerBody, object>.Create("SlotViews");
reflectiondata.RefSlotList = RefHelp.FieldRef<object, IEnumerable<object>>.Create(reflectiondata.RefSlotViews.FieldType, "list_0");
reflectiondata.RefDresses = RefHelp.FieldRef<object, Dress[]>.Create(reflectiondata.RefSlotList.FieldType.GetGenericArguments()[0], "Dresses");
}
void Update()
{
if (settingsdata.KBSPlayerSkinHide.Value.IsDown())
{
settingsdata.KeyPlayerSkinHide.Value = !settingsdata.KeyPlayerSkinHide.Value;
}
if (settingsdata.KBSBotSkinHide.Value.IsDown())
{
settingsdata.KeyBotSkinHide.Value = !settingsdata.KeyBotSkinHide.Value;
}
//PlayerModelView Skin Hide
if (PlayerModelView != null)
{
Hide(PlayerModelView, settingsdata.KeyPlayerSkinHidePart.Value, settingsdata.KeyPlayerSkinHide.Value);
}
//Player Skin Hide
if (Player != null)
{
Hide(Player, settingsdata.KeyPlayerSkinHidePart.Value, settingsdata.KeyPlayerSkinHide.Value);
}
else
{
Bot.Clear();
}
//Bot Skin Hide
if (Bot.Count > 0)
{
foreach (PlayerBody bot in Bot)
{
Hide(bot, settingsdata.KeyBotSkinHidePart.Value, settingsdata.KeyBotSkinHide.Value);
}
}
}
void Hide(PlayerBody playerbody, Part part, bool hide)
{
object slotviews = reflectiondata.RefSlotViews.GetValue(playerbody);
IEnumerable<object> slotlist = reflectiondata.RefSlotList.GetValue(slotviews);
Dress[] dresses = slotlist.Where(x => reflectiondata.RefDresses.GetValue(x) != null).SelectMany(x => reflectiondata.RefDresses.GetValue(x)).ToArray();
GameObject[] dress = dresses.Where(x => x.GetType() == typeof(Dress)).Select(x => x.gameObject).ToArray();
MeshRenderer[] renderers = dress.SelectMany(x => x.gameObject.GetComponentsInChildren<MeshRenderer>()).ToArray();
GameObject[] skindress = dresses.Where(x => x.GetType() == typeof(SkinDress) || x.GetType() == typeof(ArmBandView)).Select(x => x.gameObject).ToArray();
switch (part)
{
case Part.All:
foreach (GameObject gameobject in skindress)
{
gameobject.SetActive(!hide);
}
foreach (MeshRenderer renderer in renderers)
{
renderer.enabled = !hide;
}
break;
case Part.Dress:
foreach (MeshRenderer renderer in renderers)
{
renderer.enabled = !hide;
}
break;
case Part.SkinDress:
foreach (GameObject gameobject in skindress)
{
gameobject.SetActive(!hide);
}
break;
}
}
public class SettingsData
{
public ConfigEntry<bool> KeyPlayerSkinHide;
public ConfigEntry<bool> KeyBotSkinHide;
public ConfigEntry<Part> KeyPlayerSkinHidePart;
public ConfigEntry<Part> KeyBotSkinHidePart;
public ConfigEntry<KeyboardShortcut> KBSPlayerSkinHide;
public ConfigEntry<KeyboardShortcut> KBSBotSkinHide;
}
public class ReflectionData
{
public RefHelp.FieldRef<PlayerBody, object> RefSlotViews;
public RefHelp.FieldRef<object, IEnumerable<object>> RefSlotList;
public RefHelp.FieldRef<object, Dress[]> RefDresses;
}
}
}

View File

@ -1,337 +0,0 @@
using Aki.Reflection.Utils;
using HarmonyLib;
using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace SkinHide.Utils
{
public class RefHelp
{
public static DelegateType ObjectMethodDelegate<DelegateType>(MethodInfo method, bool virtualCall = true) where DelegateType : Delegate
{
if (method is null)
{
throw new ArgumentNullException(nameof(method));
}
var delegateType = typeof(DelegateType);
var declaringType = method.DeclaringType;
var DelegateMethod = delegateType.GetMethod("Invoke");
var DelegateParameters = DelegateMethod.GetParameters();
var DelegateparameterTypes = DelegateParameters.Select(x => x.ParameterType).ToArray();
Type ReturnType;
bool NeedBox;
if (DelegateMethod.ReturnType == typeof(object) && method.ReturnType.IsValueType)
{
ReturnType = typeof(object);
NeedBox = true;
}
else
{
ReturnType = method.ReturnType;
NeedBox = false;
}
var dmd = new DynamicMethod("OpenInstanceDelegate_" + method.Name, ReturnType, DelegateparameterTypes);
var ilGen = dmd.GetILGenerator();
Type[] parameterTypes;
int num;
if (!method.IsStatic)
{
var parameters = method.GetParameters();
var numParameters = parameters.Length;
parameterTypes = new Type[numParameters + 1];
parameterTypes[0] = typeof(object);
for (int i = 0; i < numParameters; i++)
{
parameterTypes[i + 1] = parameters[i].ParameterType;
}
if (declaringType != null && declaringType.IsValueType)
{
ilGen.Emit(OpCodes.Ldarga_S, 0);
}
else
{
ilGen.Emit(OpCodes.Ldarg_0);
}
ilGen.Emit(OpCodes.Castclass, declaringType);
num = 1;
}
else
{
parameterTypes = method.GetParameters().Select(x => x.ParameterType).ToArray();
num = 0;
}
for (int i = num; i < parameterTypes.Length; i++)
{
ilGen.Emit(OpCodes.Ldarg, i);
bool isvaluetype = parameterTypes[i].IsValueType;
if (!isvaluetype)
{
ilGen.Emit(OpCodes.Castclass, parameterTypes[i]);
}
// DelegateparameterTypes i == parameterTypes i
else if (DelegateparameterTypes[i] == typeof(object) && isvaluetype)
{
ilGen.Emit(OpCodes.Unbox_Any, parameterTypes[i]);
}
}
if (method.IsStatic || !virtualCall)
{
ilGen.Emit(OpCodes.Call, method);
}
else
{
ilGen.Emit(OpCodes.Callvirt, method);
}
if (NeedBox)
{
ilGen.Emit(OpCodes.Box, method.ReturnType);
}
ilGen.Emit(OpCodes.Ret);
return (DelegateType)dmd.CreateDelegate(delegateType);
}
public class PropertyRef<T, F> where T : class
{
private Func<T, F> RefGetValue;
private Action<T, F> RefSetValue;
private PropertyInfo PropertyInfo;
private MethodInfo GetMethodInfo;
private MethodInfo SetMethodInfo;
private Type TType;
private T Instance;
public Type InType;
public Type PropertyType;
public PropertyRef(PropertyInfo propertyinfo, object instance = null)
{
Init(propertyinfo, instance);
}
public PropertyRef(Type type, string propertyname, object instance = null)
{
Init(type.GetProperty(propertyname, AccessTools.all), instance);
}
private void Init(PropertyInfo propertyinfo, object instance)
{
PropertyInfo = propertyinfo;
TType = PropertyInfo.DeclaringType;
InType = TType;
PropertyType = PropertyInfo.PropertyType;
Instance = (T)instance;
if (PropertyInfo.CanRead)
{
GetMethodInfo = PropertyInfo.GetGetMethod(true);
RefGetValue = ObjectMethodDelegate<Func<T, F>>(GetMethodInfo);
}
if (PropertyInfo.CanWrite)
{
SetMethodInfo = PropertyInfo.GetSetMethod(true);
RefSetValue = ObjectMethodDelegate<Action<T, F>>(SetMethodInfo);
}
}
public static PropertyRef<T, F> Create(PropertyInfo propertyinfo, object instance = null)
{
return new PropertyRef<T, F>(propertyinfo, instance);
}
public static PropertyRef<T, F> Create(string propertyname, object instance = null)
{
return new PropertyRef<T, F>(typeof(T), propertyname, instance);
}
public static PropertyRef<T, F> Create(Type type, string propertyname, object instance = null)
{
return new PropertyRef<T, F>(type, propertyname, instance);
}
public F GetValue(T instance)
{
if (RefGetValue == null)
{
throw new ArgumentNullException(nameof(RefGetValue));
}
if (instance != null && TType.IsAssignableFrom(instance.GetType()))
{
return RefGetValue(instance);
}
else if (Instance != null && instance == null)
{
return RefGetValue(Instance);
}
else
{
return default(F);
}
}
public void SetValue(T instance, F value)
{
if (RefSetValue == null)
{
throw new ArgumentNullException(nameof(RefSetValue));
}
if (instance != null && TType.IsAssignableFrom(instance.GetType()))
{
RefSetValue(instance, value);
}
else if (Instance != null && instance == null)
{
RefSetValue(Instance, value);
}
}
}
public class FieldRef<T, F>
{
private AccessTools.FieldRef<T, F> HarmonyFieldRef;
private FieldInfo FieldInfo;
private Type TType;
private T Instance;
public Type InType;
public Type FieldType;
public FieldRef(FieldInfo fieldinfo, object instance = null)
{
Init(fieldinfo, instance);
}
public FieldRef(Type type, string fieldname, object instance = null)
{
Init(type.GetField(fieldname, AccessTools.all), instance);
}
public static FieldRef<T, F> Create(FieldInfo fieldinfo, object instance = null)
{
return new FieldRef<T, F>(fieldinfo, instance);
}
public static FieldRef<T, F> Create(string fieldname, object instance = null)
{
return new FieldRef<T, F>(typeof(T), fieldname, instance);
}
public static FieldRef<T, F> Create(Type type, string fieldname, object instance = null)
{
return new FieldRef<T, F>(type, fieldname, instance);
}
private void Init(FieldInfo fieldinfo, object instance = null)
{
FieldInfo = fieldinfo;
TType = FieldInfo.DeclaringType;
InType = TType;
FieldType = FieldInfo.FieldType;
Instance = (T)instance;
HarmonyFieldRef = AccessTools.FieldRefAccess<T, F>(FieldInfo);
}
public F GetValue(T instance)
{
if (HarmonyFieldRef == null)
{
throw new ArgumentNullException(nameof(HarmonyFieldRef));
}
if (instance != null && TType.IsAssignableFrom(instance.GetType()))
{
return HarmonyFieldRef(instance);
}
else if (Instance != null && instance == null)
{
return HarmonyFieldRef(Instance);
}
else
{
return default(F);
}
}
public void SetValue(T instance, F value)
{
if (HarmonyFieldRef == null)
{
throw new ArgumentNullException(nameof(HarmonyFieldRef));
}
if (instance != null && TType.IsAssignableFrom(instance.GetType()))
{
HarmonyFieldRef(instance) = value;
}
else if (Instance != null && instance == null)
{
HarmonyFieldRef(Instance) = value;
}
}
}
public static Type GetEftType(Func<Type, bool> func)
{
return PatchConstants.EftTypes.Single(func);
}
public static MethodInfo GetEftMethod(Type type, BindingFlags flags, Func<MethodInfo, bool> func)
{
return type.GetMethods(flags).Single(func);
}
public static MethodInfo GetEftMethod(Func<Type, bool> func, BindingFlags flags, Func<MethodInfo, bool> func2)
{
return GetEftMethod(GetEftType(func), flags, func2);
}
}
}