Decompiled source of JellyJamTinyMod v1.0.0

JellyJamTinyPlayerMod.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("JellyJamMadness")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JellyJamMadness")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f4957b33-0535-4113-88c1-e378a5fc3e2f")]
[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 JellyJamMadness
{
	[BepInPlugin("JellyJam.TinyMod", "JellyJamTinyMod", "1.0.0.0")]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "JellyJam.TinyMod";

		private const string modName = "JellyJamTinyMod";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("JellyJam.TinyMod");

		private static ModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("JellyJam.TinyMod");
			mls.LogInfo((object)"The JellyJamTinyMod has started");
			harmony.PatchAll();
		}
	}
}
namespace JellyJamMadness.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public class MyInputClass
	{
		[HarmonyPatch("SubmitChat_performed")]
		[HarmonyPrefix]
		public static bool SubmitChat_performed_Prefix(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			text = text.ToLower();
			if (!PlayerControllerBPatch.inTerminal && text.StartsWith("/"))
			{
				Debug.Log((object)(text + " - Input"));
				if (text.StartsWith("/size"))
				{
					if ((Object)(object)((Component)__instance.localPlayer).gameObject.AddComponent<PlayerInfoSize>() == (Object)null)
					{
						((Component)__instance.localPlayer).gameObject.AddComponent<PlayerInfoSize>();
					}
					PlayerInfoSize component = ((Component)__instance.localPlayer).gameObject.GetComponent<PlayerInfoSize>();
					component.ChangeSize();
					Debug.Log((object)"Attempting to Change Size");
					HUDManager.Instance.DisplayTip("Size Changed.", "Please note: This is currently only client side. Others will still see you as tiny", false, false, "LC_Tip1");
					__instance.localPlayer = GameNetworkManager.Instance.localPlayerController;
					__instance.localPlayer.isTypingChat = false;
					__instance.chatTextField.text = "";
					EventSystem.current.SetSelectedGameObject((GameObject)null);
					((Behaviour)__instance.typingIndicator).enabled = false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class HoardingRevamp
	{
		public class HeldInfo : MonoBehaviour
		{
			public PlayerControllerB player;

			public bool isHeld = false;

			public float canHoldTime = holdTime;

			public HoarderBugAI bug;
		}

		public class HoldingInfo : MonoBehaviour
		{
			public bool holdingPlayer = false;

			public float remainingHoldTime = holdTime;

			public PlayerControllerB playerHeld;
		}

		public static float holdTime = 12f;

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		private static void AwakeChanged(PlayerControllerB __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			((Component)__instance).gameObject.AddComponent<HeldInfo>();
			HeldInfo component = ((Component)__instance).GetComponent<HeldInfo>();
			component.player = __instance;
			Debug.Log((object)"Created Player Instance for Hoarding Bug");
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void NewUpdate(ref PlayerControllerB __instance, ref Vector3 ___serverPlayerPosition)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			HeldInfo component = ((Component)__instance).GetComponent<HeldInfo>();
			if (component.isHeld)
			{
				HoldingInfo component2 = ((Component)component.bug).gameObject.GetComponent<HoldingInfo>();
				___serverPlayerPosition = ((EnemyAI)component.bug).serverPosition;
				Vector3 val = ((EnemyAI)component.bug).serverPosition - ((Component)component).gameObject.transform.position;
				__instance.thisController.SimpleMove(val * 6f + new Vector3(0f, 0.5f, 0f));
				component.canHoldTime -= Time.deltaTime;
				if (((EnemyAI)component.bug).isEnemyDead || component.canHoldTime <= 0f || component.player.isPlayerDead)
				{
					component2.holdingPlayer = false;
					component.isHeld = false;
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		private static void OnBugCollide(HoarderBugAI __instance, Collider other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			HoldingInfo component = ((Component)__instance).gameObject.GetComponent<HoldingInfo>();
			PlayerInfoSize component2 = ((Component)__instance).gameObject.GetComponent<PlayerInfoSize>();
			if (!component.holdingPlayer && component.remainingHoldTime <= 0f && !((EnemyAI)__instance).isEnemyDead && Object.op_Implicit((Object)(object)((Component)other).GetComponent<PlayerControllerB>()))
			{
				Debug.Log((object)"PLAYER HAS BEEN PICKED UP");
				GameObject gameObject = ((Component)other).gameObject;
				HeldInfo component3 = gameObject.GetComponent<HeldInfo>();
				component3.isHeld = true;
				component.remainingHoldTime = holdTime;
				component3.canHoldTime = holdTime;
				component3.bug = __instance;
				component.holdingPlayer = true;
				component.playerHeld = gameObject.GetComponent<PlayerControllerB>();
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		private static void OnStart(HoarderBugAI __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((Component)__instance).gameObject.AddComponent<HoldingInfo>();
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Update")]
		[HarmonyPostfix]
		private static void UpdateBug(HoarderBugAI __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			HoldingInfo component = ((Component)__instance).GetComponent<HoldingInfo>();
			if (component.holdingPlayer)
			{
				HeldInfo component2 = ((Component)component.playerHeld).GetComponent<HeldInfo>();
				__instance.angryTimer = 1f;
				__instance.angryAtPlayer = null;
				if (((EnemyAI)__instance).isEnemyDead)
				{
					component.holdingPlayer = false;
					component2.isHeld = false;
				}
			}
			else
			{
				component.remainingHoldTime -= Time.deltaTime;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		public static Vector3 savedPos = Vector3.zero;

		public static GameObject managerObject;

		public static Vector3 visorScale;

		public static GameObject player;

		public static bool inTerminal;

		public static bool isStarting = true;

		public static PlayerInfoSize infoScript;

		public static Rigidbody playerRigidbody;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePatch(ref float ___sprintMeter, ref Transform ___thisPlayerBody, ref float ___movementSpeed, ref float ___jumpForce, ref float ___grabDistance, ref Transform ___localVisor, PlayerControllerB __instance, ref bool ___inTerminalMenu, ref bool ___isPlayerDead)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (isStarting)
			{
				if ((Object)(object)player == (Object)null)
				{
					player = ((Component)___thisPlayerBody).gameObject;
				}
				Debug.Log((object)"Starting the Tiny Mod...");
				infoScript.baseGrab = ___grabDistance;
				infoScript.baseJump = ___jumpForce;
				infoScript.baseSize = 1f;
				infoScript.baseSpeed = ___movementSpeed;
				isStarting = false;
			}
			inTerminal = ___inTerminalMenu;
			((Component)__instance.localVisor).gameObject.SetActive(false);
			if (___inTerminalMenu)
			{
				___thisPlayerBody.localScale = new Vector3(1f, 1f, 1f);
			}
			else
			{
				PlayerInfoSize component = ((Component)__instance).gameObject.GetComponent<PlayerInfoSize>();
				component.UpdateSize();
			}
			if (infoScript.isSmall)
			{
				playerRigidbody.AddForce(Physics.gravity * 0.75f, (ForceMode)5);
			}
			if (infoScript.spawnTimer >= 0f && !___isPlayerDead)
			{
				infoScript.spawnTimer -= Time.deltaTime;
				infoScript.UpdateSize();
			}
			if (___isPlayerDead && infoScript.spawnTimer != 5f)
			{
				infoScript.spawnTimer = 5f;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void NewStart(ref float ___sprintMeter, ref Transform ___thisPlayerBody, ref float ___movementSpeed, ref float ___jumpForce, ref float ___grabDistance, ref Transform ___localVisor, PlayerControllerB __instance, ref bool ___inTerminalMenu, ref Rigidbody ___playerRigidbody)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)__instance).gameObject.AddComponent<PlayerInfoSize>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<PlayerInfoSize>();
			}
			if ((Object)(object)player == (Object)null)
			{
				player = ((Component)___thisPlayerBody).gameObject;
			}
			infoScript = ((Component)__instance).gameObject.GetComponent<PlayerInfoSize>();
			playerRigidbody = player.GetComponent<Rigidbody>();
			infoScript.IsSmall(_isSmall: true);
			infoScript.spawnTimer = 5f;
			player.transform.localScale = new Vector3(1f, 1f, 1f);
			HUDManager.Instance.DisplayTip("JellyJam Tiny Mod:", "Do /size to toggle being small!", false, false, "LC_Tip1");
		}
	}
	public class PlayerInfoSize : MonoBehaviour
	{
		public bool isSmall = true;

		public float baseSpeed;

		public float baseJump;

		public float baseSize;

		public float baseGrab;

		private bool hasSetStats = false;

		public float spawnTimer = 1.5f;

		public void ChangeSize()
		{
			GameObject gameObject = ((Component)this).gameObject;
			PlayerControllerB component = gameObject.GetComponent<PlayerControllerB>();
			isSmall = !isSmall;
			UpdateSize();
		}

		public void IsSmall(bool _isSmall)
		{
			isSmall = _isSmall;
			UpdateSize();
		}

		public void UpdateSize()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)this).gameObject;
			PlayerControllerB component = gameObject.GetComponent<PlayerControllerB>();
			Rigidbody component2 = gameObject.GetComponent<Rigidbody>();
			if (!(spawnTimer > 0f))
			{
				if (!hasSetStats)
				{
					baseSpeed = component.movementSpeed;
					baseJump = component.jumpForce;
					baseSize = 1f;
					baseGrab = component.grabDistance;
					hasSetStats = true;
				}
				if (isSmall)
				{
					gameObject.transform.localScale = new Vector3(0.33f, 0.33f, 0.33f);
					component.movementSpeed = 2.7f;
					component.jumpForce = 8f;
					component.grabDistance = 1f;
					component2.useGravity = false;
				}
				else
				{
					gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
					component.movementSpeed = baseSpeed;
					component.jumpForce = baseJump;
					component.grabDistance = baseGrab;
					component2.useGravity = true;
				}
			}
		}
	}
}