Decompiled source of EverythingFloats v1.0.0

plugins\TeflonTed.EverythingFloats.dll

Decompiled 20 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TeflonTed.EverythingFloats")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Teflon Ted's Everything Floats — dropped items do not sink")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+aa3557958a7656958068f9c07e5ebb364e91eab7")]
[assembly: AssemblyProduct("TeflonTed.EverythingFloats")]
[assembly: AssemblyTitle("TeflonTed.EverythingFloats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 TeflonTed.EverythingFloats
{
	[BepInPlugin("com.teflonted.valheim.everythingfloats", "Teflon Ted's Everything Floats", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.teflonted.valheim.everythingfloats";

		public const string PluginName = "Teflon Ted's Everything Floats";

		public const string PluginVersion = "1.0.0";

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.teflonted.valheim.everythingfloats");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Teflon Ted's Everything Floats 1.0.0 loaded");
		}

		internal static void ApplyFloating(ObjectDB db)
		{
			if (db?.m_items == null)
			{
				return;
			}
			int num = 0;
			foreach (GameObject item in db.m_items)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.GetComponent<ItemDrop>() == (Object)null) && !((Object)(object)item.GetComponent<Rigidbody>() == (Object)null) && !((Object)(object)item.GetComponentInChildren<Collider>() == (Object)null))
				{
					Floating val = item.GetComponent<Floating>();
					if ((Object)(object)val == (Object)null)
					{
						val = item.AddComponent<Floating>();
						val.m_waterLevelOffset = 0.7f;
						num++;
					}
					((Behaviour)val).enabled = true;
				}
			}
			if (num > 0)
			{
				Logger.CreateLogSource("Teflon Ted's Everything Floats").LogInfo((object)$"Enabled floating on {num} item prefab(s)");
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	internal static class ObjectDB_Awake_Patch
	{
		private static void Postfix(ObjectDB __instance)
		{
			Plugin.ApplyFloating(__instance);
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	internal static class ObjectDB_CopyOtherDB_Patch
	{
		private static void Postfix(ObjectDB __instance)
		{
			Plugin.ApplyFloating(__instance);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}