Decompiled source of Unstrippable v1.0.0

Unstrippable.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Unstrippable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Unstrippable")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("08a78e99-5cad-4ca4-aaff-3a29533025b9")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Unstrippable;

public static class PluginConfig
{
	public static ConfigFile CurrentConfig { get; private set; }

	public static ConfigEntry<bool> IsModEnabled { get; private set; }

	public static void BindConfig(ConfigFile config)
	{
		CurrentConfig = config;
		IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod.");
	}
}
[HarmonyPatch(typeof(ZDO))]
internal static class ZDOPatch
{
	[HarmonyPrefix]
	[HarmonyPatch("Strip", new Type[] { typeof(int) })]
	[HarmonyPatch("Strip", new Type[]
	{
		typeof(int),
		typeof(long)
	})]
	[HarmonyPatch("Strip", new Type[]
	{
		typeof(int),
		typeof(int)
	})]
	[HarmonyPatch("Strip", new Type[]
	{
		typeof(int),
		typeof(Quaternion)
	})]
	[HarmonyPatch("Strip", new Type[]
	{
		typeof(int),
		typeof(string)
	})]
	[HarmonyPatch("Strip", new Type[]
	{
		typeof(int),
		typeof(byte[])
	})]
	[HarmonyPatch("StripConvert", new Type[]
	{
		typeof(ZDOID),
		typeof(int),
		typeof(long)
	})]
	[HarmonyPatch("StripConvert", new Type[]
	{
		typeof(ZDOID),
		typeof(int),
		typeof(Vector3)
	})]
	[HarmonyPatch("StripConvert", new Type[]
	{
		typeof(ZDOID),
		typeof(int),
		typeof(float)
	})]
	[HarmonyPatch("StripLong", new Type[] { typeof(int) })]
	private static bool StripPrefix(ref bool __result)
	{
		if (PluginConfig.IsModEnabled.Value)
		{
			__result = false;
			return false;
		}
		return true;
	}
}
[BepInPlugin("redseiko.valheim.unstrippable", "Unstrippable", "1.0.0")]
public sealed class Unstrippable : BaseUnityPlugin
{
	public const string PluginGuid = "redseiko.valheim.unstrippable";

	public const string PluginName = "Unstrippable";

	public const string PluginVersion = "1.0.0";

	private static ManualLogSource _logger;

	private void Awake()
	{
		_logger = ((BaseUnityPlugin)this).Logger;
		PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.unstrippable");
	}

	public static void LogInfo(object obj)
	{
		_logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
	}
}