Skip to content

Commit

Permalink
Conform to BepInEx.x.Loader format
Browse files Browse the repository at this point in the history
  • Loading branch information
notfood committed Jun 9, 2020
1 parent 2c60632 commit e9ab5f4
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 134 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,4 @@ ASALocalRun/

package/
source/references/
lib/*.dll
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# BepInEx-Partiality-Wrapper
# BepInEx.Partiality.Loader

[![Version](https://img.shields.io/badge/BepInEx-5.0-green.svg)](https://github.com/BepInEx/BepInEx)
[![Version](https://img.shields.io/badge/Partiality-0.1-green.svg)](https://github.com/PartialityModding/Partiality)

Generic **BepInEx** Wrapper for any **Unity games** that rely on **Partiality**.
Generic **BepInEx** Loader for any **Unity games** that rely on **Partiality**.

## Installation

Unpack on your game instalation folder, requires **BepInEx +5.0**.

## Adding Partiality Mods

Drag and drop any **Partiality** mods dlls onto **BepInEx/plugins** folder.
Drag and drop any **Partiality** mods dlls onto **BepInEx/partiality** folder.

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Expand Down
6 changes: 6 additions & 0 deletions lib/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Place BepInEx.Partiality.Loader dependencies here

* 0Harmony.dll
* BepInEx.dll
* Partiality.dll
* UnityEngine.dll
75 changes: 0 additions & 75 deletions source/BepInEx-Partiality-Wrapper.csproj

This file was deleted.

48 changes: 48 additions & 0 deletions source/BepInEx.Partiality.Loader.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.1.0.0</Version>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<DebugType>None</DebugType>
<OutputPath>..\package\BepInEx\plugins\BepInEx.Partiality.Loader</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

<ItemGroup>
<Reference Include="BepInEx">
<HintPath>..\lib\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>..\lib\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\lib\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Partiality">
<HintPath>..\lib\Partiality.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.10.4">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="MonoMod" Version="19.11.5.1" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="19.11.5.1">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="19.11.5.1" />
<PackageReference Include="MonoMod.Utils" Version="19.11.5.1">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx-Partiality-Wrapper", "BepInEx-Partiality-Wrapper.csproj", "{15FFC242-62DB-4C19-91C0-182FCBC5E652}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx.Partiality.Loader", "BepInEx.Partiality.Loader.csproj", "{15FFC242-62DB-4C19-91C0-182FCBC5E652}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
34 changes: 23 additions & 11 deletions source/Wrapper.cs → source/PartialityLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Reflection;
using System.Text;

using BepInEx;
using BepInEx.Logging;

using HarmonyLib;
Expand All @@ -18,16 +17,16 @@
using Partiality;
using Partiality.Modloader;

namespace BepInExPartialityWrapper
namespace BepInEx.Partiality.Loader
{
[BepInPlugin(ID, NAME, VERSION)]
public class Wrapper : BaseUnityPlugin
public class PartialityLoader : BaseUnityPlugin
{
const string ID = "github.notfood.BepInExPartialityWrapper";
const string NAME = "Partiality Wrapper";
const string VERSION = "2.0";
const string ID = "github.notfood.BepInExPartialityLoader";
const string NAME = "Partiality Loader";
const string VERSION = "2.1";

public Wrapper()
void Awake()
{
GenerateHooks();
BootstrapPartiality();
Expand All @@ -41,7 +40,13 @@ void GenerateHooks()
string pathOut = Path.Combine(Path.GetDirectoryName(Info.Location), "HOOKS-Assembly-CSharp.dll");

if (File.Exists(pathOut)) {
return;

// Only Regenerate if Managed is newer than HOOKS
if (File.GetLastWriteTime(pathOut) > File.GetLastWriteTime(pathIn)) {
return;
}

File.Delete(pathOut);
}

using (MonoModder mm = new MonoModder {
Expand Down Expand Up @@ -69,7 +74,7 @@ void BootstrapPartiality()
var harmony = new Harmony(ID);

harmony.Patch(AccessTools.Method(typeof(ModManager), nameof(ModManager.LoadAllMods)),
prefix: new HarmonyMethod(typeof(Wrapper), nameof(PrefixReturnFalse)));
prefix: new HarmonyMethod(typeof(PartialityLoader), nameof(PrefixReturnFalse)));

PartialityManager.CreateInstance();
}
Expand All @@ -79,7 +84,14 @@ void BootstrapPartiality()
/// <summary>Loads the Partiality Mods after sorting</summary>
void LoadPartialityMods()
{
var modTypes = LoadTypes<PartialityMod>(Paths.PluginPath);
string partialityPath = Path.Combine(Paths.BepInExRootPath, "partiality");

if (!Directory.Exists(partialityPath)) {
Directory.CreateDirectory(partialityPath);
return;
}

var modTypes = LoadTypes<PartialityMod>(partialityPath);

var loadedMods = PartialityManager.Instance.modManager.loadedMods;

Expand Down Expand Up @@ -175,4 +187,4 @@ static string TypeLoadExceptionToString(ReflectionTypeLoadException ex)
return sb.ToString();
}
}
}
}
36 changes: 0 additions & 36 deletions source/Properties/AssemblyInfo.cs

This file was deleted.

8 changes: 0 additions & 8 deletions source/packages.config

This file was deleted.

0 comments on commit e9ab5f4

Please sign in to comment.