Decompiled source of R2API Addressables v1.0.4

plugins/R2API.Addressables/R2API.Addressables.dll

Decompiled 3 months ago
using System;
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.Reflection;
using Microsoft.CodeAnalysis;
using R2API.AutoVersionGen;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
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.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+6c9035333c99ee3ecb3db4fb28885d70ab1fd9c7")]
[assembly: AssemblyProduct("R2API.Addressables")]
[assembly: AssemblyTitle("R2API.Addressables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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.0.4")]
	public sealed class AddressablesPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.bepis.r2api.addressables";

		public const string PluginName = "R2API.Addressables";

		public const string PluginVersion = "1.0.4";

		internal static ManualLogSource Logger { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
		}
	}
}
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
	{
		[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) && !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)
					{
						AddressablesPlugin.Logger.LogWarning((object)$"Not trying to load {this} because it's address has already failed to load beforehand. Null will be returned.");
					}
					else
					{
						LoadFromAddress();
					}
				}
				return _asset;
			}
			set
			{
				_asset = value;
				_address = (Object.op_Implicit((Object)(object)_asset) ? string.Empty : _address);
				_useDirectReference = Object.op_Implicit((Object)(object)_asset);
			}
		}

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

		public string Address
		{
			get
			{
				return _address;
			}
			set
			{
				_address = value;
				_asset = default(T);
				_useDirectReference = false;
				_AddressFailedToLoad = false;
				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; }

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

		protected sealed override async Task LoadAssetAsync()
		{
			if (IsValidForLoadingWithAddress())
			{
				await LoadAsync();
			}
		}

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

		protected virtual async Task LoadAsync()
		{
			await LoadFromAddressAsync();
		}

		protected async Task LoadFromAddressAsync()
		{
			if (!(await IsAddressValidAsync()))
			{
				AddressablesPlugin.Logger.LogWarning((object)$"{this} failed to load from it's address because the address is either invalid, or malformed.");
				_AddressFailedToLoad = true;
			}
			else
			{
				_asset = await Addressables.LoadAssetAsync<T>((object)_address).Task;
			}
		}

		protected void LoadFromAddress()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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;
			}
			else
			{
				_asset = Addressables.LoadAssetAsync<T>((object)_address).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)
			IList<IResourceLocation> source = Addressables.LoadResourceLocationsAsync((object)_address, (Type)null).WaitForCompletion();
			AddressablesPlugin.Logger.LogFatal((object)$"Location for address {Address} exists?: {source.Any()}");
			return source.Any();
		}

		private async Task<bool> IsAddressValidAsync()
		{
			return (await Addressables.LoadResourceLocationsAsync((object)_address, (Type)null).Task).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 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
	{
		protected static readonly HashSet<AddressReferencedAsset> instances = new HashSet<AddressReferencedAsset>();

		private static bool _initialized;

		public static bool Initialized => _initialized;

		public static event Action OnAddressReferencedAssetsLoaded;

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

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

		private static async void LoadReferencesAsync()
		{
			foreach (AddressReferencedAsset instance in instances)
			{
				try
				{
					await instance.LoadAssetAsync();
				}
				catch (Exception ex)
				{
					AddressablesPlugin.Logger.LogError((object)ex);
				}
			}
			_initialized = true;
			AddressReferencedAsset.OnAddressReferencedAssetsLoaded?.Invoke();
		}

		protected abstract Task LoadAssetAsync();
	}
	[Serializable]
	public class AddressReferencedBuffDef : AddressReferencedAsset<BuffDef>
	{
		public override bool CanLoadFromCatalog => true;

		protected override async Task LoadAsync()
		{
			BuffIndex val = BuffCatalog.FindBuffIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = BuffCatalog.GetBuffDef(val);
			}
			else
			{
				await LoadFromAddressAsync();
			}
		}

		protected override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			BuffIndex val = BuffCatalog.FindBuffIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = BuffCatalog.GetBuffDef(val);
			}
			else
			{
				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>
	{
		public override bool CanLoadFromCatalog => true;

		protected override async Task LoadAsync()
		{
			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;
			}
			else
			{
				await LoadFromAddressAsync();
			}
		}

		protected override void Load()
		{
			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;
			}
			else
			{
				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>
	{
		public override bool CanLoadFromCatalog => true;

		protected override async Task LoadAsync()
		{
			EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = EquipmentCatalog.GetEquipmentDef(val);
			}
			else
			{
				await LoadFromAddressAsync();
			}
		}

		protected override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = EquipmentCatalog.GetEquipmentDef(val);
			}
			else
			{
				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>
	{
		public override bool CanLoadFromCatalog => true;

		protected override async Task LoadAsync()
		{
			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;
			}
			await LoadFromAddressAsync();
		}

		protected override void Load()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			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;
			}
			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>
	{
		public override bool CanLoadFromCatalog => true;

		protected override async Task LoadAsync()
		{
			ItemIndex val = ItemCatalog.FindItemIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = ItemCatalog.GetItemDef(val);
			}
			else
			{
				await LoadFromAddressAsync();
			}
		}

		protected override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex val = ItemCatalog.FindItemIndex(base.Address);
			if ((int)val != -1)
			{
				base.Asset = ItemCatalog.GetItemDef(val);
			}
			else
			{
				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>
	{
		protected override async Task LoadAsync()
		{
			UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(base.Address);
			if (Object.op_Implicit((Object)(object)unlockableDef))
			{
				base.Asset = unlockableDef;
			}
			else
			{
				await LoadFromAddressAsync();
			}
		}

		protected override void Load()
		{
			UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(base.Address);
			if (Object.op_Implicit((Object)(object)unlockableDef))
			{
				base.Asset = unlockableDef;
			}
			else
			{
				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)
		{
		}
	}
}