Decompiled source of MiscFixes v0.6.4

MinorTweaks.dll

Decompiled 2 months ago
using System;
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 MinorTweaks.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MinorTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MinorTweaks")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("72d79f23-dad1-4fea-ad13-acd9a2f9fee7")]
[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 MinorTweaks
{
	[BepInPlugin("ironbean.MinorTweaks", "Minor Tweaks", "1.4.0")]
	public class MinorTweaks : BaseUnityPlugin
	{
		private const string modGUID = "ironbean.MinorTweaks";

		private const string modName = "Minor Tweaks";

		private const string modVersion = "1.4.0";

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

		internal static MinorTweaks Instance;

		internal static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("ironbean.MinorTweaks");
			mls.LogInfo((object)" hello!  o/");
			harmony.PatchAll(typeof(MinorTweaks));
			harmony.PatchAll(typeof(LandmineCollision));
			harmony.PatchAll(typeof(TVRemote));
			harmony.PatchAll(typeof(WolfKiller));
			harmony.PatchAll(typeof(WeedRemover));
			harmony.PatchAll(typeof(InverseCooldownRemover));
			harmony.PatchAll(typeof(TerminalHotSwitcher));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(CruiserVolume));
		}
	}
}
namespace MinorTweaks.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class MeteorChance
	{
		private static int daysWithoutMeteor;

		[HarmonyPatch("DecideRandomDayEvents")]
		[HarmonyPostfix]
		public static void OverwriteMeteorChance(TimeOfDay __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				Random random = new Random(StartOfRound.Instance.randomMapSeed + 28);
				float num = -0.4f + (float)Math.Pow(0.85, -daysWithoutMeteor);
				if ((float)random.Next(0, 100) < num)
				{
					daysWithoutMeteor = 0;
					__instance.meteorShowerAtTime = (float)random.Next(5, 80) / 100f;
				}
				else
				{
					daysWithoutMeteor++;
					__instance.meteorShowerAtTime = -1f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(VehicleController))]
	internal class CruiserVolume
	{
		private static float lastTimeValue = -1f;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CruiserUpdate(VehicleController __instance, ref bool ___radioOn)
		{
			__instance.radioAudio.volume = 0.2f;
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			if (__instance.carDestroyed || !__instance.ignitionStarted)
			{
				if (___radioOn)
				{
					__instance.SwitchRadio();
				}
				return;
			}
			if (lastTimeValue > __instance.radioAudio.time && ___radioOn)
			{
				__instance.ChangeRadioStation();
			}
			lastTimeValue = __instance.radioAudio.time;
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class InverseCooldownRemover
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void SetCooldown(ref float ___cooldownAmount)
		{
			___cooldownAmount = 10f;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void DropItemButton(PlayerControllerB __instance)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance) && !__instance.isTypingChat && !__instance.inTerminalMenu && !__instance.quickMenuManager.isMenuOpen && !__instance.isGrabbingObjectAnimation && ((ButtonControl)Keyboard.current[(Key)22]).wasPressedThisFrame)
			{
				__instance.DropAllHeldItemsAndSync();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalHotSwitcher
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Switch(Terminal __instance)
		{
			if (!(GameNetworkManager.Instance?.localPlayerController?.inTerminalMenu).GetValueOrDefault())
			{
				return;
			}
			bool wasPressedThisFrame = ((ButtonControl)Keyboard.current[(Key)63]).wasPressedThisFrame;
			bool wasPressedThisFrame2 = ((ButtonControl)Keyboard.current[(Key)62]).wasPressedThisFrame;
			bool wasPressedThisFrame3 = ((ButtonControl)Keyboard.current[(Key)64]).wasPressedThisFrame;
			bool wasPressedThisFrame4 = ((ButtonControl)Keyboard.current[(Key)61]).wasPressedThisFrame;
			if (!(wasPressedThisFrame4 || wasPressedThisFrame2))
			{
				return;
			}
			ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
			int targetTransformIndex = mapScreen.targetTransformIndex;
			int num = targetTransformIndex;
			PlayerControllerB component;
			do
			{
				num += ((!wasPressedThisFrame4) ? 1 : (-1));
				if (num < 0)
				{
					num = mapScreen.radarTargets.Count - 1;
				}
				else if (num >= mapScreen.radarTargets.Count)
				{
					num = 0;
				}
				component = ((Component)mapScreen.radarTargets[num].transform).gameObject.GetComponent<PlayerControllerB>();
			}
			while ((Object)(object)component != (Object)null && !component.isPlayerControlled && !component.isPlayerDead && (Object)(object)component.redirectToEnemy == (Object)null && num != targetTransformIndex);
			if (num != targetTransformIndex)
			{
				mapScreen.SwitchRadarTargetAndSync(num);
				__instance.LoadNewNode(__instance.terminalNodes.specialNodes[20]);
			}
		}
	}
	[HarmonyPatch(typeof(MoldSpreadManager))]
	internal class WeedRemover
	{
		[HarmonyPatch("GenerateMold")]
		[HarmonyPostfix]
		private static void ICalledTheWeedMan(MoldSpreadManager __instance)
		{
			__instance.RemoveAllMold();
		}
	}
	[HarmonyPatch(typeof(BushWolfEnemy))]
	internal class WolfKiller
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void KillThem(BushWolfEnemy __instance)
		{
			((EnemyAI)__instance).KillEnemy(true);
		}
	}
	[HarmonyPatch(typeof(WhoopieCushionItem))]
	internal class UsableWhoopieCushion
	{
		[HarmonyPatch("ItemInteractLeftRightOnClient")]
		[HarmonyPostfix]
		private static void UseWhoopieCushion(ref WhoopieCushionItem __instance)
		{
			__instance.Fart();
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandmineCollision
	{
		[HarmonyPatch("ExplodeMineClientRpc")]
		[HarmonyPostfix]
		private static void disableLandmineCollision(Landmine __instance)
		{
			SphereCollider componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<SphereCollider>();
			if (!((Object)(object)componentInChildren == (Object)null) && __instance.hasExploded)
			{
				((Collider)componentInChildren).enabled = false;
			}
		}
	}
	[HarmonyPatch(typeof(RemoteProp))]
	internal class TVRemote
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPostfix]
		private static void ToggleTV(ref RemoteProp __instance)
		{
			((GrabbableObject)__instance).useCooldown = 0.2f;
			Object.FindObjectOfType<ShipLights>().ToggleShipLightsOnLocalClientOnly();
			if (((NetworkBehaviour)__instance).IsServer)
			{
				TVScript val = Object.FindObjectOfType<TVScript>();
				if (!((Object)(object)val == (Object)null))
				{
					val.SwitchTVLocalClient();
				}
			}
		}
	}
}

