Decompiled source of R2API Addressables v1.1.2

plugins/R2API.Addressables/R2API.Addressables.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HG.Coroutines;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API.AutoVersionGen;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.Addressables")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+c78ac49eca03f066e140dc8ca92a167668074629")]
[assembly: AssemblyProduct("R2API.Addressables")]
[assembly: AssemblyTitle("R2API.Addressables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace R2API
{
	[AutoVersion]
	[BepInPlugin("com.bepis.r2api.addressables", "R2API.Addressables", "1.1.2")]
	public sealed class AddressablesPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.bepis.r2api.addressables";

		public const string PluginName = "R2API.Addressables";

		public const string PluginVersion = "1.1.2";

		internal static ManualLogSource Logger { get; set; }

		public static AddressablesPlugin Instance { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
		}
	}
}
namespace R2API.AutoVersionGen
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	internal class AutoVersionAttribute : Attribute
	{
	}
}
namespace R2API.AddressReferencedAssets
{
	[Serializable]
	public class AddressReferencedAsset<T> : AddressReferencedAsset where T : Object
	{
		private AsyncOperationHandle<T> _asyncOperationHandle;

		[SerializeField]
		private T _asset;

		[SerializeField]
		private string _address;

		[SerializeField]
		[HideInInspector]
		private bool _useDirectReference;

		private bool _AddressFailedToLoad;

