Decompiled source of Tiny Company v1.0.4

JellyJamTinyPlayerMod.dll

Decompiled 3 months 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.3.0")]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "JellyJam.TinyMod";

		private const string modName = "JellyJamTinyMod";

		private const string modVersion = "1.0.3.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
	{
		public static void EndChat(HUDManager __instance)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			__instance.localPlayer = GameNetworkManager.Instance.localPlayerController;
			__instance.localPlayer.isTypingChat = false;
			PlayerInfoSize component = ((Component)__instance.localPlayer).GetComponent<PlayerInfoSize>();
			__instance.chatTextField.text = "";
			EventSystem.current.SetSelectedGameObject((GameObject)null);
			((Behaviour)__instance.typingIndicator).enabled = false;
			Debug.Log((object)("IsSmall = " + component.GetSize()));
			Debug.Log((object)("Player Size: " + ((Component)__instance).gameObject.transform.localScale.y));
			Debug.Log((object)("Using Small Speed: " + component.useSmallSpeed));
		}

		[HarmonyPatch("SubmitChat_performed")]
		[HarmonyPrefix]
		public static bool SubmitChat_performed_Prefix(HUDManager __instance)
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			string text = __instance.chatTextField.text;
			text = text.ToLower();
			if (!PlayerControllerBPatch.inTerminal && text.StartsWith("/"))
			{
				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>();
				PlayerControllerB component2 = ((Component)__instance.localPlayer).GetComponent<PlayerControllerB>();
				Debug.Log((object)(text + " - Input"));
				if (text.StartsWith("/size"))
				{
					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");
					EndChat(__instance);
				}
				if (text.StartsWith("/speed"))
				{
					component.useSmallSpeed = !component.useSmallSpeed;
					component.UpdateSize();
					Debug.Log((object)"Attempting to Change Speed");
					if (component.useSmallSpeed)
					{
						HUDManager.Instance.DisplayTip("Stats Changed", "You now use the Tiny modifiers when Tiny", false, false, "LC_Tip1");
					}
					else
					{
						HUDManager.Instance.DisplayTip("Stats Changed", "You now use the normal modifiers when Tiny", false, false, "LC_Tip1");
					}
					EndChat(__instance);
				}
				if (text.StartsWith("/stuck"))
				{
					StartOfRound component3 = ((Component)Object.FindObjectOfType<StartOfRound>()).GetComponent<StartOfRound>();
					if (component2.isInHangarShipRoom)
					{
						component2.TeleportPlayer(component3.playerSpawnPositions[1].position + new Vector3(0f, 1f, 0f), false, 0f, false, true);
						component2.ResetFallGravity();
						HUDManager.Instance.DisplayTip("Unstuck the player", "Moved the player to spawn", false, false, "LC_Tip1");
					}
					else
					{
						HUDManager.Instance.DisplayTip("Unstuck failed.", "Only works while in ship", false, false, "LC_Tip1");
					}
					EndChat(__instance);
				}
			}
			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 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (isStarting)
			{
				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);
				Debug.Log((object)"IN TERMINAL");
			}
			else
			{
				PlayerInfoSize component = ((Component)__instance).gameObject.GetComponent<PlayerInfoSize>();
				component.UpdateSize();
			}
			if (infoScript.GetSize())
			{
				playerRigidbody.AddForce(Physics.gravity * 0.75f, (ForceMode)5);
			}
		}

		[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)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<PlayerInfoSize>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<PlayerInfoSize>();
			}
			GameObject gameObject = ((Component)___thisPlayerBody).gameObject;
			infoScript = ((Component)__instance).gameObject.GetComponent<PlayerInfoSize>();
			playerRigidbody = gameObject.GetComponent<Rigidbody>();
			infoScript.IsSmall(_isSmall: true);
			HUDManager.Instance.DisplayTip("JellyJam Tiny Mod:", "Do /size to toggle being small!", false, false, "LC_Tip1");
		}
	}
	public class PlayerInfoSize : MonoBehaviour
	{
		private bool isSmall = true;

		public bool useSmallSpeed = true;

		public float baseSpeed;

		public float baseJump;

		public float baseSize;

		public float baseGrab;

		private bool hasSetStats = false;

		public PlayerControllerB playerScript;

		public Rigidbody rb;

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

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

		public bool GetSize()
		{
			return isSmall;
		}

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