99using COTL_API . CustomTarotCard ;
1010using COTL_API . CustomTasks ;
1111using FoodPlus . CustomTraits ;
12+ using I2 . Loc ;
1213using Lamb . UI ;
14+ using Lamb . UI . Assets ;
15+ using Lamb . UI . BuildMenu ;
16+ using Lamb . UI . FollowerInteractionWheel ;
17+ using Lamb . UI . MainMenu ;
18+ using Lamb . UI . PauseMenu ;
19+ using Lamb . UI . Rituals ;
20+ using Lamb . UI . Settings ;
21+ using Lamb . UI . SettingsMenu ;
22+ using MMRoomGeneration ;
23+ using Spine ;
24+ using src . Alerts ;
25+ using src . UI . InfoCards ;
26+ using src . UI . Menus ;
27+ using TMPro ;
1328using UnityEngine ;
29+ using UnityEngine . AddressableAssets ;
30+ using AudioSettings = UnityEngine . AudioSettings ;
1431
1532namespace COTL_API . Debug ;
1633
1734internal class DebugManager
1835{
1936 internal static bool DebugContentAdded ;
2037
21- internal static InventoryItem . ITEM_TYPE DebugItem { get ; private set ; }
22- internal static InventoryItem . ITEM_TYPE DebugItem2 { get ; private set ; }
23- internal static InventoryItem . ITEM_TYPE DebugItem3 { get ; private set ; }
24- internal static InventoryItem . ITEM_TYPE DebugItem4 { get ; private set ; }
25-
26- internal static FollowerCommands DebugGiftFollowerCommand { get ; private set ; }
27-
28- internal static RelicType DebugRelic { get ; private set ; }
29-
3038 internal static Dictionary < Type , Type > CustomClassMappings = new ( )
3139 {
3240 { typeof ( InventoryItem ) , typeof ( CustomInventoryItem ) } ,
@@ -36,54 +44,149 @@ internal class DebugManager
3644 { typeof ( TarotCards ) , typeof ( CustomTarotCard . CustomTarotCard ) } ,
3745 { typeof ( FollowerTrait ) , typeof ( CustomTrait ) }
3846 } ;
39-
47+
48+ // TODO: Can't we just harmony.GetPatchedMethods().Select(mB => mB.DeclaringType);
49+ internal static List < Type > PatchedClass = new ( )
50+ {
51+ typeof ( CropController ) ,
52+ typeof ( StructuresData ) ,
53+ typeof ( StructureBrain ) ,
54+ typeof ( FarmPlot ) ,
55+ typeof ( Interaction_Berries ) ,
56+ typeof ( InventoryItem ) ,
57+ typeof ( ObjectPool ) ,
58+ typeof ( ItemInfoCard ) ,
59+ typeof ( Interaction_AddFuel ) ,
60+ typeof ( Inventory ) ,
61+ typeof ( FollowerCommandGroups ) ,
62+ typeof ( FollowerCommandItems ) ,
63+ typeof ( FontImageNames ) ,
64+ typeof ( InventoryIconMapping ) ,
65+ typeof ( CookingData ) ,
66+ typeof ( InventoryMenu ) ,
67+ typeof ( Structures_Refinery ) ,
68+ typeof ( UIMenuBase ) ,
69+ typeof ( RefineryInfoCard ) ,
70+ typeof ( Interaction_Chest ) ,
71+ typeof ( InventoryItemDisplay ) ,
72+ typeof ( Interaction_OfferingShrine ) ,
73+ typeof ( Structures_OfferingShrine ) ,
74+ typeof ( RecipeInfoCard ) ,
75+ typeof ( interaction_FollowerInteraction ) ,
76+ typeof ( Meal ) ,
77+ typeof ( FollowerTask_EatMeal ) ,
78+ typeof ( UISettingsMenuController ) ,
79+ typeof ( GraphicsSettings ) ,
80+ typeof ( UIPauseMenuController ) ,
81+ typeof ( MainMenuController ) ,
82+ typeof ( SkeletonData ) ,
83+ typeof ( CharacterSkinAlerts ) ,
84+ typeof ( Graphics ) ,
85+ typeof ( FollowerInformationBox ) ,
86+ typeof ( UIFollowerIndoctrinationMenuController ) ,
87+ typeof ( PlayerFarming ) ,
88+ typeof ( FollowerTrait ) ,
89+ typeof ( FollowerCategory ) ,
90+ typeof ( TypeAndPlacementObjects ) ,
91+ typeof ( Structure ) ,
92+ typeof ( AddressablesImpl ) ,
93+ typeof ( ResourceManager ) ,
94+ typeof ( ControlUtilities ) ,
95+ typeof ( LocationManager ) ,
96+ typeof ( GenerateRoom ) ,
97+ typeof ( UIFollowerInteractionWheelOverlayController ) ,
98+ typeof ( LoadMainMenu ) ,
99+ typeof ( MMHorizontalSelector ) ,
100+ typeof ( LoadMenu ) ,
101+ typeof ( TMP_SpriteAsset ) ,
102+ typeof ( AchievementsWrapper ) ,
103+ typeof ( TermData ) ,
104+ typeof ( LanguageSourceData ) ,
105+ typeof ( GameSettings ) ,
106+ typeof ( Quests ) ,
107+ typeof ( UIWeaponCard ) ,
108+ typeof ( TarotInfoCard ) ,
109+ typeof ( TarotCards ) ,
110+ typeof ( LocalizationManager ) ,
111+ typeof ( RelicData ) ,
112+ typeof ( PlayerRelic ) ,
113+ typeof ( EquipmentManager ) ,
114+ typeof ( CommandItem ) ,
115+ typeof ( AudioSettings ) ,
116+ typeof ( SaveAndLoad ) ,
117+ typeof ( MissionInfoCard ) ,
118+ typeof ( MissionaryManager ) ,
119+ typeof ( CustomType ) ,
120+ typeof ( UIRitualsMenuController ) ,
121+ typeof ( RitualItem ) ,
122+ typeof ( RitualIconMapping ) ,
123+ typeof ( UpgradeSystem ) ,
124+ typeof ( Interaction_TempleAltar ) ,
125+ typeof ( Interaction ) ,
126+ typeof ( UITarotChoiceOverlayController )
127+ } ;
128+
129+ internal static InventoryItem . ITEM_TYPE DebugItem { get ; private set ; }
130+ internal static InventoryItem . ITEM_TYPE DebugItem2 { get ; private set ; }
131+ internal static InventoryItem . ITEM_TYPE DebugItem3 { get ; private set ; }
132+ internal static InventoryItem . ITEM_TYPE DebugItem4 { get ; private set ; }
133+
134+ internal static FollowerCommands DebugGiftFollowerCommand { get ; private set ; }
135+
136+ internal static RelicType DebugRelic { get ; private set ; }
137+
40138 private static string BeautifyNamespace ( string ? str )
41139 {
42140 return str is null or "" ? "" : str + "." ;
43141 }
44-
142+
45143 internal void ShowPatches ( Type a )
46144 {
47145 var harmony = Plugin . Instance . _harmony ;
48146 var patchedMethods = harmony . GetPatchedMethods ( ) . Where ( methodBase => methodBase . DeclaringType == a ) ;
49147
50148 foreach ( var method in a . GetMethods ( ) )
51- {
52149 LogDebug ( patchedMethods . Contains ( method )
53150 ? $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } : Patched"
54151 : $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } : Unpatched") ;
55- }
56152 }
57153
58- private static void ShowDiff ( Type a , Type b )
154+ internal void ShowPatchedClasses ( )
59155 {
60- LogDebug ( $ "Showing diff between { BeautifyNamespace ( a . Namespace ) } { a . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } ") ;
61-
156+ foreach ( var cl in PatchedClass ) ShowPatches ( cl ) ;
157+ }
158+
159+ internal static void ShowDiff ( Type a , Type b )
160+ {
161+ LogDebug (
162+ $ "Showing diff between { BeautifyNamespace ( a . Namespace ) } { a . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } ") ;
163+
62164 LogDebug ( "Methods" ) ;
63165 foreach ( var method in a . GetMethods ( ) )
64166 {
65167 if ( method . Name . StartsWith ( "get_" ) || method . Name . StartsWith ( "set_" ) )
66168 continue ;
67-
169+
68170 var corrspondingMethod = b . GetMethods ( ) . FirstOrDefault ( m => m . Name == method . Name ) ;
69171
70172 if ( corrspondingMethod is null )
71173 {
72174 LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } : missing corrsponding method") ;
73- continue ;
175+ continue ;
74176 }
75177
76178 if ( ! method . ReturnType . IsAssignableFrom ( corrspondingMethod . ReturnType ) )
77179 {
78- LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched return type") ;
180+ LogDebug (
181+ $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched return type") ;
79182 continue ;
80183 }
81184
82185 var corrospondingParameters = method . GetParameters ( ) ;
83186
84187 var parameters = method . GetParameters ( ) ;
85-
86- if ( parameters . Length == 1 && parameters [ 0 ] . GetType ( ) . IsEnum )
188+
189+ if ( parameters . Length == 1 && parameters [ 0 ] . GetType ( ) . IsEnum )
87190 parameters = parameters . Skip ( 1 ) . ToArray ( ) ;
88191
89192 var parameterMatches = parameters . Length == corrospondingParameters . Length && parameters . All ( info =>
@@ -93,22 +196,21 @@ private static void ShowDiff(Type a, Type b)
93196
94197 if ( ! parameterMatches )
95198 {
96- LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched parameters") ;
199+ LogDebug (
200+ $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched parameters") ;
97201 LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } : { parameters } ") ;
98202 LogDebug ( $ "{ BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } : { corrospondingParameters } ") ;
99203 continue ;
100204 }
101-
102- LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } matches { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } ") ;
205+
206+ LogDebug (
207+ $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } matches { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } ") ;
103208 }
104209 }
105210
106211 internal static void CheckCustomClasses ( )
107212 {
108- foreach ( var type in CustomClassMappings )
109- {
110- ShowDiff ( type . Key , type . Value ) ;
111- }
213+ foreach ( var type in CustomClassMappings ) ShowDiff ( type . Key , type . Value ) ;
112214 }
113215
114216 internal static void AddDebugContent ( )
0 commit comments