using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using EnhancedPrefabLoader.API.Assets; using EnhancedPrefabLoader.API.Behaviors; using EnhancedPrefabLoader.API.Components; using EnhancedPrefabLoader.API.Events; using EnhancedPrefabLoader.API.InternalBridges; using EnhancedPrefabLoader.API.Models; using EnhancedPrefabLoader.API.Registry; using EnhancedPrefabLoader.API.Services; using EnhancedPrefabLoader.Shared.Models; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: ComVisible(false)] [assembly: Guid("d64dc15b-8078-4750-8278-87e0065dc75e")] [assembly: InternalsVisibleTo("EnhancedPrefabLoader")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("EnhancedPrefabLoader.API")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("6.0.1.0")] [assembly: AssemblyInformationalVersion("6.0.1+cd7431ddc1ec5aac5b27bb4a89a6104e570aad10")] [assembly: AssemblyProduct("EnhancedPrefabLoader.API")] [assembly: AssemblyTitle("EnhancedPrefabLoader.API")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("6.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EnhancedPrefabLoader.Shared.Models { public enum DecoFlags { None, FloorTexture, WallTexture, CeilingTexture } } namespace EnhancedPrefabLoader.API { public static class Epl { private static IEplApi? instance; public static IEplApi Api => instance ?? throw new InvalidOperationException("EPL is not loaded"); public static bool IsAvailable => instance != null; internal static void RegisterApi(IEplApi api) { instance = api; } } public interface IEplApi { bool IsBundleLoadingComplete { get; } IEplAssets Assets { get; } IEplServices Services { get; } IEplEvents Events { get; } IBundleRegistry BundleRegistry { get; } } } namespace EnhancedPrefabLoader.API.UI { public interface ICustomShopScreen { } } namespace EnhancedPrefabLoader.API.Services { public interface ICardExpansionService { void SetCardPriceGenerator(ECardExpansionType expansionType, ICardPriceGenerator generator); void SetCardExpGenerator(ECardExpansionType expansionType, ICardExpGenerator generator); float GenerateCardMarketPrice(ECardExpansionType cardExpansionType, EMonsterType monsterType, bool isFoil); float GenerateCardMarketPrice(CardData cardData); float GenerateCardExp(CardData cardData); } public interface ICardUIService { void ApplyEplCardUI(CardUI cardUI, CardData cardData); void RestoreOriginalCardUI(CardUI cardUI, CardData cardData); } public interface IDecoService { void SetLevelRequirement(EDecoObject decoObject, int level); } public interface IEplServices { IItemService ItemService { get; } ICardExpansionService CardExpansionService { get; } ICardUIService CardUIService { get; } IMenuService MenuService { get; } IFurnitureService FurnitureService { get; } IDecoService DecoService { get; } } public interface IFurnitureService { void SetLevelRequirement(EObjectType objectType, int level); } public interface IItemService { void SetPackGenerator(EItemType pack, IPackGenerator generator); List GeneratePackContent(EItemType pack); void SetItemPriceGenerator(string bundleId, IItemPriceGenerator generator); float GenerateItemCost(EItemType itemType); float GenerateItemMarketPrice(EItemType itemType, float costPrice, float minMarkup, float maxMarkup); void SetNormalGenerationWeight(EItemType pack, ERarity rarity, float weight); void SetGodGenerationWeight(EItemType pack, ERarity rarity, float weight); void SetSlotWeight(EItemType pack, PackSlot slot, ERarity rarity, float weight); void SetLicensePrice(EItemType itemType, bool isBigBox, float price); void SetLicenseLevel(EItemType itemType, bool isBigBox, int level); void SetAutoBoxPrice(EItemType itemType, EItemType followItemType); void SetMarketPricePercent(EItemType itemType, float min, float max); void SetFollowItemPrice(EItemType itemType, EItemType sourceItemType); void SetCanHaveGodPacks(EItemType pack, bool enabled); void SetGodPackPercentage(EItemType pack, float percentage); void SetGodPack(EItemType pack, bool enabled, float percentage); } public interface IMenuService { void AddGenericExpansionButton(string label, Action onClick); void AddBinderExpansionButton(string label, Action onClick); } } namespace EnhancedPrefabLoader.API.Registry { public interface IBundleRegistry { IReadOnlyDictionary BundleInfo { get; } string? GetBundleIdFor(TEnum enumValue) where TEnum : Enum; string? GetBundleIdFor(DecoFlags category, string assetName); bool IsEplAsset(TEnum enumValue) where TEnum : Enum; bool IsEplAsset(string category, string assetName); bool HasRegisteredRestockData(EItemType itemType); } } namespace EnhancedPrefabLoader.API.Models { public class BundleInfo { internal readonly List ceilingTextures = new List(); internal readonly List floorTextures = new List(); internal readonly List wallTextures = new List(); internal readonly List expansionTypes = new List(); internal readonly List furnitureTypes = new List(); internal readonly List decoObjects = new List(); internal readonly List itemTypes = new List(); internal readonly List errors = new List(); internal readonly List warnings = new List(); public string BundleId { get; internal set; } = string.Empty; public string Name { get; internal set; } = string.Empty; public string JsonPath { get; internal set; } = string.Empty; public string BundlePath { get; internal set; } = string.Empty; public bool IsLoaded { get; internal set; } public bool IsValid { get; internal set; } = true; public IReadOnlyList ExpansionTypes => expansionTypes; public IReadOnlyList FurnitureTypes => furnitureTypes; public IReadOnlyList DecoObjects => decoObjects; public IReadOnlyList ItemTypes => itemTypes; public IReadOnlyList CeilingTextures => ceilingTextures; public IReadOnlyList FloorTextures => floorTextures; public IReadOnlyList WallTextures => wallTextures; public IReadOnlyList Errors => errors; public IReadOnlyList Warnings => warnings; } public class ItemShopInfo { public string PhoneAppId { get; internal set; } public string AppDisplayName { get; internal set; } public RestockData? SmallBox { get; internal set; } public RestockData? BigBox { get; internal set; } } public class PackGenerationEventArgs { public EItemType Pack { get; internal set; } public bool IsGodPack { get; internal set; } public Dictionary? NormalWeights { get; internal set; } public Dictionary? GodWeights { get; internal set; } public SortedDictionary>? SlotWeights { get; internal set; } } [Flags] public enum PackSlot : byte { None = 0, Slot1 = 1, Slot2 = 2, Slot3 = 4, Slot4 = 8, Slot5 = 0x10, Slot6 = 0x20, Slot7 = 0x40, All = byte.MaxValue } public class PackWeightData { public IReadOnlyDictionary NormalWeights { get; internal set; } public IReadOnlyDictionary GodWeights { get; internal set; } public IReadOnlyDictionary> SlotWeights { get; internal set; } } public class ShopData { public string PhoneAppId { get; internal set; } public string AppDisplayName { get; internal set; } public IReadOnlyList TCG { get; internal set; } public IReadOnlyList Accessories { get; internal set; } public IReadOnlyList Figurines { get; internal set; } } public class StreamingAsset where T : Object { public string BundlePath { get; private set; } public string AssetName { get; private set; } public StreamingAsset(string bundlePath, string assetName) { BundlePath = bundlePath; AssetName = assetName; base..ctor(); } internal void GetAsync(Action callback, bool keepAlive = false) { if (callback != null) { StreamingAssetsBridge.AssetLoadBridge?.StartLoadingCoroutine(BundlePath, AssetName, keepAlive, typeof(T), callback); } } } } namespace EnhancedPrefabLoader.API.InternalBridges { internal interface IAssetLoadBridge { void StartLoadingCoroutine(string bundlePath, string assetName, bool keepAlive, Type type, Action callback); } internal interface IAssetRefTracker { void IncrementRef(string assetKey); void DecrementRef(string assetKey); } internal static class StreamingAssetsBridge { internal static IAssetLoadBridge? AssetLoadBridge { get; set; } internal static IAssetRefTracker? AssetRefTracker { get; set; } } } namespace EnhancedPrefabLoader.API.Extensions { public static class GameObjectExtensions { public static T GetOrAddComponent(this GameObject obj) where T : Component { T result = default(T); if (!obj.TryGetComponent(ref result)) { return obj.AddComponent(); } return result; } } public static class StreamingAssetExtensions { private class AssetRequest { public string AssetName = string.Empty; public string RequestId = string.Empty; } private static readonly ConditionalWeakTable activeSpriteRequests = new ConditionalWeakTable(); private static readonly ConditionalWeakTable> activeTextureRequests = new ConditionalWeakTable>(); public static void SetSpriteAsync(this Image image, StreamingAsset? asset) { Image image2 = image; StreamingAsset asset2 = asset; if (asset2 == null) { image2.sprite = null; return; } string requestId = Guid.NewGuid().ToString(); AssetRequest orCreateValue = activeSpriteRequests.GetOrCreateValue(image2); orCreateValue.AssetName = asset2.AssetName; orCreateValue.RequestId = requestId; asset2.GetAsync(delegate(Object? obj) { if (image2 != null) { Sprite val = (Sprite)(object)((obj is Sprite) ? obj : null); if (val != null && activeSpriteRequests.TryGetValue(image2, out AssetRequest value) && !(value.RequestId != requestId) && !(value.AssetName != asset2.AssetName)) { ((Component)image2).gameObject.GetOrAddComponent().TrackImage(image2, asset2.BundlePath + "|" + asset2.AssetName); image2.sprite = val; ((Graphic)image2).SetAllDirty(); } } }); } public static void CancelPendingSpriteAsync(this Image image) { if (activeSpriteRequests.TryGetValue(image, out AssetRequest value)) { value.RequestId = Guid.NewGuid().ToString(); value.AssetName = string.Empty; } } public static void CancelPendingTextureAsync(this Material material, string propertyName) { if (activeTextureRequests.TryGetValue(material, out Dictionary value) && value.TryGetValue(propertyName, out var value2)) { value2.RequestId = Guid.NewGuid().ToString(); value2.AssetName = string.Empty; } } public static void SetTextureAsync(this Material material, string propertyName, StreamingAsset? asset) { Material material2 = material; string propertyName2 = propertyName; StreamingAsset asset2 = asset; if (asset2 == null) { material2.SetTexture(propertyName2, (Texture)null); return; } string requestId = Guid.NewGuid().ToString(); Dictionary orCreateValue = activeTextureRequests.GetOrCreateValue(material2); if (!orCreateValue.TryGetValue(propertyName2, out var value)) { value = new AssetRequest(); orCreateValue[propertyName2] = value; } value.AssetName = asset2.AssetName; value.RequestId = requestId; asset2.GetAsync(delegate(Object? obj) { if (material2 != null) { Texture val = (Texture)(object)((obj is Texture) ? obj : null); if (val != null && activeTextureRequests.TryGetValue(material2, out Dictionary value2) && value2.TryGetValue(propertyName2, out var value3) && !(value3.RequestId != requestId) && !(value3.AssetName != asset2.AssetName)) { material2.SetTexture(propertyName2, val); } } }, keepAlive: true); } } public static class StringExtensions { public static T? TryParseToEnum(this string value) where T : struct, Enum { if (!Enum.TryParse(value, out var result)) { return null; } return result; } public static string Sanitize(this string value) { if (string.IsNullOrWhiteSpace(value)) { return "_Invalid"; } string input = Regex.Replace(value, "\\s", ""); input = Regex.Replace(input, "[^\\w]", "_"); if (!string.IsNullOrEmpty(input) && !char.IsDigit(input[0])) { return input; } return "_" + (input ?? "Invalid"); } public static string Prettierize(this string value) { if (string.IsNullOrWhiteSpace(value)) { return value; } value = value.Replace('_', ' '); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value[0]); for (int i = 1; i < value.Length; i++) { char c = value[i]; char c2 = value[i - 1]; if (char.IsUpper(c) && !char.IsWhiteSpace(c2) && (char.IsLower(c2) || (i < value.Length - 1 && char.IsLower(value[i + 1])))) { stringBuilder.Append(' '); } if (char.IsDigit(c) && char.IsLetter(c2)) { stringBuilder.Append(' '); } stringBuilder.Append(c); } return Regex.Replace(stringBuilder.ToString(), "\\s+", " ").Trim(); } } } namespace EnhancedPrefabLoader.API.Events { public interface IEplEvents { IShopEvents Shops { get; } IItemEvents Items { get; } event Action OnBundleLoadingComplete; } public interface IItemEvents { event Action OnBeforePackGenerated; } public interface IShopEvents { event Action OnShopsReady; } } namespace EnhancedPrefabLoader.API.Components { internal class StreamingAssetTracker : MonoBehaviour { private readonly ConditionalWeakTable imageTracker = new ConditionalWeakTable(); private readonly ConditionalWeakTable> materialTracker = new ConditionalWeakTable>(); internal void TrackImage(Image image, string assetKey) { if (imageTracker.TryGetValue(image, out string value)) { StreamingAssetsBridge.AssetRefTracker?.DecrementRef(value); } imageTracker.AddOrUpdate(image, assetKey); StreamingAssetsBridge.AssetRefTracker?.IncrementRef(assetKey); } internal void TrackMaterial(Material material, string layer, string assetKey) { if (materialTracker.TryGetValue(material, out Dictionary value) && value.TryGetValue(layer, out var value2)) { StreamingAssetsBridge.AssetRefTracker?.DecrementRef(value2); } materialTracker.GetOrCreateValue(material)[layer] = assetKey; StreamingAssetsBridge.AssetRefTracker?.IncrementRef(assetKey); } internal bool TryGetTrackedKey(Image image, out string? assetKey) { return imageTracker.TryGetValue(image, out assetKey); } internal bool TryGetTrackedKey(Material material, string layer, out string? assetKey) { if (materialTracker.TryGetValue(material, out Dictionary value)) { return value.TryGetValue(layer, out assetKey); } assetKey = null; return false; } private void OnDestroy() { foreach (var (_, assetKey) in (IEnumerable>)imageTracker) { StreamingAssetsBridge.AssetRefTracker?.DecrementRef(assetKey); } foreach (KeyValuePair> item in (IEnumerable>>)materialTracker) { item.Deconstruct(out var _, out var value); foreach (string value2 in value.Values) { StreamingAssetsBridge.AssetRefTracker?.DecrementRef(value2); } } } } } namespace EnhancedPrefabLoader.API.Behaviors { public interface ICardExpGenerator { float CalculateExp(CardData cardData); } public interface ICardPriceGenerator { float GenerateCardMarketPrice(ECardExpansionType expansionType, EMonsterType monsterType, ECardBorderType borderType, ERarity rarity, List expansionRarities, bool isFoil); } public interface IItemPriceGenerator { float GenerateItemCost(EItemType itemType, float baseCost); float GenerateItemMarketPrice(EItemType itemType, float baseCost, float minMarkup, float maxMarkup); } public interface IPackGenerator { List GeneratePack(ECardExpansionType cardExpansion, List cardPool, bool hasRandomFoils); } } namespace EnhancedPrefabLoader.API.Assets { public interface ICardExpansionLibrary { StreamingAsset? GetCardExpansionCardBack(ECardExpansionType cardExpansionType); StreamingAsset? GetCardExpansionFoilMask(ECardExpansionType cardExpansionType); StreamingAsset? GetCardFoilMask(ECardExpansionType cardExpansionType, EMonsterType monsterType); StreamingAsset? GetCardBack(ECardExpansionType cardExpansionType, EMonsterType monsterType); StreamingAsset? GetCardSprite(ECardExpansionType cardExpansionType, EMonsterType monsterType); IReadOnlyDictionary> GetCardSprites(ECardExpansionType cardExpansionType); MonsterData GetMonsterData(CardData cardData); MonsterData GetMonsterData(ECardExpansionType expansionType, EMonsterType monsterType); bool IsCardExpansionUnlocked(ECardExpansionType expansionType); bool IsCardFoil(ECardExpansionType expansionType, EMonsterType monsterType); } public interface IDecoLibrary { StreamingAsset? GetIcon(EDecoObject decoObject); IReadOnlyDictionary> GetIcons(); InteractableObject? GetPrefab(EDecoObject decoObject); IReadOnlyDictionary GetPrefabs(); int GetLevelRequirement(EDecoObject decoObject); } public interface IEplAssets { ICardExpansionLibrary CardExpansions { get; } IFurnitureLibrary Furniture { get; } IItemLibrary Items { get; } IDecoLibrary Deco { get; } IShopLibrary Shops { get; } } public interface IFurnitureLibrary { StreamingAsset? GetIcon(EObjectType objectType); IReadOnlyDictionary> GetIcons(); InteractableObject? GetPrefab(EObjectType objectType); IReadOnlyDictionary GetPrefabs(); int GetLevelRequirement(EObjectType objectType); } public interface IItemLibrary { StreamingAsset? GetIcon(EItemType itemType); IReadOnlyDictionary> GetIcons(); ItemMeshData? GetItemMeshData(EItemType itemType); IReadOnlyDictionary GetAllItemMeshData(); EItemType GetBulkBox(ECardExpansionType expansionType, int priceCutoff); IReadOnlyDictionary> GetBulkBoxes(); PackWeightData GetPackWeights(EItemType pack); } public interface IShopLibrary { List GetPhoneAppIds(); ShopData? GetShopDataFor(string appId); ItemShopInfo? GetShopInfoFor(EItemType itemType); } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }