Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proc Type API - Groove's Worst Mistake #513

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 13 additions & 0 deletions R2API.ProcType.Interop/ProcTypeInterop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using RoR2;
using System.Runtime.CompilerServices;

[assembly:InternalsVisibleTo("R2API.ProcType")]

namespace R2API;

internal static class ProcTypeInterop
{
public static byte[] GetModdedMask(ProcChainMask procChainMask) => procChainMask.r2api_moddedMask;

public static void SetModdedMask(ref ProcChainMask procChainMask, byte[] value) => procChainMask.r2api_moddedMask = value;
}
16 changes: 16 additions & 0 deletions R2API.ProcType.Interop/R2API.ProcType.Interop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>annotations</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);NU5104</NoWarn>
<RootNamespace>R2API</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Reference Include="RoR2">
<HintPath>libs\RoR2.Patched.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Binary file added R2API.ProcType.Interop/libs/RoR2.Patched.dll
Binary file not shown.
23 changes: 23 additions & 0 deletions R2API.ProcType.Patcher/ProcTypePatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BepInEx;
using BepInEx.Logging;
using Mono.Cecil;
using System.Collections.Generic;

namespace R2API;

internal static class ProcTypePatcher
{
public static IEnumerable<string> TargetDLLs
{
get
{
yield return "RoR2.dll";
}
}

public static void Patch(AssemblyDefinition assembly)
{
TypeDefinition procChainMask = assembly.MainModule.GetType("RoR2", "ProcChainMask");
procChainMask?.Fields.Add(new FieldDefinition("r2api_moddedMask", FieldAttributes.Public, assembly.MainModule.ImportReference(typeof(byte[]))));
}
}
14 changes: 14 additions & 0 deletions R2API.ProcType.Patcher/R2API.ProcType.Patcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>annotations</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);NU5104</NoWarn>
<RootNamespace>R2API</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.4.19" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions R2API.ProcType/ModdedProcType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using RoR2;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

namespace R2API;

/// <summary>
/// A modded equivalent of <see cref="ProcType"/> for use with <see cref="ProcTypeAPI"/>.
/// </summary>
public enum ModdedProcType : int
{
/// <summary>
/// Represents an invalid value of <see cref="ModdedProcType"/>.
/// </summary>
/// <remarks>All negative values of <see cref="ModdedProcType"/> are considered invalid.</remarks>
Invalid = -1
}
Loading
Loading