Decompiled source of Incredibly Gassy v1.0.2

BepInEx/plugins/incrediblygassy.dll

Decompiled 2 weeks 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("incrediblygassy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("incrediblygassy")]
[assembly: AssemblyTitle("Incredibly Gassy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.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;
		}
	}
	[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 incrediblegas
{
	internal class fard : MonoBehaviour
	{
		public int dueFarts = 0;

		public float totalduration = 0f;

		public float interval = 0f;

		public float counter = 0f;

		public bool regetInterval = true;

		public Character character;

		public void Update()
		{
			if (regetInterval)
			{
				interval = totalduration / (float)dueFarts;
				regetInterval = false;
			}
			float num = Time.deltaTime * Random.Range(0.6f, 4f);
			if (dueFarts > 0)
			{
				counter += num;
			}
			if (totalduration > 0f)
			{
				totalduration -= num;
			}
			if (dueFarts > 0 && totalduration > 0f && counter > interval)
			{
				dueFarts--;
				counter = 0f;
				RPC_theFard(character);
			}
		}

		[PunRPC]
		public void RPC_theFard(Character character)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			int num = Random.Range(1, 103);
			if (!Plugin.ClientSideMode.Value)
			{
				switch (num)
				{
				case 101:
					GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_PoisonExplo", character.Center);
					break;
				case 102:
					GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_DynamiteExplosion", character.Center);
					break;
				}
				GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center, (RpcTarget)0);
			}
			else
			{
				switch (num)
				{
				case 101:
					GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_PoisonExplo", character.Center, (RpcTarget)0);
					break;
				case 102:
					GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_DynamiteExplosion", character.Center, (RpcTarget)0);
					break;
				default:
					GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_SporeExploExploEdibleSpawn", character.Center, (RpcTarget)1);
					break;
				}
				GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center);
			}
			float num2 = Random.Range(50, 300) * 3;
			if (num2 > 600f)
			{
				character.Fall(4f, 0f);
			}
			character.AddForceToBodyPart(character.GetBodypartRig((BodypartType)0), Vector3.zero, (Vector3.up + new Vector3(Random.Range(-0.5f, 0.5f), 0f, Random.Range(-0.5f, 0.5f))) * (num2 + (float)(dueFarts * 10)));
		}
	}
	[HarmonyPatch(typeof(Action_InflictPoison), "RunAction")]
	public static class poisonFardInitiator
	{
		public static void Prefix(Action_InflictPoison __instance)
		{
			fard orAddComponent = ExtGameObject.GetOrAddComponent<fard>(((Component)((ItemActionBase)__instance).character).gameObject);
			if (orAddComponent.totalduration < 160f)
			{
				orAddComponent.totalduration += __instance.inflictionTime * 5f;
			}
			if (orAddComponent.counter >= 0f && orAddComponent.dueFarts <= 0)
			{
				orAddComponent.counter -= __instance.delay * Random.Range(0.2f, 3f);
			}
			orAddComponent.dueFarts += (int)Math.Round(__instance.inflictionTime * (__instance.poisonPerSecond * 100f));
			orAddComponent.regetInterval = true;
			orAddComponent.character = ((ItemActionBase)__instance).character;
		}
	}
	[HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")]
	public static class hungerFardInitiator
	{
		public static void Prefix(Action_RestoreHunger __instance)
		{
			fard orAddComponent = ExtGameObject.GetOrAddComponent<fard>(((Component)((ItemActionBase)__instance).character).gameObject);
			if (orAddComponent.totalduration < 160f)
			{
				orAddComponent.totalduration += Random.Range(0.2f, 100f);
			}
			if (orAddComponent.counter >= 0f && orAddComponent.dueFarts <= 0)
			{
				orAddComponent.counter -= Random.Range(10f, 100f);
			}
			orAddComponent.dueFarts += (int)Math.Round(__instance.restorationAmount * 20f);
			orAddComponent.regetInterval = true;
			orAddComponent.character = ((ItemActionBase)__instance).character;
		}
	}
	[HarmonyPatch(typeof(Action_ApplyAffliction), "RunAction")]
	public static class juiceFardInitiator
	{
		public static void Prefix(Action_ApplyAffliction __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			if ((int)__instance.affliction.GetAfflictionType() == 1 || (int)__instance.affliction.GetAfflictionType() == 2)
			{
				fard orAddComponent = ExtGameObject.GetOrAddComponent<fard>(((Component)((ItemActionBase)__instance).character).gameObject);
				if (orAddComponent.totalduration < 160f)
				{
					orAddComponent.totalduration += Random.Range(0.2f, 100f);
				}
				if (orAddComponent.counter >= 0f && orAddComponent.dueFarts <= 0)
				{
					orAddComponent.counter -= Random.Range(10f, 50f);
				}
				orAddComponent.dueFarts += (int)__instance.affliction.totalTime;
				orAddComponent.totalduration *= Random.Range(0f, 1.5f);
				orAddComponent.regetInterval = true;
				orAddComponent.character = ((ItemActionBase)__instance).character;
			}
		}
	}
	[BepInPlugin("incrediblegas", "Incredibly Gassy", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> ClientSideMode;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ClientSideMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Mode", "PVP Mode", false, "If set to true things will also happen to other players (Get the hosts permission if you are not the host!)");
			Log.LogInfo((object)"Plugin incredibly gassy is loaded!");
			Harmony val = new Harmony("incrediblegas");
			val.PatchAll();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}