Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
2.2
Browse files Browse the repository at this point in the history
Small cleanup
  • Loading branch information
sinai-dev committed Feb 11, 2021
1 parent 4cd4d67 commit 5e1cc65
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 46 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ A <b>BepInEx-Partiality Mod Wrapper</b> for Unity Games. This allows Partiality

This version is essentially Partiality packaged <b>as</b> a BepInEx mod. It serves as a dummy reference to Partliality.dll for Partiality Mods, but otherwise behaves as a BepInEx mod.

The HOOKS file included with the release is the current latest one for Outward. If you're using this for a different game you will need to delete that and run the mod once to generate the hooks for your game.

## Install

Installation instructions and the download link can be found here:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\package\BepInEx\plugins\PartialityWrapper\</OutputPath>
<OutputPath>..\Release\BepInEx\plugins\PartialityWrapper\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="BepInEx">
<HintPath>..\references\BepInEx.dll</HintPath>
<HintPath>..\lib\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e">
Expand Down Expand Up @@ -71,13 +71,13 @@
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\references\UnityEngine.dll</HintPath>
<HintPath>..\lib\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PartialityMod.cs" />
<Compile Include="Wrapper.cs" />
<Compile Include="PartialityWrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
File renamed without changes.
File renamed without changes.
39 changes: 6 additions & 33 deletions source/Wrapper.cs → src/PartialityWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
namespace Partiality
{
[BepInPlugin(ID, NAME, VERSION)]
public class Wrapper : BaseUnityPlugin
public class PartialityWrapper : BaseUnityPlugin
{
private const string ID = "com.sinai.PartialityWrapper";
private const string NAME = "Partiality Wrapper";
private const string VERSION = "2.1";
private const string VERSION = "2.2";

public string PluginFolder => Path.GetDirectoryName(Info.Location);
public string ModsFolder => Path.Combine(Paths.GameRootPath, "Mods");
Expand All @@ -37,19 +37,19 @@ internal void Awake()

private void LoadDependencies()
{
IEnumerable<string> dependencies = (
var dependencies = (
from filepath in Directory.GetFiles(PluginFolder)
where (filepath.EndsWith(".dll") || filepath.EndsWith(".exe")) && !filepath.Contains("Partiality.dll")
select filepath
).AsEnumerable();

foreach (string filepath in dependencies)
{
Logger.Log(LogLevel.Message, "Loading dependency " + Path.GetFileName(filepath));
//Logger.Log(LogLevel.Message, "Loading dependency " + Path.GetFileName(filepath));
Assembly.Load(File.ReadAllBytes(filepath));
}

Logger.Log(LogLevel.Message, "Done loading dependencies");
//Logger.Log(LogLevel.Message, "Done loading dependencies");
}

private void CheckHooks()
Expand Down Expand Up @@ -120,7 +120,7 @@ private void LoadMods()
catch (ReflectionTypeLoadException ex)
{
Logger.Log(LogLevel.Error, $"Could not load \"{Path.GetFileName(filepath)}\" as a plugin!");
Logger.Log(LogLevel.Debug, TypeLoadExceptionToString(ex));
Logger.Log(LogLevel.Debug, ex);
}
catch (BadImageFormatException) { } // unmanaged DLL
catch (Exception ex)
Expand Down Expand Up @@ -178,32 +178,5 @@ public static IEnumerable<Type> GetTypesSafe(Assembly asm)
catch (ReflectionTypeLoadException e) { return e.Types.Where(x => x != null); }
catch { return Enumerable.Empty<Type>(); }
}

private static string TypeLoadExceptionToString(ReflectionTypeLoadException ex)
{
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions)
{
sb.AppendLine(exSub.Message);
if (exSub is FileNotFoundException exFileNotFound)
{
if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
{
sb.AppendLine("Fusion Log:");
sb.AppendLine(exFileNotFound.FusionLog);
}
}
else if (exSub is FileLoadException exLoad)
{
if (!string.IsNullOrEmpty(exLoad.FusionLog))
{
sb.AppendLine("Fusion Log:");
sb.AppendLine(exLoad.FusionLog);
}
}
sb.AppendLine();
}
return sb.ToString();
}
}
}
File renamed without changes.
14 changes: 7 additions & 7 deletions source/packages.config → src/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
<package id="MonoMod" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.RuntimeDetour" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.RuntimeDetour.HookGen" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.Utils" version="20.4.3.1" targetFramework="net35" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
<package id="MonoMod" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.RuntimeDetour" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.RuntimeDetour.HookGen" version="20.4.3.1" targetFramework="net35" />
<package id="MonoMod.Utils" version="20.4.3.1" targetFramework="net35" />
</packages>

0 comments on commit 5e1cc65

Please sign in to comment.