Decompiled source of No Puke v0.2.3

Plugins/VentureValheim.NoPuke.dll

Decompiled a month ago
using System;
using System.Diagnostics;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VentureValheim.NoPuke")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VentureValheim.NoPuke")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8E4407DA-E41A-47DF-8AA8-81A55954CE12")]
[assembly: AssemblyFileVersion("0.2.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.3.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VentureValheim.NoPuke
{
	[BepInPlugin("com.orianaventure.mod.NoPuke", "NoPuke", "0.2.3")]
	public class NoPukePlugin : BaseUnityPlugin
	{
		private const string ModName = "NoPuke";

		private const string ModVersion = "0.2.3";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.NoPuke";

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.NoPuke");

		public static readonly ManualLogSource NoPukeLogger = Logger.CreateLogSource("NoPuke");

		public void Awake()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
		}
	}
	public class NoPuke
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class Patch_ObjectDB_Awake
		{
			private static void Postfix()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0176: Expected O, but got Unknown
				Scene activeScene = SceneManager.GetActiveScene();
				if (!((Scene)(ref activeScene)).name.Equals("main"))
				{
					return;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode("fx_Puke"));
				if ((Object)(object)prefab != (Object)null)
				{
					ParticleSystem[] componentsInChildren = prefab.GetComponentsInChildren<ParticleSystem>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						MainModule main = componentsInChildren[i].main;
						((MainModule)(ref main)).duration = 0f;
						((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
						((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0f);
					}
				}
				else
				{
					NoPukePlugin.NoPukeLogger.LogWarning((object)"Could not disable puke animations and effects for fx_Puke.");
				}
				GameObject prefab2 = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode("sfx_Puke_female"));
				if ((Object)(object)prefab2 != (Object)null)
				{
					ZSFX component = prefab2.GetComponent<ZSFX>();
					if ((Object)(object)component != (Object)null)
					{
						component.m_maxVol = 0f;
						component.m_minVol = 0f;
					}
				}
				else
				{
					NoPukePlugin.NoPukeLogger.LogWarning((object)"Could not disable puke animations and effects for sfx_Puke_female.");
				}
				GameObject prefab3 = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode("sfx_Puke_male"));
				if ((Object)(object)prefab3 != (Object)null)
				{
					ZSFX component2 = prefab3.GetComponent<ZSFX>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.m_maxVol = 0f;
						component2.m_minVol = 0f;
					}
				}
				else
				{
					NoPukePlugin.NoPukeLogger.LogWarning((object)"Could not disable puke animations and effects for sfx_Puke_male.");
				}
				if (GetItemDrop("bonemass_attack_aoe", out ItemDrop item))
				{
					item.m_itemData.m_shared.m_startEffect = new EffectList();
				}
				else
				{
					NoPukePlugin.NoPukeLogger.LogWarning((object)"Could not disable bonemass puke animations and effects.");
				}
				NoPukePlugin.NoPukeLogger.LogInfo((object)"Done disabling puke animations and effects.");
			}
		}

		private static readonly NoPuke _instance = new NoPuke();

		public static NoPuke Instance => _instance;

		private NoPuke()
		{
		}

		public static bool GetItemDrop(string name, out ItemDrop item)
		{
			item = null;
			if (!Utility.IsNullOrWhiteSpace(name))
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(name));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					itemPrefab = ObjectDB.instance.GetItemPrefab(name);
				}
				if ((Object)(object)itemPrefab != (Object)null)
				{
					item = itemPrefab.GetComponent<ItemDrop>();
					if ((Object)(object)item != (Object)null)
					{
						return true;
					}
				}
			}
			return false;
		}
	}
}