public static void Postfix(ImageIdentifierTextureProvider __instance, CharacterCode ____characterCode) { if (__instance.ImageTypeCode == 5 && ____characterCode != null && TaleWorlds.Core.FaceGen.GetMaturityTypeWithAge(____characterCode.BodyProperties.Age) <= BodyMeshMaturityType.Child && ____characterCode.BodyProperties.Age >= 3) { TableauCacheManager.Current.ReleaseTextureWithId(____characterCode, __instance.IsBig); } }
// The original method is async, but the problem spot is not, so... public static void Postfix(ImageIdentifierTextureProvider __instance, string id, int typeAsInt, string additionalArgs, ref CharacterCode ____characterCode, ref bool ____creatingTexture) { if (!string.IsNullOrEmpty(id) && typeAsInt == 5) { CharacterCode from = CharacterCode.CreateFrom(id); ____characterCode = from; if (TaleWorlds.Core.FaceGen.GetMaturityTypeWithAge(from.BodyProperties.Age) <= BodyMeshMaturityType.Child && from.BodyProperties.Age >= 3) { ____creatingTexture = true; TableauCacheManager.Current.BeginCreateCharacterTexture(from, new Action <Texture>(__instance.OnTextureCreated), __instance.IsBig); } } }
private static void OnTextureCreated(this ImageIdentifierTextureProvider instance, Texture texture) { AccessTools.Method(typeof(ImageIdentifierTextureProvider), "OnTextureCreated").Invoke(instance, new object[] { texture }); }