Decompiled source of modpack qol v0.0.6

plugins/MiningMod.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
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: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7ccc489f173c74e963a76aecaa0f5c26a4c025a5")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MiningMod;

[BepInPlugin("aedenthorn.MiningMod", "Mining Mod", "0.8.1")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(DropOnDestroyed), "Awake")]
	private static class DropOnDestroyed_Awake_Patch
	{
		private static void Postfix(ref DropOnDestroyed __instance)
		{
			if (((Object)((Component)__instance).gameObject).name.Contains("Rock"))
			{
				__instance.m_dropWhenDestroyed.m_dropMin = Mathf.RoundToInt(dropMinMult.Value * (float)__instance.m_dropWhenDestroyed.m_dropMin);
				__instance.m_dropWhenDestroyed.m_dropMax = Mathf.RoundToInt(dropMaxMult.Value * (float)__instance.m_dropWhenDestroyed.m_dropMax);
				DropTable dropWhenDestroyed = __instance.m_dropWhenDestroyed;
				dropWhenDestroyed.m_dropChance *= dropChanceMult.Value;
			}
		}
	}

	[HarmonyPatch(typeof(DropOnDestroyed), "OnDestroyed")]
	private static class DropOnDestroyed_OnDestroyed_Patch
	{
		private static void Prefix(ref DropOnDestroyed __instance)
		{
			dropTableObject = ((Object)((Component)__instance).gameObject).name;
		}

		private static void Postfix(ref DropOnDestroyed __instance)
		{
			dropTableObject = "";
		}
	}

	[HarmonyPatch(typeof(MineRock), "Start", new Type[] { })]
	private static class MineRock_Start_Patch
	{
		private static void Postfix(ref MineRock __instance)
		{
			__instance.m_dropItems.m_dropMin = Mathf.RoundToInt(dropMinMult.Value * (float)__instance.m_dropItems.m_dropMin);
			__instance.m_dropItems.m_dropMax = Mathf.RoundToInt(dropMaxMult.Value * (float)__instance.m_dropItems.m_dropMax);
			DropTable dropItems = __instance.m_dropItems;
			dropItems.m_dropChance *= dropChanceMult.Value;
		}
	}

	[HarmonyPatch(typeof(MineRock5), "Awake", new Type[] { })]
	private static class MineRock5_Start_Patch
	{
		private static void Postfix(ref MineRock5 __instance)
		{
			__instance.m_dropItems.m_dropMin = Mathf.RoundToInt(dropMinMult.Value * (float)__instance.m_dropItems.m_dropMin);
			__instance.m_dropItems.m_dropMax = Mathf.RoundToInt(dropMaxMult.Value * (float)__instance.m_dropItems.m_dropMax);
			DropTable dropItems = __instance.m_dropItems;
			dropItems.m_dropChance *= dropChanceMult.Value;
		}
	}

	[HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { })]
	private static class DropTable_GetDropList_Patch
	{
		private static void Postfix(ref List<GameObject> __result)
		{
			if (!Environment.StackTrace.Contains("MineRock") && (!Environment.StackTrace.Contains("DropOnDestroyed") || !dropTableObject.Contains("Rock")))
			{
				return;
			}
			Dictionary<string, List<GameObject>> dictionary = new Dictionary<string, List<GameObject>>();
			foreach (GameObject item in __result)
			{
				if (!((Object)(object)item == (Object)null))
				{
					if (!dictionary.ContainsKey(((Object)item).name))
					{
						dictionary.Add(((Object)item).name, new List<GameObject>());
					}
					dictionary[((Object)item).name].Add(item);
				}
			}
			foreach (KeyValuePair<string, List<GameObject>> item2 in dictionary)
			{
				string prefabName = Utils.GetPrefabName(item2.Value[0]);
				int num = item2.Value.Count;
				if (item2.Key == "Stone")
				{
					num = Mathf.RoundToInt((float)num * stoneDropMult.Value);
				}
				else if (item2.Key.EndsWith("Ore"))
				{
					num = Mathf.RoundToInt((float)num * oreDropMult.Value);
				}
				if (item2.Value.Count < num)
				{
					for (int i = item2.Value.Count; i < num; i++)
					{
						__result.Add(item2.Value[0]);
					}
				}
				else if (num < item2.Value.Count)
				{
					for (int j = num; j < item2.Value.Count; j++)
					{
						__result.Remove(item2.Value[j]);
					}
				}
			}
			if (Random.value < rubyDropChance.Value)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("Ruby");
				__result.Add(prefab);
			}
			if (Random.value < amberDropChance.Value)
			{
				GameObject prefab2 = ZNetScene.instance.GetPrefab("Amber");
				__result.Add(prefab2);
			}
			if (Random.value < amberPearlDropChance.Value)
			{
				GameObject prefab3 = ZNetScene.instance.GetPrefab("AmberPearl");
				__result.Add(prefab3);
			}
			if (Random.value < flintDropChance.Value)
			{
				GameObject prefab4 = ZNetScene.instance.GetPrefab("Flint");
				__result.Add(prefab4);
			}
		}
	}

	private static class DropTable_GetDropList_Patch2
	{
		private static void Prefix(ref int amount)
		{
			if (!Environment.StackTrace.Contains("MineRock") && Environment.StackTrace.Contains("DropOnDestroyed") && !dropTableObject.Contains("Rock"))
			{
			}
		}
	}

	[HarmonyPatch(typeof(MineRock), "Damage")]
	private static class MineRock_Damage_Patch
	{
		private static void Prefix(MineRock __instance, ref HitData hit)
		{
			hit.m_damage.m_pickaxe *= damageMult.Value;
			hit.m_damage.m_blunt *= damageMult.Value;
			hit.m_damage.m_chop *= damageMult.Value;
			hit.m_damage.m_pierce *= damageMult.Value;
		}
	}

	[HarmonyPatch(typeof(MineRock5), "Damage")]
	private static class MineRock5_Damage_Patch
	{
		private static void Prefix(MineRock5 __instance, ref HitData hit)
		{
			hit.m_damage.m_pickaxe *= damageMult.Value;
			hit.m_damage.m_blunt *= damageMult.Value;
			hit.m_damage.m_chop *= damageMult.Value;
			hit.m_damage.m_pierce *= damageMult.Value;
		}
	}

	[HarmonyPatch(typeof(Destructible), "Damage")]
	private static class DropOnDestroyed_Damage_Patch
	{
		private static void Prefix(Destructible __instance, ref HitData hit)
		{
			if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<DropOnDestroyed>()) && ((Object)((Component)__instance).gameObject).name.Contains("Rock"))
			{
				hit.m_damage.m_pickaxe *= damageMult.Value;
				hit.m_damage.m_blunt *= damageMult.Value;
				hit.m_damage.m_chop *= damageMult.Value;
				hit.m_damage.m_pierce *= damageMult.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Terminal), "InputText")]
	private static class InputText_Patch
	{
		private static bool Prefix(Terminal __instance)
		{
			if (!modEnabled.Value)
			{
				return true;
			}
			string text = ((TMP_InputField)__instance.m_input).text;
			if (text.ToLower().Equals("mining reset"))
			{
				((BaseUnityPlugin)context).Config.Reload();
				((BaseUnityPlugin)context).Config.Save();
				__instance.AddString(text);
				__instance.AddString("Mining Mod config reloaded");
				return false;
			}
			return true;
		}
	}

	private static readonly bool isDebug = true;

	private static BepInExPlugin context;

	public static ConfigEntry<bool> modEnabled;

	public static ConfigEntry<float> damageMult;

	public static ConfigEntry<float> stoneDropMult;

	public static ConfigEntry<float> oreDropMult;

	public static ConfigEntry<float> dropMinMult;

	public static ConfigEntry<float> dropMaxMult;

	public static ConfigEntry<float> dropChanceMult;

	public static ConfigEntry<float> rubyDropChance;

	public static ConfigEntry<float> amberDropChance;

	public static ConfigEntry<float> amberPearlDropChance;

	public static ConfigEntry<float> flintDropChance;

	public static ConfigEntry<int> nexusID;

	private static string dropTableObject = "";

	public static void Dbgl(string str = "", bool pref = true)
	{
		if (isDebug)
		{
			Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str));
		}
	}

	private void Awake()
	{
		context = this;
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		dropChanceMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropChanceMult", 1f, "Multiply the drop chance by this amount");
		stoneDropMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StoneDropMult", 1f, "Multiply the amount of stone dropped by this amount");
		oreDropMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OreDropMult", 1f, "Multiply the amount of ore dropped by this amount");
		dropMinMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropMinMult", 1f, "Multiply the minimum amount dropped (before multiplier) by this amount");
		dropMaxMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropMaxMult", 1f, "Multiply the maximum amount dropped (before multiplier) by this amount");
		rubyDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RubyDropChance", 0.05f, "Chance of dropping a ruby");
		amberPearlDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AmberPearlDropChance", 0.1f, "Chance of dropping amber pearl");
		amberDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AmberDropChance", 0.2f, "Chance of dropping amber");
		flintDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FlintDropChance", 0.15f, "Chance of dropping flint");
		damageMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DamageMult", 1f, "Damage multiplier to mining rocks");
		nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 206, "Nexus mod ID for updates");
		if (modEnabled.Value)
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
}

