Decompiled source of Slop Sign v1.1.3

SlopSign.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RemoveLevelBadge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoveLevelBadge")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9a54c138-13be-4664-851d-92c9ee1cc204")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SlopSign;

[BepInPlugin("ironbean.SlopSign", "Slop Sign", "1.1.3")]
public class SlopSignBase : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class SlopPatch
	{
		[HarmonyPatch("SetScrapValue")]
		[HarmonyPostfix]
		private static void CreatePatch(GrabbableObject __instance)
		{
			bool flag = ((Object)__instance.itemProperties).name == "StopSign";
			bool flag2 = ((Object)__instance.itemProperties).name == "YieldSign";
			if (!flag2 && !flag)
			{
				return;
			}
			string text = "Slop";
			Material material = slopSignMat;
			if (flag2)
			{
				int num = __instance.scrapValue % 4;
				text = yieldSignNames[num];
				material = yieldSignMats[num];
			}
			MeshRenderer componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				ScanNodeProperties componentInChildren2 = ((Component)componentInChildren).GetComponentInChildren<ScanNodeProperties>();
				if (!((Object)(object)componentInChildren2 == (Object)null))
				{
					componentInChildren2.headerText = text + " sign";
					((Renderer)componentInChildren).material = material;
				}
			}
		}
	}

	private const string modGUID = "ironbean.SlopSign";

	private const string modName = "Slop Sign";

	private const string modVersion = "1.1.3";

	private readonly Harmony harmony = new Harmony("ironbean.SlopSign");

	private static SlopSignBase Instance;

	internal static ManualLogSource mls;

	private static Material slopSignMat;

	private static readonly string[] yieldSignNames = new string[4] { "Piss", "Yeet", "Cum", "Ye old" };

	private static List<Material> yieldSignMats = new List<Material>();

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ironbean.SlopSign");
		mls.LogInfo((object)"THE SLOP!");
		AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "slopsign"));
		slopSignMat = val.LoadAsset<Material>("Assets/ModelTextures/SlopSignMat.mat");
		for (int i = 1; i <= 4; i++)
		{
			yieldSignMats.Add(val.LoadAsset<Material>("Assets/ModelTextures/YieldSignMat" + i + ".mat"));
		}
		mls.LogInfo((object)("Got " + yieldSignMats.Count + " materials."));
		harmony.PatchAll(typeof(SlopSignBase));
		harmony.PatchAll(typeof(SlopPatch));
	}
}