@@ -52,8 +52,8 @@ private static void StartScreen_Start()
5252 }
5353
5454 [ HarmonyPrefix ]
55- [ HarmonyPatch ( typeof ( SpriteAtlasManager ) , nameof ( SpriteAtlasManager . LoadSprite ) , typeof ( string ) , typeof ( string ) , typeof ( SpriteCallback ) ) ] // temporary fix
56- private static bool SpriteAtlasManager_LoadSprite_Postfix ( SpriteAtlasManager __instance , string atlas , string sprite , SpriteCallback completion )
55+ [ HarmonyPatch ( typeof ( SpriteAtlasManager ) , nameof ( SpriteAtlasManager . LoadSprite ) , typeof ( string ) , typeof ( string ) , typeof ( SpriteCallback ) ) ]
56+ private static bool SpriteAtlasManager_LoadSprite ( SpriteAtlasManager __instance , string atlas , string sprite , SpriteCallback completion )
5757 {
5858 bool found = false ;
5959 __instance . LoadSpriteAtlas ( atlas , ( Il2CppSystem . Action < UnityEngine . U2D . SpriteAtlas > ) GetAtlas ) ;
@@ -64,47 +64,36 @@ void GetAtlas(SpriteAtlas spriteAtlas)
6464 {
6565 if ( spriteAtlas != null )
6666 {
67- Sprite foundSprite = __instance . GetSpriteFromAtlas ( spriteAtlas , sprite ) ;
68- if ( foundSprite != null )
67+ List < string > names = sprite . Split ( '_' ) . ToList ( ) ;
68+ List < string > filteredNames = new List < string > ( names ) ;
69+ string style = "" ;
70+ foreach ( string item in names )
6971 {
70- completion ? . Invoke ( atlas , sprite , __instance . GetSpriteFromAtlas ( spriteAtlas , sprite ) ) ;
72+ string upperitem = char . ToUpper ( item [ 0 ] ) + item . Substring ( 1 ) ;
73+ if ( EnumCache < TribeData . Type > . TryGetType ( item , out TribeData . Type tribe ) || EnumCache < SkinType > . TryGetType ( item , out SkinType skin )
74+ || EnumCache < TribeData . Type > . TryGetType ( upperitem , out TribeData . Type tribeUpper ) || EnumCache < SkinType > . TryGetType ( upperitem , out SkinType skinUpper ) )
75+ {
76+ filteredNames . Remove ( item ) ;
77+ style = item ;
78+ continue ;
79+ }
80+ }
81+ string name = string . Join ( "_" , filteredNames ) ;
82+ Sprite ? newSprite = Registry . GetSprite ( name , style ) ;
83+ if ( newSprite != null )
84+ {
85+ completion ? . Invoke ( atlas , sprite , newSprite ) ;
7186 found = true ;
7287 }
7388 }
7489 }
7590 }
7691
77- [ HarmonyPostfix ]
78- [ HarmonyPatch ( typeof ( SpriteAtlasManager ) , nameof ( SpriteAtlasManager . GetSpriteFromAtlas ) , typeof ( SpriteAtlas ) , typeof ( string ) ) ]
79- private static void SpriteAtlasManager_GetSpriteFromAtlas ( ref Sprite __result , SpriteAtlas spriteAtlas , string sprite )
80- {
81- List < string > names = sprite . Split ( '_' ) . ToList ( ) ;
82- List < string > filteredNames = new List < string > ( names ) ;
83- string style = "" ;
84- foreach ( string item in names )
85- {
86- string upperitem = char . ToUpper ( item [ 0 ] ) + item . Substring ( 1 ) ;
87- if ( EnumCache < TribeData . Type > . TryGetType ( item , out TribeData . Type tribe ) || EnumCache < SkinType > . TryGetType ( item , out SkinType skin )
88- || EnumCache < TribeData . Type > . TryGetType ( upperitem , out TribeData . Type tribeUpper ) || EnumCache < SkinType > . TryGetType ( upperitem , out SkinType skinUpper ) )
89- {
90- filteredNames . Remove ( item ) ;
91- style = item ;
92- continue ;
93- }
94- }
95- string name = string . Join ( "_" , filteredNames ) ;
96- Sprite ? newSprite = Registry . GetSprite ( name , style ) ;
97- if ( newSprite != null )
98- {
99- __result = newSprite ;
100- }
101- }
102-
10392 [ HarmonyPostfix ]
10493 [ HarmonyPatch ( typeof ( SpriteAtlasManager ) , nameof ( SpriteAtlasManager . DoSpriteLookup ) ) ]
10594 private static void SpriteAtlasManager_DoSpriteLookup ( ref SpriteAtlasManager . SpriteLookupResult __result , SpriteAtlasManager __instance , string baseName , TribeData . Type tribe , SkinType skin , bool checkForOutline , int level )
10695 {
107- baseName = Util . ReverseSpriteData ( baseName ) ;
96+ baseName = Util . FormatSpriteName ( baseName ) ;
10897
10998 Sprite ? sprite = Registry . GetSprite ( baseName , Util . GetStyle ( tribe , skin ) , level ) ;
11099 if ( sprite != null )
0 commit comments