Decompiled source of Backflip Become Stone Ragdoll Beans Die Bones v1.0.1

BepInEx/plugins/FlipBecomeStone.dll

Decompiled 3 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 System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[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("FlipBecomeStone")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlipBecomeStone")]
[assembly: AssemblyTitle("FlipBecomeStone")]
[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.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]
	[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]
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace FlipBecomeStone
{
	[HarmonyPatch(typeof(CharacterAnimations), "RPCA_PlayRemove")]
	internal static class EmoteCheck
	{
		internal static void Prefix(CharacterAnimations __instance, string emoteName, bool succeeded)
		{
			if (emoteName == "A_Scout_Emote_BackFlip" && __instance.character.data.fallSeconds <= 0f && PhotonNetwork.IsMasterClient && !__instance.character.data.dead && !__instance.character.data.passedOut)
			{
				BackflipHandler.BackflipLogic(__instance.character);
			}
		}
	}
	internal static class BackflipHandler
	{
		internal static async void BackflipLogic(Character __instance)
		{
			await Task.Delay(750);
			if (Plugin.ragdoll.Value)
			{
				float roll = Random.Range(0f, 100f);
				if (roll > 100f - Plugin.ragdollChance.Value)
				{
					Plugin.Log.LogInfo((object)"Ragdolled a player!");
					__instance.Fall(Plugin.ragdollLength.Value, 0f);
				}
			}
			if (Plugin.becomeBean.Value)
			{
				for (int i = 0; i < Plugin.beanAmount.Value; i++)
				{
					Item component = PhotonNetwork.InstantiateItemRoom("MagicBean", __instance.Center, Quaternion.identity, true).GetComponent<Item>();
					((ItemComponent)((Component)component).GetComponent<MagicBean>()).GetData<OptionableBoolItemData>((DataEntryKey)8).HasData = true;
					Vector3 force = new Vector3(Random.Range(-12000f, 12000f), Random.Range(0f, 5000f), Random.Range(-12000f, 12000f));
					((Component)component).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
					{
						false,
						component.transform.position + ((Vector3)(ref force)).normalized * 2f,
						component.transform.rotation
					});
					component.rig.AddForce(force);
				}
			}
			if (Plugin.becomeSkelly.Value)
			{
				__instance.data.SetSkeleton(true);
			}
			if (Plugin.die.Value)
			{
				__instance.DieInstantly();
			}
			if (Plugin.becomeStone.Value)
			{
				float[] arr = new float[CharacterAfflictions.NumStatusTypes];
				arr[Plugin.penaltyType.Value] = Plugin.stoneAmount.Value;
				__instance.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { arr });
			}
		}
	}
	[BepInPlugin("flipbecomestone", "Flip_Become_Stone", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<STATUSTYPE> penaltyType;

		internal static ConfigEntry<bool> becomeStone;

		internal static ConfigEntry<float> stoneAmount;

		internal static ConfigEntry<bool> ragdoll;

		internal static ConfigEntry<float> ragdollChance;

		internal static ConfigEntry<float> ragdollLength;

		internal static ConfigEntry<bool> becomeBean;

		internal static ConfigEntry<int> beanAmount;

		internal static ConfigEntry<bool> becomeSkelly;

		internal static ConfigEntry<bool> die;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			becomeStone = ((BaseUnityPlugin)this).Config.Bind<bool>("Become What", "Become Stone", true, (ConfigDescription)null);
			penaltyType = ((BaseUnityPlugin)this).Config.Bind<STATUSTYPE>("Become What", "Status Type", (STATUSTYPE)13, (ConfigDescription)null);
			stoneAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Become What", "Status Amount", 0.04f, (ConfigDescription)null);
			ragdoll = ((BaseUnityPlugin)this).Config.Bind<bool>("Become What", "Ragdoll", true, (ConfigDescription)null);
			ragdollChance = ((BaseUnityPlugin)this).Config.Bind<float>("Become What", "Ragdoll % Chance", 50f, (ConfigDescription)null);
			ragdollLength = ((BaseUnityPlugin)this).Config.Bind<float>("Become What", "Ragdoll Length", 2f, (ConfigDescription)null);
			becomeBean = ((BaseUnityPlugin)this).Config.Bind<bool>("Become What", "Become Bean", false, (ConfigDescription)null);
			beanAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Become What", "Bean Amount", 4, (ConfigDescription)null);
			becomeSkelly = ((BaseUnityPlugin)this).Config.Bind<bool>("Become What", "Become Skelly", false, (ConfigDescription)null);
			die = ((BaseUnityPlugin)this).Config.Bind<bool>("Become What", "Become Dead", false, (ConfigDescription)null);
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin Flip_Become_Stone is loaded!");
			Harmony val = new Harmony("flipbecomestone");
			val.PatchAll();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}