Decompiled source of RegisterCommandChest v1.0.0

plugins/viliger-RegisterCommandChest/RegisterCommandChest.dll

Decompiled 2 days ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using RoR2;
using RoR2.ContentManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RegisterCommandChest")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RegisterCommandChest")]
[assembly: AssemblyTitle("RegisterCommandChest")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RegisterCommandChest;

[BepInPlugin("Viliger.RegisterCommandChest", "RegisterCommandChest", "1.0.0")]
public class RegisterCommandChest : BaseUnityPlugin
{
	public const string Author = "Viliger";

	public const string Name = "RegisterCommandChest";

	public const string Version = "1.0.0";

	public const string GUID = "Viliger.RegisterCommandChest";

	public const string LanguageFolder = "Language";

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		Language.collectLanguageRootFolders += Language_collectLanguageRootFolders;
	}

	private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
	{
		addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider());
	}

	private void Language_collectLanguageRootFolders(List<string> folders)
	{
		folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
	}
}
public class ContentProvider : IContentPackProvider
{
	private readonly ContentPack _contentPack = new ContentPack();

	public string identifier => "Viliger.RegisterCommandChest.ContentPack";

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(_contentPack, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		_contentPack.identifier = identifier;
		InspectDef val = ScriptableObject.CreateInstance<InspectDef>();
		((Object)val).name = "CommandChestInspectDef";
		val.Info = new InspectInfo
		{
			Visual = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/ChestIcon_1.png").WaitForCompletion(),
			TitleToken = "COMMANDCHEST_NAME",
			DescriptionToken = "COMMANDCHEST_DESCRIPTION",
			FlavorToken = "COMMANDCHEST_LORE"
		};
		GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/CommandChest/CommandChest.prefab").WaitForCompletion();
		val2.AddComponent<GenericInspectInfoProvider>().InspectInfo = val;
		_contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { val2 });
		yield break;
	}
}