Decompiled source of GoopToGlorp v1.0.0

GoopToGlorp.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Notifications;
using Player;
using Player.Visuals;
using Store;
using UnityEngine;
using WallyBox;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GoopToGlorp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GoopToGlorp")]
[assembly: AssemblyTitle("GoopToGlorp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GoopToGlorp;

[BepInPlugin("com.gooptoglorp.roadsideresearch", "GoopToGlorp", "1.0.0")]
public class Plugin : BasePlugin
{
	public const string GUID = "com.gooptoglorp.roadsideresearch";

	public const string Name = "GoopToGlorp";

	public const string Version = "1.0.0";

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> EnableTextReplacement;

	internal static ConfigEntry<bool> EnableProximityAlerts;

	internal static ConfigEntry<float> GlorpIntimacyRadius;

	internal static ConfigEntry<float> ProximityCooldown;

	internal static ConfigEntry<bool> EnableGlorpOnCommand;

	internal static ConfigEntry<KeyCode> GlorpKey;

	internal static ConfigEntry<float> GlorpCooldown;

	internal static ConfigEntry<bool> RenameCustomers;

	internal static float LastProximityAlert = -999f;

	private static readonly string[] ProximityMessages = new string[11]
	{
		"Two glorps touching! That's... rare. And beautiful.", "Oh my. Those glorps are VERY close together.", "When two glorps love each other very much...", "Double glorp detected. Scientists say this is 'normal'.", "Those glorps need to get a room.", "Intimate glorp proximity detected. Look away.", "Two glorps, one spot. Nature is healing.", "Glorps in close formation! A once-in-a-lifetime event. Probably.", "Scandalous! Two glorps found in a compromising position.", "Congratulations, you've witnessed a rare glorp rendezvous.",
		"Those glorps are practically on top of each other. No comment."
	};

	private static readonly Random Rng = new Random();

	private static readonly (string original, string replacement)[] PhraseRewrites = new(string, string)[14]
	{
		("One of you just gooped all over the floor! This happens with Aliens regularly and it's a lot of fun!", "One of you just glorped all over the floor! It just... comes out sometimes. Don't be embarrassed, it happens to all of us. Frequently. Some say it feels amazing."),
		("Humans find it nasty, so clean it up quickly otherwise they will get", "Humans wouldn't understand the pleasure of a good glorp, so mop up the evidence before they get"),
		("Alright goopy heads", "Alright you sloppy glorpers"),
		("we watch every goop you make!", "we see every glorp you release! Every. Single. One."),
		("Of all the goopers we’ve sent", "Of all the dirty little glorpers we’ve sent"),
		("Of all the goopers we've sent", "Of all the dirty little glorpers we've sent"),
		("Do you goop brainers have any idea", "Do you glorp-for-brains have any idea"),
		("goop on the reputation of us", "glorp all over the good name of us"),
		("my little gooper", "my dirty little glorper"),
		("sucks up goop and turns it into energy drinks. Drink it!", "sucks up glorp and turns it into energy drinks. Put it in your mouth! It's delicious, we promise."),
		("Humans love plant goop", "Humans love plant glorp. They put it on everything. Honestly, we get it"),
		("left by humans and goop", "left behind by humans and... intimate glorp deposits"),
		("gooping instead of eating garbage", "glorping freely instead of eating garbage. Glorping is natural and beautiful"),
		("cookin' with goop", "gettin' glorpy with it")
	};

	public override void Load()
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Expected O, but got Unknown
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BasePlugin)this).Log;
		EnableTextReplacement = ((BasePlugin)this).Config.Bind<bool>("Text", "EnableTextReplacement", true, "Replace all instances of 'goop' with 'glorp' in game text");
		RenameCustomers = ((BasePlugin)this).Config.Bind<bool>("Text", "RenameCustomers", true, "Replace 'customer' with 'glorper' in game text");
		EnableProximityAlerts = ((BasePlugin)this).Config.Bind<bool>("Proximity", "EnableProximityAlerts", true, "Show notifications when two glorps land near each other");
		GlorpIntimacyRadius = ((BasePlugin)this).Config.Bind<float>("Proximity", "IntimacyRadius", 2.5f, new ConfigDescription("How close two glorps need to be to trigger a proximity alert (meters)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
		ProximityCooldown = ((BasePlugin)this).Config.Bind<float>("Proximity", "AlertCooldown", 15f, new ConfigDescription("Seconds between proximity alert notifications", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>()));
		EnableGlorpOnCommand = ((BasePlugin)this).Config.Bind<bool>("OnDemand", "EnableGlorpOnCommand", true, "Allow manual glorping with a keybind");
		GlorpKey = ((BasePlugin)this).Config.Bind<KeyCode>("OnDemand", "GlorpKey", (KeyCode)103, "Key to press for on-demand glorping");
		GlorpCooldown = ((BasePlugin)this).Config.Bind<float>("OnDemand", "GlorpCooldown", 1f, new ConfigDescription("Seconds between manual glorps", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 30f), Array.Empty<object>()));
		Log.LogInfo((object)"GoopToGlorp loaded. The glorpening has begun.");
		Harmony val = new Harmony("com.gooptoglorp.roadsideresearch");
		val.PatchAll(typeof(TMP_TextPatch));
		val.PatchAll(typeof(UITextPatch));
		val.PatchAll(typeof(GlorpProximityPatch));
		((BasePlugin)this).AddComponent<GlorpOnCommand>();
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(104, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("All patches applied. Press ");
			((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<KeyCode>(GlorpKey.Value);
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to glorp on command. Every orifice— I mean, every UI element is now glorped.");
		}
		log.LogInfo(val2);
	}

	internal static string Glorpify(string text)
	{
		if (text == null)
		{
			return text;
		}
		if (!EnableTextReplacement.Value && !RenameCustomers.Value)
		{
			return text;
		}
		bool flag = EnableTextReplacement.Value && text.IndexOf("goop", StringComparison.OrdinalIgnoreCase) >= 0;
		bool flag2 = RenameCustomers.Value && text.IndexOf("customer", StringComparison.OrdinalIgnoreCase) >= 0;
		if (!flag && !flag2)
		{
			return text;
		}
		if (flag)
		{
			(string, string)[] phraseRewrites = PhraseRewrites;
			for (int i = 0; i < phraseRewrites.Length; i++)
			{
				var (text2, newValue) = phraseRewrites[i];
				if (text.Contains(text2))
				{
					text = text.Replace(text2, newValue);
				}
			}
			text = text.Replace("GOOP", "GLORP");
			text = text.Replace("Goop", "Glorp");
			text = text.Replace("goop", "glorp");
		}
		if (flag2)
		{
			text = text.Replace("CUSTOMERS", "GLORPERS");
			text = text.Replace("Customers", "Glorpers");
			text = text.Replace("customers", "glorpers");
			text = text.Replace("CUSTOMER", "GLORPER");
			text = text.Replace("Customer", "Glorper");
			text = text.Replace("customer", "glorper");
		}
		return text;
	}

	internal static void CheckGlorpProximity(Vector3 freshGlorpPosition)
	{
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Invalid comparison between Unknown and I4
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		if (!EnableProximityAlerts.Value || Time.time - LastProximityAlert < ProximityCooldown.Value)
		{
			return;
		}
		bool flag = default(bool);
		try
		{
			DirtManager instance = SingletonNetworkBehaviour<DirtManager>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			HashSet<DirtStain> value = Traverse.Create((object)instance).Field("_activeStains").GetValue<HashSet<DirtStain>>();
			if (value == null)
			{
				return;
			}
			foreach (DirtStain item in value)
			{
				if ((Object)(object)item == (Object)null || (int)item.StainType != 1)
				{
					continue;
				}
				float num = Vector3.Distance(((Component)item).transform.position, freshGlorpPosition);
				if (num > 0.01f && num < GlorpIntimacyRadius.Value)
				{
					LastProximityAlert = Time.time;
					string text = ProximityMessages[Rng.Next(ProximityMessages.Length)];
					NotificationsManager.QueueNotification(text, false, 5f);
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Glorp proximity event! Distance: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F2");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m — ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					}
					log.LogInfo(val);
					break;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Log;
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Glorp proximity check got stage fright: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log2.LogWarning(val2);
		}
	}
}
[HarmonyPatch]
public static class TMP_TextPatch
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPrefix]
	public static void SetTextPrefix(ref string value)
	{
		value = Plugin.Glorpify(value);
	}
}
[HarmonyPatch]
public static class UITextPatch
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPrefix]
	public static void SetTextPrefix(ref string value)
	{
		value = Plugin.Glorpify(value);
	}
}
public class GlorpOnCommand : MonoBehaviour
{
	private float _lastGlorpTime = -999f;

	private void Update()
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.EnableGlorpOnCommand.Value || !Input.GetKeyDown(Plugin.GlorpKey.Value) || Time.time - _lastGlorpTime < Plugin.GlorpCooldown.Value)
		{
			return;
		}
		try
		{
			PlayerInfo localPlayer = PlayerInfo.LocalPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				Goopspawner componentInChildren = ((Component)localPlayer).GetComponentInChildren<Goopspawner>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					short skinID = CustomizationManager.SkinID;
					Vector3 position = ((Component)localPlayer).transform.position;
					componentInChildren.SpawnExternalGoop(position, skinID);
					_lastGlorpTime = Time.time;
					Plugin.Log.LogInfo((object)"Manual glorp deposited. Hope that felt good.");
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to glorp on command (performance anxiety): ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
	}
}
[HarmonyPatch]
public static class GlorpProximityPatch
{
	[HarmonyPatch(typeof(DirtManager), "RpcSpawnStain")]
	[HarmonyPostfix]
	public static void OnGlorpDeposited(Vector3 position, StainType stainType)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		if ((int)stainType == 1 && Plugin.EnableProximityAlerts.Value)
		{
			Plugin.CheckGlorpProximity(position);
		}
	}
}