File tree Expand file tree Collapse file tree 3 files changed +51
-23
lines changed
Expand file tree Collapse file tree 3 files changed +51
-23
lines changed Original file line number Diff line number Diff line change 1+ using COTL_API . CustomInventory ;
2+ using HarmonyLib ;
3+ using Sirenix . Utilities ;
4+
5+ namespace COTL_API . HarmonyUtils ;
6+
7+ public class Patcher
8+ {
9+ private List < PatchProcessor > xyz = new ( ) ;
10+
11+ public void PatchAll ( )
12+ {
13+ CreatePatchClass ( typeof ( InventoryItem ) , typeof ( CustomInventoryItem ) ) ;
14+ }
15+
16+ public void CreatePatchClass ( Type orig , Type dest )
17+ {
18+ var destMethods = dest . GetMethods ( ) ;
19+
20+ foreach ( var x in orig . GetMethods ( ) )
21+ {
22+ LogDebug ( "Trying to patch " + x . Name + "AAAAA" ) ;
23+
24+ var method = destMethods . FirstOrDefault ( info =>
25+ {
26+ if ( info . Name != x . Name ) return false ;
27+ if ( info . ReturnType != dest . GetReturnType ( ) ) return false ;
28+ return info . GetParameters ( ) . Length == x . GetParameters ( ) . Length &&
29+ x . GetParameters ( ) . All ( parameter => parameter . GetType ( ) == info . GetParameters ( ) [ parameter . Position ] . ParameterType ) ;
30+ } ) ;
31+
32+ if ( method is null )
33+ return ;
34+
35+ var processor = new PatchProcessor ( Plugin . Instance ! . _harmony , x ) ;
36+ processor . AddPrefix ( new HarmonyMethod
37+ {
38+ method = method ,
39+ methodName = method . Name ,
40+ argumentTypes = method . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ,
41+
42+ } ) ;
43+ processor . Patch ( ) ;
44+
45+ xyz . Add ( processor ) ;
46+ }
47+ }
48+ }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public class Plugin : BaseUnityPlugin
2727 internal static Dropdown ? GoatFleeceBleatSettings ;
2828
2929 internal static Dropdown ? CustomPlayerSpineSettings ;
30- private readonly Harmony _harmony = new ( MyPluginInfo . PLUGIN_GUID ) ;
30+ internal readonly Harmony _harmony = new ( MyPluginInfo . PLUGIN_GUID ) ;
3131
3232 internal readonly ModdedSaveData < ApiData > APIData = new ( MyPluginInfo . PLUGIN_GUID )
3333 {
Original file line number Diff line number Diff line change 1- # COTL_API
1+ # Experimental Harmony TESTING THINGY THING YAYY
22
3- [ ![ Wiki] ( https://img.shields.io/static/v1?label=wiki&message=read&style=flat&color=informational )] ( https://cotl-api.vercel.app/ )
4- [ ![ Github] ( https://img.shields.io/static/v1?label=&message=github&style=flat&color=black&logo=github )] ( https://github.com/xhayper/COTL_API )
5- [ ![ Thunderstore] ( https://img.shields.io/static/v1?label=&message=thunderstore&style=flat&color=informational )] ( https://cult-of-the-lamb.thunderstore.io/package/xhayper/COTL_API/ )
6- [ ![ nexusmods] ( https://img.shields.io/static/v1?label=&message=nexusmods&style=flat&color=yellow )] ( https://www.nexusmods.com/cultofthelamb/mods/30 )
7-
8- A library to easily interact with [ ` Cult of the Lamb ` ] ( https://store.steampowered.com/app/1313140/Cult_of_the_Lamb )
9-
10- ## NOTE
11-
12- This project is still in alpha, and stuff can change without any notice!
13-
14- ## Contribution
15-
16- ### How can you help?
17-
18- We need people to help develop the API! You can help by joining
19- the [ Cult of the Lamb Modding Discord Server] ( https://discord.gg/jZ2DytX3TX ) !
20-
21- ## Credits
22-
23- [ InscryptionAPI] ( https://github.com/InscryptionModding/InscryptionAPI ) - Most of the code
3+ do not use this will break 100%
You can’t perform that action at this time.
0 commit comments