-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6890630
commit 0d1601c
Showing
5 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?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>{9F4A6B41-3465-4086-A1E2-023699B3F2EE}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ModLoader.PlayHome</RootNamespace> | ||
<AssemblyName>ModLoader.PlayHome</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<Import Project="..\BuildSettings.PlayHome.props"/> | ||
<ItemGroup> | ||
<Reference Include="0Harmony, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\IllusionLibs.BepInEx.Harmony.2.0.0-beta2\lib\net35\0Harmony.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\IllusionLibs.PlayHome.Assembly-CSharp.2018.3.11\lib\net35\Assembly-CSharp.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="BepInEx, Version=5.0.1.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\IllusionLibs.BepInEx.5.0.1.1\lib\net35\BepInEx.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="BepInEx.Harmony, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\IllusionLibs.BepInEx.Harmony.2.0.0-beta2\lib\net35\BepInEx.Harmony.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\IllusionLibs.PlayHome.UnityEngine.5.5.5\lib\net35\UnityEngine.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ModLoader.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="..\Common.Core\Common.Core.projitems" Label="Shared" /> | ||
<Import Project="..\Common.PlayHome\Common.PlayHome.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
using BepInEx; | ||
using BepInEx.Logging; | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace ModLoader.PlayHome | ||
{ | ||
[BepInPlugin(GUID, PluginName, Version)] | ||
public class ModLoader : BaseUnityPlugin | ||
{ | ||
public const string GUID = "keelhauled.modloader"; | ||
public const string PluginName = "ModLoader"; | ||
public const string Version = "1.0.0." + BuildNumber.Version; | ||
|
||
private static new ManualLogSource Logger; | ||
private Harmony Harmony; | ||
|
||
private Type[] types = new[] | ||
{ | ||
typeof(PrefabData), | ||
typeof(HairData), | ||
typeof(BackHairData), | ||
typeof(CombineTextureData), | ||
typeof(UnderhairData), | ||
typeof(WearData), | ||
typeof(AccessoryData), | ||
}; | ||
|
||
private void Awake() | ||
{ | ||
Logger = base.Logger; | ||
Harmony = new Harmony($"{GUID}.harmony"); | ||
|
||
Harmony.Patch(typeof(AssetBundleController).GetMethod("LoadAsset", AccessTools.all).MakeGenericMethod(typeof(Texture2D)), | ||
prefix: new HarmonyMethod(GetType().GetMethod(nameof(LoadAssetPatch), AccessTools.all))); | ||
|
||
Harmony.Patch(typeof(ItemDataBase).GetConstructors(AccessTools.all).First(), | ||
prefix: new HarmonyMethod(GetType().GetMethod(nameof(IDPatch), AccessTools.all))); | ||
|
||
foreach(var type in types) | ||
{ | ||
var targetType = type.Assembly.GetType("CustomDataSetupLoader`1").MakeGenericType(type); | ||
var dicType = typeof(Dictionary<,>).MakeGenericType(typeof(int), type); | ||
|
||
Harmony.Patch(targetType.GetMethod("Setup", AccessTools.all), | ||
prefix: new HarmonyMethod(GetType().GetMethod(nameof(SetupPatch), AccessTools.all))); | ||
|
||
Harmony.Patch(targetType.GetMethod("Setup_Search", AccessTools.all), | ||
prefix: new HarmonyMethod(GetType().GetMethod(nameof(SetupSearchPrefix), AccessTools.all)), | ||
postfix: new HarmonyMethod(GetType().GetMethod(nameof(SetupSearchPatch), AccessTools.all))); | ||
} | ||
} | ||
|
||
private static bool LoadAssetPatch(AssetBundleController __instance, ref string assetName, ref object __result) | ||
{ | ||
if(__instance.assetBundleName.Contains("thumnbnail/thumbnail_") || __instance.assetBundleName.Contains("thumnbnail/thumnbs_")) | ||
{ | ||
string text = __instance.directory + "/thumnbnail_R/" + assetName + ".png"; | ||
if(File.Exists(text)) | ||
{ | ||
Logger.LogInfo("Load thumb:" + text); | ||
__result = LoadPNG(text); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static Texture2D LoadPNG(string file) | ||
{ | ||
byte[] array; | ||
|
||
using(var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read)) | ||
using(var binaryReader = new BinaryReader(fileStream)) | ||
{ | ||
try | ||
{ | ||
array = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); | ||
} | ||
catch(Exception ex) | ||
{ | ||
Logger.LogWarning(ex); | ||
array = null; | ||
} | ||
|
||
binaryReader.Close(); | ||
} | ||
|
||
if(array == null) | ||
return null; | ||
|
||
var texture2D = new Texture2D(1, 1, TextureFormat.ARGB32, false); | ||
texture2D.LoadImage(array); | ||
return texture2D; | ||
} | ||
|
||
private static bool IDPatch(ItemDataBase __instance, ref int id, ref string name, ref string assetbundleName, ref int order, ref bool isNew) | ||
{ | ||
name = name.Replace("\\n", "\n"); | ||
__instance.id = ((id > 999999 && id < 1000000000) ? id : (id % 1000)); | ||
__instance.name_LineFeed = name; | ||
__instance.name = name.Replace("\n", string.Empty); | ||
__instance.assetbundleDir = GlobalData.assetBundlePath; | ||
__instance.assetbundleName = assetbundleName; | ||
__instance.order = order; | ||
__instance.isNew = isNew; | ||
|
||
return false; | ||
} | ||
|
||
private static bool SetupPatch(ref AssetBundleController abc, ref Action<object, AssetBundleController, CustomDataListLoader> ___action, ref object datas) | ||
{ | ||
string text = abc.directory + "/list/" + abc.assetBundleName + "_list.txt"; | ||
if(File.Exists(text)) | ||
{ | ||
Logger.LogInfo("Load list:" + text); | ||
CustomDataListLoader customDataListLoader = new CustomDataListLoader(); | ||
customDataListLoader.Load(text); | ||
___action(datas, abc, customDataListLoader); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static string searchValue; | ||
|
||
private static void SetupSearchPrefix(ref string search) | ||
{ | ||
searchValue = search; | ||
} | ||
|
||
private static void SetupSearchPatch(ref object datas, ref string search, ref Action<object, AssetBundleController, CustomDataListLoader> ___action) | ||
{ | ||
int num = searchValue.LastIndexOf("/"); | ||
var text = searchValue.Substring(0, num); | ||
|
||
if(!Directory.Exists(GlobalData.assetBundlePath + "/list/" + text)) | ||
return; | ||
|
||
foreach(var text3 in Directory.GetFiles(GlobalData.assetBundlePath + "/list/" + text, search + "_Mlist.txt")) | ||
{ | ||
Logger.LogInfo("Load Mlist:" + text3); | ||
StreamReader streamReader = new StreamReader(new FileStream(text3, FileMode.Open)); | ||
string assetBundleName = streamReader.ReadLine(); | ||
string contents = streamReader.ReadToEnd(); | ||
string tempFileName = Path.GetTempFileName(); | ||
File.WriteAllText(tempFileName, contents); | ||
CustomDataListLoader customDataListLoader = new CustomDataListLoader(); | ||
customDataListLoader.Load(tempFileName); | ||
File.Delete(tempFileName); | ||
AssetBundleController assetBundleController2 = new AssetBundleController(); | ||
assetBundleController2.OpenFromFile(GlobalData.assetBundlePath, assetBundleName); | ||
___action(datas, assetBundleController2, customDataListLoader); | ||
assetBundleController2.Close(false); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("ModLoader.PlayHome")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ModLoader.PlayHome")] | ||
[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("9f4a6b41-3465-4086-a1e2-023699b3f2ee")] | ||
|
||
// 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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="IllusionLibs.BepInEx" version="5.0.1.1" targetFramework="net35" developmentDependency="true" /> | ||
<package id="IllusionLibs.BepInEx.Harmony" version="2.0.0-beta2" targetFramework="net35" developmentDependency="true" /> | ||
<package id="IllusionLibs.PlayHome.Assembly-CSharp" version="2018.3.11" targetFramework="net35" developmentDependency="true" /> | ||
<package id="IllusionLibs.PlayHome.UnityEngine" version="5.5.5" targetFramework="net35" developmentDependency="true" /> | ||
</packages> |