File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System . Diagnostics . CodeAnalysis ;
2+ using DiskCardGame ;
3+ using HarmonyLib ;
4+ using Mono . Collections . Generic ;
5+ using Sirenix . Serialization . Utilities ;
6+ using UnityEngine ;
7+
8+ namespace InscryptionAPI . Card ;
9+
10+ [ HarmonyPatch ]
11+ public static class CardManager
12+ {
13+ public static readonly ReadOnlyCollection < CardInfo > BaseGameCards = new ( Resources . LoadAll < CardInfo > ( "Data/" ) ) ;
14+ private static readonly List < CardInfo > NewCards = new ( ) ;
15+
16+ private static long _counter = 0 ;
17+ private static long lastBuilt = - 1 ;
18+
19+ public static event Action < List < CardInfo > > ModifyCardList ;
20+
21+ private static List < CardInfo > _allCards ;
22+
23+ public static List < CardInfo > AllCards
24+ {
25+ get
26+ {
27+ if ( _counter != lastBuilt )
28+ {
29+ lastBuilt = _counter ;
30+ _allCards = BaseGameCards . Append ( NewCards ) . ToList ( ) ;
31+ ModifyCardList ? . Invoke ( _allCards ) ;
32+ }
33+ return _allCards ;
34+ }
35+ }
36+
37+ public static void Add ( CardInfo newCard )
38+ {
39+ NewCards . Add ( newCard ) ;
40+ ++ _counter ;
41+ }
42+ public static void Remove ( CardInfo card )
43+ {
44+ NewCards . Remove ( card ) ;
45+ ++ _counter ;
46+ }
47+
48+ [ HarmonyPostfix ]
49+ [ HarmonyPatch ( typeof ( ScriptableObjectLoader < UnityObject > ) , nameof ( ScriptableObjectLoader < UnityObject > . LoadData ) ) ]
50+ [ SuppressMessage ( "Member Access" , "Publicizer001" ) ]
51+ private static void CardLoadPrefix ( )
52+ {
53+ ScriptableObjectLoader < CardInfo > . allData = AllCards ;
54+ }
55+ }
Original file line number Diff line number Diff line change 1- using BepInEx ;
1+ global using UnityObject = UnityEngine . Object ;
2+
3+ using BepInEx ;
24using HarmonyLib ;
35
46namespace InscryptionAPI ;
@@ -10,8 +12,15 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
1012 public const string ModName = "InscryptionAPI" ;
1113 public const string ModVer = "2.0.0" ;
1214
13- public void Awake ( )
15+ private readonly Harmony HarmonyInstance = new ( ModGUID ) ;
16+
17+ public void OnEnable ( )
18+ {
19+ HarmonyInstance . PatchAll ( typeof ( InscryptionAPIPlugin ) . Assembly ) ;
20+ }
21+
22+ public void OnDisable ( )
1423 {
15- Harmony . CreateAndPatchAll ( typeof ( InscryptionAPIPlugin ) . Assembly , ModGUID ) ;
24+ HarmonyInstance . UnpatchSelf ( ) ;
1625 }
1726}
You can’t perform that action at this time.
0 commit comments