plugins/valheim_orbital_camera.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("valheim_orbital_camera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("valheim_orbital_camera")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6DA0F241-7F0F-4C27-B48D-41DD61F2BE04")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace valheim_orbital_camera;

[BepInPlugin("de.torbilicious", "valheim-orbital-camera", "1.1.1")]
[BepInProcess("valheim.exe")]
public class OrbitalCameraMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
	private class Camera_Patch
	{
		private static void Prefix(ref float ___m_maxDistance, ref float ___m_fov)
		{
			if (patchPending)
			{
				Debug.Log((object)$"Previous max Camera Distance: {___m_maxDistance}");
				___m_maxDistance = newMaxCameraDistance.Value;
				Debug.Log((object)$"Patched max Camera Distance:  {___m_maxDistance}");
				Debug.Log((object)$"Previous FOV: {___m_fov}");
				___m_fov = newFov.Value;
				Debug.Log((object)$"Patched FOV:  {___m_fov}");
				patchPending = false;
			}
		}
	}

	private readonly Harmony harmony = new Harmony("de.torbilicious.valheim-orbital-camera");

	private static ConfigEntry<float> newMaxCameraDistance;

	private static ConfigEntry<float> newFov;

	private static bool patchPending = true;

	private void Awake()
	{
		newMaxCameraDistance = ((BaseUnityPlugin)this).Config.Bind<float>("valheim-orbital-camera", "newMaxCameraDistance", 90f, "Max Camera Distance To Patch");
		newMaxCameraDistance.SettingChanged += delegate
		{
			patchPending = true;
		};
		newFov = ((BaseUnityPlugin)this).Config.Bind<float>("valheim-orbital-camera", "newFov", 65f, "New FOV");
		newFov.SettingChanged += delegate
		{
			patchPending = true;
		};
		harmony.PatchAll();
	}
}