Skip to content

Commit

Permalink
Added support for MonkeyLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmxyz authored Nov 6, 2023
1 parent 36faba2 commit 17242ce
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 269 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
/packages
/Test/obj
/Test/bin
/*.nupkg
/MonkeyLoader Mods/*
/MonkeyLoader Gamepacks/*
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
9 changes: 9 additions & 0 deletions ISampleMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SampleMod
{
internal interface ISampleMod
{
bool Enabled { get; }

void DoSomething();
}
}
8 changes: 8 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="Installed MonkeyLoader Mods" value="MonkeyLoader Mods" />
<add key="Installed MonkeyLoader GamePacks" value="MonkeyLoader GamePacks" />
</packageSources>
</configuration>
34 changes: 34 additions & 0 deletions Patches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using FrooxEngine.UIX;
using HarmonyLib;

namespace SampleMod
{
internal class Patches
{
private static ISampleMod ModInstance;

internal static void Apply(ISampleMod instance)
{
ModInstance = instance;
Harmony harmony = new Harmony("com.github.mpmxyz.SampleMod"); //typically a reverse domain name is used here (https://en.wikipedia.org/wiki/Reverse_domain_name_notation)
harmony.PatchAll(); // do whatever LibHarmony patching you need, this will patch all [HarmonyPatch()] instances
}
//Example of how a HarmonyPatch can be formatted
[HarmonyPatch(typeof(Button), "OnPressBegin")]
class ClassName_MethodName_Patch
{
//Postfix() here will be automatically applied as a PostFix Patch
[HarmonyPostfix]
static void Postfix(Button __instance, Canvas.InteractionData eventData)
{
if (!ModInstance.Enabled)
{//Use Config.GetValue() to use the ModConfigurationKey defined earlier
return; //In this example if the mod is not enabled, we'll just return before doing anything
}
ModInstance.DoSomething();
FrooxEngineBootstrap.LogStream.Flush();
//Do stuff after everything in the original OnPressBegin has run.
}
}
}
}
37 changes: 0 additions & 37 deletions Properties/AssemblyInfo.cs

This file was deleted.

163 changes: 76 additions & 87 deletions SampleMod.csproj
Original file line number Diff line number Diff line change
@@ -1,62 +1,56 @@
<?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')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">RML</Platform>
<ProjectGuid>{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleMod</RootNamespace>
<AssemblyName>SampleMod</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<AssemblyName>mpmxyz.SampleMod</AssemblyName>
<Authors>mpmxyz</Authors>
<TargetFramework>net472</TargetFramework>
<AssemblyTitle>SampleMod</AssemblyTitle>
<Product>SampleMod</Product>
<Description>A sample Resonite Mod</Description>
<Copyright>CC0</Copyright>
<Version>1.0.0</Version>
<PackageProjectUrl>https://github.com/mpmxyz/ResoniteSampleMod</PackageProjectUrl>
<PackageReleaseNotes>Summary of changes made in this release of the package.</PackageReleaseNotes>
<PackageTags>Resonite</PackageTags>
<Configurations>Debug RML;Release RML;Debug MonkeyLoader;Release MonkeyLoader</Configurations>
<BaseOutputPath>bin\</BaseOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|RML' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\DebugRML\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|RML' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\ReleaseRML\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PropertyGroup Condition="'$(Configuration)' == 'Debug RML' Or '$(Configuration)' == 'Release RML'">
<PostBuildEvent>copy /Y "$(AssemblyName).dll" "%ResonitePath%\rml_mods\"</PostBuildEvent>
<StartAction>Program</StartAction>
<StartProgram>$(ResonitePath)\Resonite.exe</StartProgram>
<StartArguments>-Screen -CachePath "$(ResoniteCache)" -LoadAssembly Libraries/ResoniteModLoader.dll</StartArguments>
<StartWorkingDirectory>$(ResonitePath)</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|MonkeyLoader' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\DebugMonkey\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PropertyGroup Condition="'$(Configuration)' == 'Debug MonkeyLoader' Or '$(Configuration)' == 'Release MonkeyLoader'">
<PreBuildEvent>
nuget init "$(ResonitePath)\MonkeyLoader\GamePacks" "$(ProjectDir)\MonkeyLoader Gamepacks"
nuget init "$(ResonitePath)\MonkeyLoader\Mods" "$(ProjectDir)\MonkeyLoader Mods"
</PreBuildEvent>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<StartAction>Program</StartAction>
<StartProgram>$(ResonitePath)\Resonite.exe</StartProgram>
<StartArguments>-Screen -CachePath "$(ResoniteCache)"</StartArguments>
<StartWorkingDirectory>$(ResonitePath)</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|MonkeyLoader' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\ReleaseMonkey\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Target Name="MovePack" AfterTargets="Pack">
<Exec Command="copy /Y &quot;$(OutputPath)\..\$(AssemblyName).$(Version).nupkg&quot; &quot;$(ResonitePath)\MonkeyLoader\Mods\$(AssemblyName).nupkg&quot;"/>
</Target>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);obj/**</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<Compile Remove="MonkeyLoader Gamepacks\**" />
<Compile Remove="Test\**" />
<EmbeddedResource Remove="MonkeyLoader Gamepacks\**" />
<EmbeddedResource Remove="Test\**" />
<None Remove="MonkeyLoader Gamepacks\**" />
<None Remove="Test\**" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Harmony" Condition="'$(Platform)' == 'RML'">
<HintPath>$(ResonitePath)\rml_libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Harmony" Condition="'$(Platform)' == 'MonkeyLoader'">
<HintPath>$(ResonitePath)\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Elements.Assets">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\Elements.Assets.dll</HintPath>
</Reference>
Expand All @@ -75,9 +69,6 @@
<Reference Include="FrooxEngine.Weaver">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\FrooxEngine.Weaver.dll</HintPath>
</Reference>
<Reference Include="MonkeyLoader" Condition="'$(Platform)' == 'MonkeyLoader'">
<HintPath>$(ResonitePath)\MonkeyLoader.dll</HintPath>
</Reference>
<Reference Include="ProtoFlux.Core">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\ProtoFlux.Core.dll</HintPath>
</Reference>
Expand All @@ -90,48 +81,46 @@
<Reference Include="ProtoFluxBindings">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\ProtoFluxBindings.dll</HintPath>
</Reference>
<Reference Include="ResoniteModLoader" Condition="'$(Platform)' == 'RML'">
<Reference Include="ResoniteModLoader">
<HintPath>$(ResonitePath)\Libraries\ResoniteModLoader.dll</HintPath>
</Reference>
<Reference Include="QuantityX">
<HintPath>$(ResonitePath)\Resonite_Data\Managed\QuantityX.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.Xml" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug RML' Or '$(Configuration)' == 'Release RML'">
<Reference Include="Harmony">
<HintPath>$(ResonitePath)\rml_libs\0Harmony.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug MonkeyLoader' Or '$(Configuration)' == 'Release MonkeyLoader'">
<Compile Update="SampleModMonkey.cs" />
<Reference Include="Harmony">
<HintPath>$(ResonitePath)\0Harmony.dll</HintPath>
</Reference>
<Reference Include="MonkeyLoader">
<HintPath>$(ResonitePath)\MonkeyLoader.dll</HintPath>
</Reference>
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleMod.cs" />
<Compile Include="TestableCode.cs" />
<InternalsVisibleTo Include="Test" />
</ItemGroup>
<ItemGroup>
<Compile Remove="SampleModRML.cs" Condition="'$(Configuration)' != 'Debug RML' And '$(Configuration)' != 'Release RML'" />
<Compile Remove="SampleModMonkey.cs" Condition="'$(Configuration)' != 'Debug MonkeyLoader' And '$(Configuration)' != 'Release MonkeyLoader'" />
<Compile Remove="obj\Debug RML\net472\SampleMod.AssemblyInfo.cs" />
<Compile Remove="obj\Debug RML\net472\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" />
<Compile Remove="obj\Debug MonkeyLoader\net472\SampleMod.AssemblyInfo.cs" />
<Compile Remove="obj\Debug MonkeyLoader\net472\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" />
<Compile Remove="obj\Release RML\net472\SampleMod.AssemblyInfo.cs" />
<Compile Remove="obj\Release RML\net472\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" />
<Compile Remove="obj\Release MonkeyLoader\net472\SampleMod.AssemblyInfo.cs" />
<Compile Remove="obj\Release MonkeyLoader\net472\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" />
</ItemGroup>
<ItemGroup>
<Folder Remove="Test" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|RML'">
<PostBuildEvent>copy /Y $(TargetPath) "$(ResonitePath)\rml_mods\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|RML'">
<PostBuildEvent>copy /Y $(TargetPath) "$(ResonitePath)\rml_mods\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|MonkeyLoader'">
<PostBuildEvent>copy /Y $(TargetPath) "$(ResonitePath)\MonkeyLoader\Mods"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|MonkeyLoader'">
<PostBuildEvent>copy /Y $(TargetPath) "$(ResonitePath)\MonkeyLoader\Mods"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|RML'">
<StartAction>Program</StartAction>
<StartProgram>$(ResonitePath)\Resonite.exe</StartProgram>
<StartArguments>-Screen -CachePath "$(ResoniteCache)" -LoadAssembly Libraries/ResoniteModLoader.dll</StartArguments>
<StartWorkingDirectory>$(ResonitePath)</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|RML'">
<StartAction>Program</StartAction>
<StartProgram>$(ResonitePath)\Resonite.exe</StartProgram>
<StartArguments>-Screen -CachePath "$(ResoniteCache)" -LoadAssembly Libraries/ResoniteModLoader.dll</StartArguments>
<StartWorkingDirectory>$(ResonitePath)</StartWorkingDirectory>
</PropertyGroup>
</Project>
44 changes: 22 additions & 22 deletions SampleMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleMod", "SampleMod.csproj", "{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleMod", "SampleMod.csproj", "{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|MonkeyLoader = Debug|MonkeyLoader
Debug|RML = Debug|RML
Release|MonkeyLoader = Release|MonkeyLoader
Release|RML = Release|RML
Debug MonkeyLoader|AnyCPU = Debug MonkeyLoader|AnyCPU
Debug RML|AnyCPU = Debug RML|AnyCPU
Release MonkeyLoader|AnyCPU = Release MonkeyLoader|AnyCPU
Release RML|AnyCPU = Release RML|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug|MonkeyLoader.ActiveCfg = Debug|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug|MonkeyLoader.Build.0 = Debug|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug|RML.ActiveCfg = Debug|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug|RML.Build.0 = Debug|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release|MonkeyLoader.ActiveCfg = Release|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release|MonkeyLoader.Build.0 = Release|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release|RML.ActiveCfg = Release|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release|RML.Build.0 = Release|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug|MonkeyLoader.ActiveCfg = Debug|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug|MonkeyLoader.Build.0 = Debug|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug|RML.ActiveCfg = Debug|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug|RML.Build.0 = Debug|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release|MonkeyLoader.ActiveCfg = Release|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release|MonkeyLoader.Build.0 = Release|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release|RML.ActiveCfg = Release|Any CPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release|RML.Build.0 = Release|Any CPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug MonkeyLoader|AnyCPU.ActiveCfg = Debug MonkeyLoader|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug MonkeyLoader|AnyCPU.Build.0 = Debug MonkeyLoader|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug RML|AnyCPU.ActiveCfg = Debug RML|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Debug RML|AnyCPU.Build.0 = Debug RML|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release MonkeyLoader|AnyCPU.ActiveCfg = Release MonkeyLoader|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release MonkeyLoader|AnyCPU.Build.0 = Release MonkeyLoader|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release RML|AnyCPU.ActiveCfg = Release RML|AnyCPU
{3FA1B07B-D0C9-4EA5-B228-93DD6891EFD2}.Release RML|AnyCPU.Build.0 = Release RML|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug MonkeyLoader|AnyCPU.ActiveCfg = Debug MonkeyLoader|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug MonkeyLoader|AnyCPU.Build.0 = Debug MonkeyLoader|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug RML|AnyCPU.ActiveCfg = Debug RML|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Debug RML|AnyCPU.Build.0 = Debug RML|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release MonkeyLoader|AnyCPU.ActiveCfg = Release MonkeyLoader|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release MonkeyLoader|AnyCPU.Build.0 = Release MonkeyLoader|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release RML|AnyCPU.ActiveCfg = Release RML|AnyCPU
{DAB2D7A9-757B-4876-B95B-64A2E4F965B6}.Release RML|AnyCPU.Build.0 = Release RML|AnyCPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 17242ce

Please sign in to comment.