MiscFixes.dll

Decompiled 2 months ago
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("MiscFixes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MiscFixes")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("98be442a-a76a-4dc3-85e9-2f75678caf32")]
[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 MiscFixes;

[BepInPlugin("ironbean.MiscFixes", "Misc Fixes", "0.3.0")]
public class MiscFixesBase : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GenericPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CreatePatch(GrabbableObject __instance)
		{
			if (((Object)__instance.itemProperties).name == "Clipboard")
			{
				SkinnedMeshRenderer componentInChildren = ((Component)((Component)__instance).transform.Find("Plane")).GetComponentInChildren<SkinnedMeshRenderer>();
				SkinnedMeshRenderer componentInChildren2 = ((Component)((Component)__instance).transform.Find("Plane.003")).GetComponentInChildren<SkinnedMeshRenderer>();
				if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren2 == (Object)null)
				{
					return;
				}
				((Renderer)componentInChildren).material.mainTexture = (Texture)(object)petitionTex;
				((Renderer)componentInChildren2).material.mainTexture = (Texture)(object)clipTex;
			}
			if (((Object)__instance.itemProperties).name == "StickyNote")
			{
				MeshRenderer componentInChildren3 = ((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
				if (!((Object)(object)componentInChildren3 == (Object)null))
				{
					((Renderer)componentInChildren3).material.mainTexture = (Texture)(object)cheeseTex;
					__instance.itemProperties.itemName = "Cheese";
				}
			}
		}
	}

	private const string modGUID = "ironbean.MiscFixes";

	private const string modName = "Misc Fixes";

	private const string modVersion = "0.3.0";

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

	private static MiscFixesBase Instance;

	internal static ManualLogSource mls;

	private static Texture2D clipTex;

	private static Texture2D petitionTex;

	private static Texture2D cheeseTex;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ironbean.MiscFixes");
		mls.LogInfo((object)"THE MISC!");
		AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "misctex"));
		clipTex = val.LoadAsset<Texture2D>("Assets/MiscTextures/clipboard.png");
		petitionTex = val.LoadAsset<Texture2D>("Assets/MiscTextures/petition.png");
		cheeseTex = val.LoadAsset<Texture2D>("Assets/MiscTextures/cheese.png");
		harmony.PatchAll(typeof(MiscFixesBase));
		harmony.PatchAll(typeof(GenericPatch));
	}
}