Decompiled source of UncrustedSandwich v1.0.7

plugins/UncrustedSandwich/UncrustedSandwich.dll

Decompiled a week ago
using System;
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 BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UncrustedSandwich")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cf4b78503ee9ecb7ab93fe4aa7b4369be9141e14")]
[assembly: AssemblyProduct("UncrustedSandwich")]
[assembly: AssemblyTitle("UncrustedSandwich")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UncrustedSandwich
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Egglectro.UncrustedSandwich", "UncrustedSandwich", "1.0.7")]
	public class UncrustedSandwich : BaseUnityPlugin
	{
		public const string PluginGUID = "Egglectro.UncrustedSandwich";

		public const string PluginAuthor = "Egglectro";

		public const string PluginName = "UncrustedSandwich";

		public const string PluginVersion = "1.0.7";

		private static ItemDef uncrustedSandwich;

		public void Awake()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			UncrustedSandwichConfig.SetUpConfig((BaseUnityPlugin)(object)this);
			uncrustedSandwich = ScriptableObject.CreateInstance<ItemDef>();
			string text = "Uncrustable Uncrustable Uncrustable Uncrustable Uncrustable Uncrustable Uncrustable Uncrustable";
			string text2 = "Uncrusted Sandwich";
			string text3 = "gamerH0ST brainrot";
			if (UncrustedSandwichConfig.ReworkType.Value == 0)
			{
				((Object)uncrustedSandwich).name = "SANDWICH_NAME";
				uncrustedSandwich.nameToken = "SANDWICH_NAME";
				uncrustedSandwich.pickupToken = "SANDWICH_PICKUP";
				uncrustedSandwich.descriptionToken = "SANDWICH_DESC";
				uncrustedSandwich.loreToken = "SANDWICH_LORE";
				uncrustedSandwich._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/LunarTierDef.asset").WaitForCompletion();
				using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UncrustedSandwich.uncrustedsandwich"))
				{
					AssetBundle val = AssetBundle.LoadFromStream(stream);
					uncrustedSandwich.pickupModelPrefab = val.LoadAsset<GameObject>("Assets/Import/sandwich/sandwich.prefab");
					uncrustedSandwich.pickupIconSprite = val.LoadAsset<Sprite>("Assets/Import/sandwich_icon/uncrustable_lunar.png");
				}
				ItemAPI.ApplyTagToItem("Any", uncrustedSandwich);
				uncrustedSandwich.canRemove = false;
				uncrustedSandwich.hidden = false;
				ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
				ItemAPI.Add(new CustomItem(uncrustedSandwich, val2));
			}
			if (UncrustedSandwichConfig.ReworkType.Value >= 1)
			{
				uncrustedSandwich = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/Base/FlatHealth/FlatHealth.asset").WaitForCompletion();
				using (Stream stream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream("UncrustedSandwich.uncrustedsandwich"))
				{
					AssetBundle val3 = AssetBundle.LoadFromStream(stream2);
					uncrustedSandwich.pickupModelPrefab = val3.LoadAsset<GameObject>("Assets/Import/sandwich/sandwich.prefab");
					uncrustedSandwich.pickupIconSprite = val3.LoadAsset<Sprite>("Assets/Import/sandwich_icon/uncrustable_common.png");
				}
				LanguageAPI.Add("ITEM_FLATHEALTH_PICKUP", text);
				LanguageAPI.Add("ITEM_FLATHEALTH_DESC", text);
				LanguageAPI.Add("ITEM_FLATHEALTH_NAME", text2);
				LanguageAPI.Add("ITEM_FLATHEALTH_LORE", text3);
			}
			if (UncrustedSandwichConfig.ReworkType.Value != 2)
			{
				CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(UncrustableEffect);
			}
		}

		private void UncrustableEffect(orig_OnInventoryChanged orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				int num = (Object.op_Implicit((Object)(object)self.inventory) ? self.inventory.GetItemCount(uncrustedSandwich) : 0);
				if (num <= 0)
				{
					return;
				}
				if (num == 8)
				{
					if (!self.HasBuff(Buffs.Cripple))
					{
						self.AddBuff(Buffs.Cripple);
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Cripple Added");
					}
				}
				else if (self.HasBuff(Buffs.Cripple))
				{
					self.RemoveBuff(Buffs.Cripple);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Cripple Removed");
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Uncrustable activated. Item count: {num}");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Not server, cannot apply Uncrustable rework.");
			}
		}
	}
	public static class UncrustedSandwichConfig
	{
		public static ConfigEntry<int> ReworkType { get; set; }

		public static void SetUpConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ReworkType = plugin.Config.Bind<int>("Uncrusted Sandwich", "Toggle Rework", 1, new ConfigDescription("[ 0 = Lunar | 1 = Replace Bison Steak | 2 = Replace Bison Steak w/ No Additional Effects]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
		}
	}
}