		public T Asset
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_asset))
				{
					return _asset;
				}
				if (!AddressReferencedAsset.Initialized && CanLoadFromCatalog)
				{
					string name = GetType().Name;
					MethodBase method = new StackTrace().GetFrame(1).GetMethod();
					AddressablesPlugin.Logger.LogWarning((object)($"Assembly {Assembly.GetCallingAssembly()} is trying to access an {name} before AddressReferencedAssets have initialized! This can cause issues as {name} can load the asset from Catalogs within the game." + "\n Consider using AddressReferencedAssets.OnAddressReferencedAssetsLoaded for running code that depends on AddressableAssets! (Method: " + method.DeclaringType.FullName + "." + method.Name + "()"));
					Load();
				}
				else if (IsValidForLoadingWithAddress())
				{
					if (!_AddressFailedToLoad)
					{
						if (_asyncOperationHandle.IsValid())
						{
							_asset = _asyncOperationHandle.WaitForCompletion();
							return _asset;
						}
						Load();
						return _asset;
					}
					AddressablesPlugin.Logger.LogWarning((object)$"Not trying to load {this} because it's address has already failed to load beforehand. Null will be returned.");
				}
				return _asset;
			}
			set
			{
				_asset = value;
				_address = (Object.op_Implicit((Object)(object)_asset) ? string.Empty : _address);
				_useDirectReference = Object.op_Implicit((Object)(object)_asset);
			}
		}

		public override Object BoxedAsset => (Object)(object)_asset;

		public new AsyncOperationHandle<T> AsyncOperationHandle
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _asyncOperationHandle;
			}
			protected set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				_asyncOperationHandle = value;
				base.AsyncOperationHandle = AsyncOperationHandle<T>.op_Implicit(value);
			}
		}

		public bool AssetExists => Object.op_Implicit((Object)(object)_asset);

		public string Address
		{
			get
			{
				return _address;
			}
			set
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				_address = value;
				_asset = default(T);
				_useDirectReference = false;
				_AddressFailedToLoad = false;
				if (_asyncOperationHandle.IsValid())
				{
					Addressables.Release<T>(_asyncOperationHandle);
				}
				if (RoR2Application.loadFinished)
				{
					Load();
				}
			}
		}

		public bool IsInvalid
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_asset))
				{
					if (!string.IsNullOrEmpty(_address))
					{
						return string.IsNullOrWhiteSpace(_address);
					}
					return true;
				}
				return false;
			}
		}

		public bool UseDirectReference => _useDirectReference;

		public virtual bool CanLoadFromCatalog { get; protected set; }

		private bool IsValidForLoadingWithAddress()
		{
			if (!Object.op_Implicit((Object)(object)_asset))
			{
				return !string.IsNullOrEmpty(_address);
			}
			return false;
		}

		[Obsolete("Call \"LoadAssetAsyncCoroutine()\" instead.")]
		protected sealed override async Task LoadAssetAsync()
		{
			if (IsValidForLoadingWithAddress())
			{
				await LoadAsync();
			}
		}

		protected sealed override IEnumerator LoadAssetAsyncCoroutine()
		{
			if (IsValidForLoadingWithAddress())
			{
				IEnumerator coroutine = LoadAsyncCoroutine();
				while (coroutine.MoveNext())
				{
					yield return null;
				}
			}
		}

		public T LoadAssetNow()
		{
			if (!AssetExists)
			{
				Load();
			}
			return Asset;
		}

		public virtual IEnumerator LoadAssetNowCoroutine(Action<T> onLoaded)
		{
			if (!AssetExists)
			{
				IEnumerator loadCoroutine = LoadAsyncCoroutine();
				while (loadCoroutine.MoveNext())
				{
					yield return null;
				}
			}
			onLoaded?.Invoke(Asset);
		}

		protected virtual void Load()
		{
			LoadFromAddress();
		}

		protected virtual IEnumerator LoadAsyncCoroutine()
		{
			IEnumerator loadCoroutine = LoadFromAddressAsyncCoroutine();
			while (loadCoroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Use \"LoadAsyncCoroutine()\" Instead")]
		protected virtual async Task LoadAsync()
		{
			await LoadFromAddressAsync();
		}

		protected IEnumerator LoadFromAddressAsyncCoroutine()
		{
			if (AddressReferencedAsset.addressesThatFailedToBeValidated.Contains(_address))
			{
				yield break;
			}
			bool? flag = null;
			IEnumerator<bool?> enumerator = IsAdressValidAsync();
			while (flag.HasValue && enumerator.MoveNext())
			{
				flag = enumerator.Current;
			}
			flag.GetValueOrDefault();
			if (!flag.HasValue)
			{
				bool value = false;
				flag = value;
			}
			if (flag == false)
			{
				AddressablesPlugin.Logger.LogWarning((object)$"{this} failed to load from it's address because the address is either invalid, or malformed.");
				AddressReferencedAsset.addressesThatFailedToBeValidated.Add(_address);
				_AddressFailedToLoad = true;
				yield break;
			}
			AsyncOperationHandle = Addressables.LoadAssetAsync<T>((object)_address);
			while (!AsyncOperationHandle.IsDone)
			{
				yield return null;
			}
			_asset = AsyncOperationHandle.Result;
		}

		[Obsolete("Use \"LoadFromAdressAsyncCoroutine\" Instead")]
		protected async Task LoadFromAddressAsync()
		{
			bool? flag = null;
			IEnumerator<bool?> enumerator = IsAdressValidAsync();
			if (flag.HasValue && enumerator.MoveNext())
			{
				flag = enumerator.Current;
			}
			if (flag == false)
			{
				AddressablesPlugin.Logger.LogWarning((object)$"{this} failed to load from it's address because the address is either invalid, or malformed.");
				AddressReferencedAsset.addressesThatFailedToBeValidated.Add(_address);
				_AddressFailedToLoad = true;
			}
			else
			{
				AsyncOperationHandle = Addressables.LoadAssetAsync<T>((object)_address);
				_asset = await AsyncOperationHandle.Task;
			}
		}

		protected void LoadFromAddress()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAddressValid())
			{
				AddressablesPlugin.Logger.LogWarning((object)$"{this} failed to load from it's address because the address is either invalid, or malformed.");
				_AddressFailedToLoad = true;
				AddressReferencedAsset.addressesThatFailedToBeValidated.Add(_address);
			}
			else
			{
				AsyncOperationHandle = Addressables.LoadAssetAsync<T>((object)_address);
				_asset = AsyncOperationHandle.WaitForCompletion();
			}
		}

		private bool IsAddressValid()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadResourceLocationsAsync((object)_address, (Type)null).WaitForCompletion().Any();
		}

		private IEnumerator<bool?> IsAdressValidAsync()
		{
			AsyncOperationHandle<IList<IResourceLocation>> locationTask = Addressables.LoadResourceLocationsAsync((object)_address, (Type)null);
			while (!locationTask.IsDone)
			{
				yield return null;
			}
			IList<IResourceLocation> result = locationTask.Result;
			yield return result.Any();
		}

		public override string ToString()
		{
			return string.Format("{0}(Asset={1}.Address={2}", GetType().Name, Object.op_Implicit((Object)(object)_asset) ? ((object)_asset) : "null", Address);
		}

		public override void Dispose()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (AsyncOperationHandle.IsValid())
			{
				Addressables.Release<T>(AsyncOperationHandle);
			}
		}

		public static implicit operator bool(AddressReferencedAsset<T> addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)((addressReferencedAsset != null) ? addressReferencedAsset.Asset : default(T)));
		}

		public static implicit operator T(AddressReferencedAsset<T> addressReferencedAsset)
		{
			if (addressReferencedAsset == null)
			{
				return default(T);
			}
			return addressReferencedAsset.Asset;
		}

		public static implicit operator AddressReferencedAsset<T>(string address)
		{
			return new AddressReferencedAsset<T>(address);
		}

		public static implicit operator AddressReferencedAsset<T>(T asset)
		{
			return new AddressReferencedAsset<T>(asset);
		}

		public AddressReferencedAsset(T asset)
		{
			SetHooks();
			_asset = asset;
			_useDirectReference = true;
			AddressReferencedAsset.instances.Add(this);
		}

		public AddressReferencedAsset(string address)
		{
			SetHooks();
			_address = address;
			_useDirectReference = false;
			AddressReferencedAsset.instances.Add(this);
		}

		public AddressReferencedAsset()
		{
			SetHooks();
			AddressReferencedAsset.instances.Add(this);
		}

		~AddressReferencedAsset()
		{
			AddressReferencedAsset.instances.Remove(this);
			if (AddressReferencedAsset.instances.Count == 0)
			{
				UnsetHooks();
			}
		}
	}
	public abstract class AddressReferencedAsset : IDisposable
	{
		protected static readonly HashSet<string> addressesThatFailedToBeValidated = new HashSet<string>();

		protected static readonly HashSet<AddressReferencedAsset> instances = new HashSet<AddressReferencedAsset>();

		private static bool _initialized;

		public abstract Object BoxedAsset { get; }

		public static bool Initialized => _initialized;

		public AsyncOperationHandle AsyncOperationHandle { get; protected set; }

		[Obsolete("This event no longer runs after anything in particular, it gets invoked on RoR2Application.onLoad for backwards compatibility.")]
		public static event Action OnAddressReferencedAssetsLoaded;

		protected void SetHooks()
		{
			if (RoR2Application.loadFinished)
			{
				CallInitialized();
				return;
			}
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(CallInitialized));
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(CallInitialized));
		}

		protected void UnsetHooks()
		{
			if (!RoR2Application.loadFinished)
			{
				RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(CallInitialized));
			}
		}

		private void CallInitialized()
		{
			if (!_initialized)
			{
				AddressablesPlugin.Logger.LogMessage((object)"AddressReferencedAssets initialized");
				_initialized = true;
				AddressReferencedAsset.OnAddressReferencedAssetsLoaded?.Invoke();
			}
		}

		private void StartCoroutineOnLoad()
		{
			((MonoBehaviour)AddressablesPlugin.Instance).StartCoroutine(LoadReferencesAsync());
		}

		private static IEnumerator LoadReferencesAsync()
		{
			ParallelCoroutine parallelCoroutine = new ParallelCoroutine();
			foreach (AddressReferencedAsset instance in instances)
			{
				if (!Object.op_Implicit(instance.BoxedAsset))
				{
					parallelCoroutine.Add(instance.LoadAssetAsyncCoroutine());
				}
			}
			while (parallelCoroutine.MoveNext())
			{
				yield return null;
			}
			List<Task> list = new List<Task>();
			foreach (AddressReferencedAsset instance2 in instances)
			{
				if (!Object.op_Implicit(instance2.BoxedAsset))
				{
					list.Add(instance2.LoadAssetAsync());
				}
			}
			Task supertask = Task.WhenAll(list);
			while (!supertask.IsCompleted)
			{
				yield return null;
			}
			_initialized = true;
			AddressReferencedAsset.OnAddressReferencedAssetsLoaded?.Invoke();
		}

		[Obsolete("If you need to implement this, implement a method that just returns Task.CompeltedTask, loading is now done via LoadAssetAsyncCoroutine instead.")]
		protected abstract Task LoadAssetAsync();

		protected abstract IEnumerator LoadAssetAsyncCoroutine();

		public virtual void Dispose()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle asyncOperationHandle = AsyncOperationHandle;
			if (((AsyncOperationHandle)(ref asyncOperationHandle)).IsValid())
			{
				Addressables.Release(AsyncOperationHandle);
			}
		}
	}
	[Serializable]
	public class AddressReferencedBuffDef : AddressReferencedAsset<BuffDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				BuffIndex val = BuffCatalog.FindBuffIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = BuffCatalog.GetBuffDef(val);
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				BuffIndex val = BuffCatalog.FindBuffIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = BuffCatalog.GetBuffDef(val);
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (CanLoadFromCatalog)
			{
				BuffIndex val = BuffCatalog.FindBuffIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = BuffCatalog.GetBuffDef(val);
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedBuffDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator BuffDef(AddressReferencedBuffDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedBuffDef(string address)
		{
			return new AddressReferencedBuffDef(address);
		}

		public static implicit operator AddressReferencedBuffDef(BuffDef asset)
		{
			return new AddressReferencedBuffDef(asset);
		}

		public AddressReferencedBuffDef()
		{
		}

		public AddressReferencedBuffDef(BuffDef def)
			: base(def)
		{
		}

		public AddressReferencedBuffDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
	[Serializable]
	public class AddressReferencedEliteDef : AddressReferencedAsset<EliteDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				EliteDef val = ((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef x) => ((Object)x).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				EliteDef val = ((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef x) => ((Object)x).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			if (CanLoadFromCatalog)
			{
				EliteDef val = ((IEnumerable<EliteDef>)EliteCatalog.eliteDefs).FirstOrDefault((Func<EliteDef, bool>)((EliteDef x) => ((Object)x).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedEliteDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator EliteDef(AddressReferencedEliteDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedEliteDef(string address)
		{
			return new AddressReferencedEliteDef(address);
		}

		public static implicit operator AddressReferencedEliteDef(EliteDef asset)
		{
			return new AddressReferencedEliteDef(asset);
		}

		public AddressReferencedEliteDef()
		{
		}

		public AddressReferencedEliteDef(EliteDef def)
			: base(def)
		{
		}

		public AddressReferencedEliteDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
	[Serializable]
	public class AddressReferencedEquipmentDef : AddressReferencedAsset<EquipmentDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = EquipmentCatalog.GetEquipmentDef(val);
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead.")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = EquipmentCatalog.GetEquipmentDef(val);
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (CanLoadFromCatalog)
			{
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = EquipmentCatalog.GetEquipmentDef(val);
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedEquipmentDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator EquipmentDef(AddressReferencedEquipmentDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedEquipmentDef(string address)
		{
			return new AddressReferencedEquipmentDef(address);
		}

		public static implicit operator AddressReferencedEquipmentDef(EquipmentDef asset)
		{
			return new AddressReferencedEquipmentDef(asset);
		}

		public AddressReferencedEquipmentDef()
		{
		}

		public AddressReferencedEquipmentDef(EquipmentDef def)
			: base(def)
		{
		}

		public AddressReferencedEquipmentDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
	[Serializable]
	public class AddressReferencedExpansionDef : AddressReferencedAsset<ExpansionDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				ExpansionDef val = ((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func<ExpansionDef, bool>)((ExpansionDef ed) => ((Object)ed).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				ExpansionDef val = ((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func<ExpansionDef, bool>)((ExpansionDef ed) => ((Object)ed).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (CanLoadFromCatalog)
			{
				ExpansionDef val = ((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func<ExpansionDef, bool>)((ExpansionDef ed) => ((Object)ed).name.Equals(base.Address, StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null)
				{
					base.Asset = val;
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedExpansionDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator ExpansionDef(AddressReferencedExpansionDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedExpansionDef(string address)
		{
			return new AddressReferencedExpansionDef(address);
		}

		public static implicit operator AddressReferencedExpansionDef(ExpansionDef asset)
		{
			return new AddressReferencedExpansionDef(asset);
		}

		public AddressReferencedExpansionDef()
		{
		}

		public AddressReferencedExpansionDef(ExpansionDef def)
			: base(def)
		{
		}

		public AddressReferencedExpansionDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
	[Serializable]
	public class AddressReferencedItemDef : AddressReferencedAsset<ItemDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				ItemIndex val = ItemCatalog.FindItemIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = ItemCatalog.GetItemDef(val);
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				ItemIndex val = ItemCatalog.FindItemIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = ItemCatalog.GetItemDef(val);
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (CanLoadFromCatalog)
			{
				ItemIndex val = ItemCatalog.FindItemIndex(base.Address);
				if ((int)val != -1)
				{
					base.Asset = ItemCatalog.GetItemDef(val);
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedItemDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator ItemDef(AddressReferencedItemDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedItemDef(string address)
		{
			return new AddressReferencedItemDef(address);
		}

		public static implicit operator AddressReferencedItemDef(ItemDef asset)
		{
			return new AddressReferencedItemDef(asset);
		}

		public AddressReferencedItemDef()
		{
		}

		public AddressReferencedItemDef(ItemDef def)
			: base(def)
		{
		}

		public AddressReferencedItemDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
	[Serializable]
	public class AddressReferencedPrefab : AddressReferencedAsset<GameObject>
	{
		public static implicit operator bool(AddressReferencedPrefab addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator GameObject(AddressReferencedPrefab addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedPrefab(string address)
		{
			return new AddressReferencedPrefab(address);
		}

		public static implicit operator AddressReferencedPrefab(GameObject asset)
		{
			return new AddressReferencedPrefab(asset);
		}

		public AddressReferencedPrefab()
		{
		}

		public AddressReferencedPrefab(GameObject gameObject)
			: base(gameObject)
		{
		}

		public AddressReferencedPrefab(string address)
			: base(address)
		{
		}
	}
	[Serializable]
	public class AddressReferencedSpawnCard : AddressReferencedAsset<SpawnCard>
	{
		public static implicit operator bool(AddressReferencedSpawnCard addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator SpawnCard(AddressReferencedSpawnCard addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedSpawnCard(string address)
		{
			return new AddressReferencedSpawnCard(address);
		}

		public static implicit operator AddressReferencedSpawnCard(SpawnCard asset)
		{
			return new AddressReferencedSpawnCard(asset);
		}

		public AddressReferencedSpawnCard()
		{
		}

		public AddressReferencedSpawnCard(SpawnCard spawnCard)
			: base(spawnCard)
		{
		}

		public AddressReferencedSpawnCard(string address)
			: base(address)
		{
		}
	}
	[Serializable]
	public class AddressReferencedUnlockableDef : AddressReferencedAsset<UnlockableDef>
	{
		[SerializeField]
		[HideInInspector]
		private bool _canLoadFromCatalog = true;

		public override bool CanLoadFromCatalog
		{
			get
			{
				return _canLoadFromCatalog;
			}
			protected set
			{
				_canLoadFromCatalog = value;
			}
		}

		protected override IEnumerator LoadAsyncCoroutine()
		{
			if (CanLoadFromCatalog)
			{
				UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(base.Address);
				if (Object.op_Implicit((Object)(object)unlockableDef))
				{
					base.Asset = unlockableDef;
					yield break;
				}
			}
			IEnumerator subroutine = LoadFromAddressAsyncCoroutine();
			while (subroutine.MoveNext())
			{
				yield return null;
			}
		}

		[Obsolete("Call LoadAsyncCoroutine instead")]
		protected override async Task LoadAsync()
		{
			if (CanLoadFromCatalog)
			{
				UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(base.Address);
				if (Object.op_Implicit((Object)(object)unlockableDef))
				{
					base.Asset = unlockableDef;
					return;
				}
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			if (CanLoadFromCatalog)
			{
				UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(base.Address);
				if (Object.op_Implicit((Object)(object)unlockableDef))
				{
					base.Asset = unlockableDef;
					return;
				}
			}
			LoadFromAddress();
		}

		public static implicit operator bool(AddressReferencedUnlockableDef addressReferencedAsset)
		{
			return Object.op_Implicit((Object)(object)addressReferencedAsset?.Asset);
		}

		public static implicit operator UnlockableDef(AddressReferencedUnlockableDef addressReferencedAsset)
		{
			return addressReferencedAsset?.Asset;
		}

		public static implicit operator AddressReferencedUnlockableDef(string address)
		{
			return new AddressReferencedUnlockableDef(address);
		}

		public static implicit operator AddressReferencedUnlockableDef(UnlockableDef asset)
		{
			return new AddressReferencedUnlockableDef(asset);
		}

		public AddressReferencedUnlockableDef()
		{
		}

		public AddressReferencedUnlockableDef(UnlockableDef def)
			: base(def)
		{
		}

		public AddressReferencedUnlockableDef(string addressOrName)
			: base(addressOrName)
		{
		}
	}
}