Decompiled source of SoftDiamondLootBug v0.6.9

SoftDiamondTinySoftHoarderBug.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("SoftDiamondTinySoftHoarderBug")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replaces Hoarder Bug with Tiny Softs")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.8")]
[assembly: AssemblyProduct("SoftDiamond's Tiny Soft Hoarder Bug Mod")]
[assembly: AssemblyTitle("SoftDiamondTinySoftHoarderBug")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SoftDiamondHoarderBug
{
	[BepInPlugin("SoftDiamondHoarderBug", "SoftDiamond's Tiny Soft Hoarder Bug Mod", "1.0.8")]
	public class TinySoftModBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("SoftDiamondHoarderBug");

		private static TinySoftModBase Instance;

		public static ManualLogSource mls;

		internal static ConfigEntry<bool> configIncreaseTinySoftSpawns;

		internal static ConfigEntry<int> configMaxEnemyPowerCount;

		internal static ConfigEntry<int> configNecoArcRarityWeight;

		internal static ConfigEntry<int> configNecoArcDay;

		public static GameObject TinySoftPrefab;

		public static GameObject NecoArcObject;

		private AssetBundle TinySoftAssetBundle;

		public static int DaysPassed;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SoftDiamondHoarderBug");
			mls.LogInfo((object)"--=== SOFTDIAMOND's TINY SOFT MOD LOADED ===--");
			configIncreaseTinySoftSpawns = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Increase Tiny Soft Spawns", true, "Determines whether or not to increase the chance of Tiny Softs spawning.");
			configMaxEnemyPowerCount = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Max Enemy Power Count", 10, "Power Count determines the maximum number of enemies that may spawn. The normal value for Experiment, for example, is 4.");
			configNecoArcRarityWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Tiny Soft Rarity Weight", 100, "Increases the chance of Tiny Softs spawning. A normal value is 10-80. Higher = more likely.");
			configNecoArcDay = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Tiny Soft Day", 3, "Tiny Softs will have increased spawn rate on this day. -1 means all days. First day is day 1. 99 means normal spawn rates at all times... unless you reach a 99th day.");
			harmony.PatchAll(typeof(TinySoftModBase));
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "softdiamondlootbug");
			mls.LogDebug((object)text);
			TinySoftAssetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)TinySoftAssetBundle == (Object)null)
			{
				mls.LogError((object)"Could not find Tiny Softs Asset Bundle! File \"softdiamondlootbug\" needs to be moved to the same folder as the .dll");
			}
			TinySoftPrefab = TinySoftAssetBundle.LoadAsset<GameObject>("Assets/wolf_01_mxo.prefab");
			SkinnedMeshRenderer[] componentsInChildren = TinySoftPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
			mls.LogMessage((object)"\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            @%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%%@             \r\n             @%%%%%%%@@@%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%%%%%%@");
		}

		private void Start()
		{
			mls.LogInfo((object)"--=== START ===--");
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		public static void PluginDetectSummonBug(HoarderBugAI __instance)
		{
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			mls.LogInfo((object)"--=== Hoarder Bug Summoned ===--");
			mls.LogInfo((object)"--=== Convert to Tiny Soft ===--");
			if ((Object)(object)((Component)__instance).transform.Find("HoarderBugModel") == (Object)null)
			{
				mls.LogInfo((object)"--=== NOT FOUND ===--");
			}
			else
			{
				mls.LogInfo((object)"--=== FOUND ===--");
			}
			((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("Cube")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
			((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("Cube.001")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
			((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer").Find("Armature")
				.Find("Abdomen")
				.Find("Chest")
				.Find("Head")
				.Find("LeftWing")).gameObject.GetComponent<MeshRenderer>()).enabled = false;
			((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer").Find("Armature")
				.Find("Abdomen")
				.Find("Chest")
				.Find("Head")
				.Find("RightWing")).gameObject.GetComponent<MeshRenderer>()).enabled = false;
			((Component)((Component)__instance).gameObject.transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText = "Tiny Soft";
			NecoArcObject = Object.Instantiate<GameObject>(TinySoftPrefab);
			NecoArcObject.transform.SetParent(((Component)__instance).transform);
			NecoArcObject.transform.localPosition = Vector3.zero;
			NecoArcObject.transform.localRotation = Quaternion.identity;
			((EnemyAI)__instance).creatureAnimator = ((Component)NecoArcObject.transform).GetComponent<Animator>();
		}

		[HarmonyPatch(typeof(HoarderBugAI), "CalculateAnimationDirection")]
		[HarmonyPostfix]
		public static void OnCalculateAnimationDirection(HoarderBugAI __instance, float maxSpeed, ref float ___velX, ref float ___velZ)
		{
			Animator component = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer")).gameObject.GetComponent<Animator>();
			if (!((Object)(object)component == (Object)null))
			{
				component.SetFloat("VelocityX", Mathf.Clamp(___velX, 0f - maxSpeed, maxSpeed));
				component.SetFloat("VelocityZ", Mathf.Clamp(___velZ, 0f - maxSpeed, maxSpeed));
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "KillEnemy")]
		[HarmonyPrefix]
		public static void OnKillEnemy(HoarderBugAI __instance, ref float ___velX, ref float ___velZ)
		{
			Animator component = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer")).gameObject.GetComponent<Animator>();
			if (!((Object)(object)component == (Object)null))
			{
				component.SetFloat("VelocityX", Mathf.Clamp(___velX, 0f, 0f));
				component.SetFloat("VelocityZ", Mathf.Clamp(___velZ, 0f, 0f));
			}
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifiedLoad(ref SelectableLevel newLevel)
		{
			mls.LogInfo((object)("Client is host: " + ((NetworkBehaviour)RoundManager.Instance).IsHost));
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			if (newLevel.levelID == 3)
			{
				mls.LogInfo((object)"Level is company, skipping");
				DaysPassed = 0;
				return true;
			}
			DaysPassed++;
			mls.LogInfo((object)$"Days passed: {DaysPassed}");
			SelectableLevel val = newLevel;
			Dictionary<Type, int> dictionary = new Dictionary<Type, int>();
			dictionary.Clear();
			if (configIncreaseTinySoftSpawns.Value && (configNecoArcDay.Value == -1 || configNecoArcDay.Value == DaysPassed))
			{
				val.maxEnemyPowerCount = configMaxEnemyPowerCount.Value;
				dictionary.Add(typeof(HoarderBugAI), configNecoArcRarityWeight.Value);
				UpdateRarity(newLevel.Enemies, dictionary);
				mls.LogInfo((object)"Increased Max Power Counter and Hoarder Bug Spawns");
			}
			else
			{
				mls.LogInfo((object)"Using default spawn rate settings");
			}
			newLevel = val;
			return true;
		}

		private static void UpdateRarity(List<SpawnableEnemyWithRarity> enemies, Dictionary<Type, int> componentRarity)
		{
			if (componentRarity.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity enemy in enemies)
			{
				foreach (KeyValuePair<Type, int> item in componentRarity)
				{
					if (!((Object)(object)enemy.enemyType.enemyPrefab.GetComponent(item.Key) == (Object)null))
					{
						enemy.rarity = item.Value;
						componentRarity.Remove(item.Key);
						break;
					}
				}
			}
		}

		public static bool Dummy(string code)
		{
			return true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SoftDiamondHoarderBug";

		public const string PLUGIN_NAME = "SoftDiamond's Tiny Soft Hoarder Bug Mod";

		public const string PLUGIN_VERSION = "1.0.8";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}