Decompiled source of AntsMod v1.3.0

AntsMod.dll

Decompiled 3 weeks ago
using System.Collections;
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 AntsMod.Config;
using AntsMod.Coroutines;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AntsMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("AntsMod")]
[assembly: AssemblyCopyright("Copyright © HP 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5ef7ae0-29a6-411a-b796-2d42321f7f63")]
[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 AntsMod
{
	[BepInPlugin("AntAptive.AntsMod", "Ant's Mod", "1.3.0")]
	public class AntsModBase : BaseUnityPlugin
	{
		private const string modGUID = "AntAptive.AntsMod";

		private const string modName = "Ant's Mod";

		private const string modVersion = "1.3.0";

		private readonly Harmony harmony = new Harmony("AntAptive.AntsMod");

		private static AntsModBase Instance;

		internal ManualLogSource mls;

		public static AssetBundle MyCustomAssets;

		public static ModConfig BoundConfig { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("AntAptive.AntsMod");
			BoundConfig = new ModConfig(((BaseUnityPlugin)this).Config);
			mls.LogInfo((object)"\n                                                                                          \r\n                .............                                .............                \r\n            .....@@@@@@@@@@@.......                    ........@@@@@@@.........           \r\n        ....@@@@@@@@@@@@@@@@@@@@@@.....            ......@@@@@@@@@@@@@............        \r\n      ...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...        ...@@@@@@@@@@@@@@@@@@@@@@@@@@@.....      \r\n     ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...    ...@@@..............@@............@@..     \r\n    ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... ..@@@................................@..    \r\n   ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@........@........................@........@..   \r\n   .@@@@@@@@@@@@@@@@.@@@@@@@@@@@@@@@@@@@@.........@@............@@@....@@..@@.......@@.   \r\n  ..@@@@@@@@@@@@@@@....@@@@@.@@@@@@@@@@@@.........@@............@@@@.....@.........@....  \r\n  ..@@@@@@@@@@@@@@@@@@@@@@@@@..@@@@@@@@@...........@..........@@@@@@@.....@........@....  \r\n  ..@@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@@.........................@@@................@@@..  \r\n  ..@@@@@@@@@@@@@@@@@@@@@@@@@..@@@@@@@@.................................................  \r\n  ..@@@@@@@.....@@@@@@@@@@@@@@@@@@@@@@@.................................................  \r\n   ..@@@@@........@@@@@@@@@@@...@@@@@@@................................................   \r\n   ..@@@@......................@@@@@@@@................................................   \r\n   ..@@@@@@.............@@@@@@@@@@@@@@@@@..............................................   \r\n   ...@@@@@@@@@.......@@@@@@@@@@@@@@@@@@@@@@@@.........................................   \r\n    ..@@@@@@@@@......@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....................................    \r\n     ..@@@@@@@@@...@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@.................................     \r\n     ...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....................     \r\n      ...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...............      \r\n        ..@@@@@@@.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..........@@@@@@@............        \r\n         ....@@....@@@@@@@@@@@@@@@@@@@@@@@@......................@@@@@@..........         \r\n           ........@@@@@@@@@@@@@@@@@@@@@..........................@@@@.........           \r\n              ......@@@@@@@@@@@@@@@@@................................@......              \r\n                 .....@@@@@@@@@@@@@@@@@@.................................                 \r\n                    ....@@@@@@@@@@@@@@@@..............................                    \r\n                       .....@@@@@@@@@@@............................                       \r\n                          ....@@@@@@............................                          \r\n                             ................................                             \r\n                                ...........................                               \r\n                                  ......................                                  \r\n                                    ..................                                    \r\n                                      ..............                                      \r\n                                       ............                                       \r\n                                         ........                                         \r\n                                          ......                                          \r\n                                           ....                                           \r\n                                            ..                                            \r\n                                                                                          ");
			mls.LogInfo((object)"Ant's Mod has awaketh!");
			mls.LogWarning((object)"Note: This is a personal mod by AntAptive for his friends! You probably won't find anything of significance here. Thanks for downloading anyways!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			MyCustomAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "antsmod"));
			if ((Object)(object)MyCustomAssets == (Object)null)
			{
				mls.LogError((object)"[Ant's Mod] Failed to load custom assets :sadge:");
			}
			else
			{
				harmony.PatchAll();
			}
		}
	}
}
namespace AntsMod.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class FlowermanPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ModelAndSoundPatch(FlowermanAI __instance)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (AntsModBase.BoundConfig.buddyBrackenEnabled.Value)
			{
				GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel/AnimContainer/metarig/Torso1/Torso2/Torso3/Neck1")).gameObject;
				GameObject val = Object.Instantiate<GameObject>(AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<GameObject>("assets/AntsMod/Bracken/buddyboy.fbx")[0]);
				val.transform.SetParent(gameObject.transform);
				val.transform.localPosition = new Vector3(0f, 1.8f, -0.085f);
				val.transform.localScale = new Vector3(0.78787f, 0.78787f, 0.78787f);
				((Component)val.transform.Find("BuddyMask")).GetComponent<Renderer>().material = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<Material>("assets/AntsMod/Bracken/buddyboyMat.mat")[0];
				((Component)val.transform.Find("Eyes")).GetComponent<Renderer>().material = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<Material>("assets/AntsMod/Bracken/buddyboyEyesMat.mat")[0];
				__instance.creatureAngerVoice.clip = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<AudioClip>("assets/AntsMod/Bracken/buddyboyDying.mp3")[0];
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal class ForestGiantPatch
	{
		private static GenoBurp genoBurp = new GenoBurp();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void AddCustomSoundPatch(ForestGiantAI __instance)
		{
			if (AntsModBase.BoundConfig.genoBurpEnabled.Value)
			{
				GameObject gameObject = ((Component)((Component)__instance).transform.Find("FGiantModelContainer/FarWideSFX")).gameObject;
				GameObject val = Object.Instantiate<GameObject>(gameObject);
				((Object)val).name = "GenoBurp";
				val.transform.parent = ((Component)((Component)__instance).transform.Find("FGiantModelContainer")).transform;
				AudioSource component = val.GetComponent<AudioSource>();
				component.playOnAwake = false;
				component.loop = false;
				component.clip = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<AudioClip>("assets/AntsMod/Common/GenoBurp.mp3")[0];
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void GenoBurpPatch(ForestGiantAI __instance)
		{
			if (AntsModBase.BoundConfig.genoBurpEnabled.Value && Traverse.Create((object)__instance).Field("inEatingPlayerAnimation").GetValue<bool>())
			{
				Debug.LogWarning((object)"ISEATINGPLAYER IS TRUE!");
				if (genoBurp.canPlayGenoBurp)
				{
					genoBurp.canPlayGenoBurp = false;
					((MonoBehaviour)__instance).StartCoroutine(genoBurp.WaitToPlayGenoBurpSound(__instance));
				}
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void FaceImagePatch(HoarderBugAI __instance)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if (AntsModBase.BoundConfig.antBugEnabled.Value)
			{
				GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel/AnimContainer/Armature/Abdomen/Chest/Head")).gameObject;
				GameObject val = Object.Instantiate<GameObject>(AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<GameObject>("assets/AntsMod/HoarderBug/AntLuvsYewFace.prefab")[0]);
				GameObject val2 = Object.Instantiate<GameObject>(AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<GameObject>("assets/AntsMod/HoarderBug/AntLuvsYewMadFace.prefab")[0]);
				val.transform.parent = gameObject.transform;
				val2.transform.parent = gameObject.transform;
				Vector3 localPosition = default(Vector3);
				((Vector3)(ref localPosition))..ctor(-1.636f, 1.636f, 0f);
				Quaternion localRotation = Quaternion.Euler(new Vector3(40f, -270f, 0f));
				Vector3 localScale = default(Vector3);
				((Vector3)(ref localScale))..ctor(0.5f, 0.5f, 0.5f);
				val.transform.localPosition = localPosition;
				val.transform.localRotation = localRotation;
				val.transform.localScale = localScale;
				val2.transform.localPosition = localPosition;
				val2.transform.localRotation = localRotation;
				val2.transform.localScale = localScale;
				((Object)val).name = "AntLuvsYewFace";
				((Object)val2).name = "AntLuvsYewMadFace";
				val2.SetActive(false);
				__instance.bugFlySFX = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<AudioClip>("assets/AntsMod/HoarderBug/panic.mp3")[0];
				__instance.angryVoiceSFX = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<AudioClip>("assets/AntsMod/HoarderBug/antSquee.mp3")[0];
				__instance.angryScreechSFX = AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<AudioClip>("assets/AntsMod/HoarderBug/antSquee.mp3");
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void MadFacePatch(HoarderBugAI __instance)
		{
			if (!AntsModBase.BoundConfig.antBugEnabled.Value)
			{
				return;
			}
			GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel/AnimContainer/Armature/Abdomen/Chest/Head/AntLuvsYewFace")).gameObject;
			GameObject gameObject2 = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel/AnimContainer/Armature/Abdomen/Chest/Head/AntLuvsYewMadFace")).gameObject;
			if (!((EnemyAI)__instance).creatureAnimator.GetBool("Chase"))
			{
				if ((Object)(object)gameObject != (Object)null && (Object)(object)gameObject2 != (Object)null)
				{
					gameObject.SetActive(true);
					gameObject2.SetActive(false);
				}
				else
				{
					Debug.LogWarning((object)"One or more of the ALYFaces are null!");
				}
			}
			else if ((Object)(object)gameObject != (Object)null && (Object)(object)gameObject2 != (Object)null)
			{
				gameObject.SetActive(false);
				gameObject2.SetActive(true);
			}
			else
			{
				Debug.LogWarning((object)"One or more of the ALYFaces are null and an Ant Bug is angry!");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class MarchPatch
	{
		private static GameObject ripBuddySign;

		private static bool IsSceneLoaded(string sceneName)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (((Scene)(ref sceneAt)).name == sceneName && ((Scene)(ref sceneAt)).isLoaded)
				{
					return true;
				}
			}
			return false;
		}

		public static void PlaceBuddyboySign()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)GameObject.Find("Environment/RipBuddySign")))
			{
				ripBuddySign = Object.Instantiate<GameObject>(AntsModBase.MyCustomAssets.LoadAssetWithSubAssets<GameObject>("assets/AntsMod/March/ripBuddyboy.prefab")[0]);
				ripBuddySign.transform.parent = GameObject.Find("Environment").transform;
				ripBuddySign.transform.localPosition = new Vector3(38f, -8.5f, -11.8f);
				ripBuddySign.transform.localRotation = Quaternion.Euler(new Vector3(-88f, 192.5f, 151.6f));
				ripBuddySign.transform.localScale = new Vector3(50f, 50f, 50f);
				((Object)ripBuddySign.transform).name = "RipBuddySign";
				Debug.Log((object)"rest in piece, sir buddy boy.");
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void ShowRipBuddyboySignPatch(PlayerControllerB __instance)
		{
			if (AntsModBase.BoundConfig.buddyMemorialEnabled.Value && IsSceneLoaded("Level4March"))
			{
				PlaceBuddyboySign();
			}
		}
	}
}
namespace AntsMod.Coroutines
{
	internal class GenoBurp
	{
		public bool canPlayGenoBurp = true;

		public IEnumerator WaitToPlayGenoBurpSound(ForestGiantAI __instance)
		{
			Debug.LogWarning((object)"Geno Burp coroutine recieved.");
			yield return (object)new WaitForSeconds(5f);
			((Component)((Component)__instance).transform.Find("FGiantModelContainer/GenoBurp")).GetComponent<AudioSource>().Play();
			yield return (object)new WaitForSeconds(5f);
			canPlayGenoBurp = true;
		}
	}
}
namespace AntsMod.Config
{
	public class ModConfig
	{
		public readonly ConfigEntry<bool> antBugEnabled;

		public readonly ConfigEntry<bool> buddyBrackenEnabled;

		public readonly ConfigEntry<bool> genoBurpEnabled;

		public readonly ConfigEntry<bool> buddyMemorialEnabled;

		public ModConfig(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			antBugEnabled = cfg.Bind<bool>("General", "antBugEnabled", true, "If enabled, the Hoarding Bug's face will be turned to Ant's face and squee at you like Ant and play spooky piano music when angered.");
			buddyBrackenEnabled = cfg.Bind<bool>("General", "buddyBrackenEnabled", true, "If enabled, the Bracken will don Buddyboy's Minecraft head and screech at you like Buddyboy when angered.");
			genoBurpEnabled = cfg.Bind<bool>("General", "genoBurpEnabled", true, "If enabled, the Forest Giant will burp really loud like Geno when they eat a player.");
			buddyMemorialEnabled = cfg.Bind<bool>("General", "buddyMemorialEnabled", true, "If enabled, a memorial sign will be placed on March for Buddyboy, who carelessly waltzed right off the edge and into the lake.");
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}
	}
}