Decompiled source of StatueLife v0.2.1

StatueLife.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using Peak;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace StatueLife;

public sealed class ModBadge : MonoBehaviour
{
	private const string Key = "purp.mod.statuelife";

	private const int Slot = 2;

	private BaseUnityPlugin owner;

	private float nextScan;

	private Material material;

	private Texture2D texture;

	private Mesh mesh;

	private readonly Dictionary<Character, GameObject> badges = new Dictionary<Character, GameObject>();

	public static void Attach(BaseUnityPlugin plugin)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		ModBadge modBadge = ((Component)plugin).gameObject.AddComponent<ModBadge>();
		modBadge.owner = plugin;
		try
		{
			string directoryName = Path.GetDirectoryName(plugin.Info.Location);
			string path = Path.Combine(directoryName, "icon.png");
			if (!File.Exists(path))
			{
				path = Path.Combine(directoryName, "assets", "icon.png");
			}
			modBadge.texture = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(modBadge.texture, File.ReadAllBytes(path)))
			{
				throw new InvalidOperationException("Invalid logo image.");
			}
			Shader val = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Shader.Find("Unlit/Transparent");
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Logo shader unavailable.");
			}
			modBadge.material = new Material(val);
			modBadge.material.mainTexture = (Texture)(object)modBadge.texture;
			modBadge.mesh = new Mesh();
			modBadge.mesh.vertices = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(-0.5f, -0.5f, 0f),
				new Vector3(0.5f, -0.5f, 0f),
				new Vector3(0.5f, 0.5f, 0f),
				new Vector3(-0.5f, 0.5f, 0f)
			};
			modBadge.mesh.colors = (Color[])(object)new Color[4]
			{
				Color.white,
				Color.white,
				Color.white,
				Color.white
			};
			modBadge.mesh.uv = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f),
				new Vector2(0f, 1f)
			};
			modBadge.mesh.triangles = new int[6] { 0, 2, 1, 0, 3, 2 };
			modBadge.mesh.RecalculateBounds();
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("StatueLife badges: " + ex.Message));
			((Behaviour)modBadge).enabled = false;
		}
	}

	private static bool Present(Player player)
	{
		if (player == null)
		{
			return false;
		}
		if (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"purp.mod.statuelife", out object value) && value is bool)
		{
			return (bool)value;
		}
		return false;
	}

	private void Advertise(bool value)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		Player localPlayer = PhotonNetwork.LocalPlayer;
		if (localPlayer != null && value != Present(localPlayer))
		{
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)(object)val).Add((object)"purp.mod.statuelife", value ? ((object)true) : null);
			localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
		}
	}

	private void Update()
	{
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Expected O, but got Unknown
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		if (Time.unscaledTime < nextScan)
		{
			return;
		}
		nextScan = Time.unscaledTime + 0.5f;
		bool flag = Object.op_Implicit((Object)(object)owner) && ((Behaviour)owner).isActiveAndEnabled && PhotonNetwork.InRoom;
		Advertise(flag);
		List<Character> list = new List<Character>();
		foreach (KeyValuePair<Character, GameObject> badge in badges)
		{
			if (!flag || !Eligible(badge.Key))
			{
				if (Object.op_Implicit((Object)(object)badge.Value))
				{
					Object.Destroy((Object)(object)badge.Value);
				}
				list.Add(badge.Key);
			}
		}
		foreach (Character item in list)
		{
			badges.Remove(item);
		}
		if (!flag || !Object.op_Implicit((Object)(object)material) || !Object.op_Implicit((Object)(object)mesh))
		{
			return;
		}
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if (Eligible(allCharacter) && !badges.ContainsKey(allCharacter))
			{
				GameObject val = new GameObject("StatueLife ownership logo");
				val.transform.SetParent(((Component)allCharacter).transform, false);
				val.transform.localScale = Vector3.one;
				val.AddComponent<MeshFilter>().sharedMesh = mesh;
				MeshRenderer val2 = val.AddComponent<MeshRenderer>();
				((Renderer)val2).sharedMaterial = material;
				((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val2).receiveShadows = false;
				badges.Add(allCharacter, val);
			}
		}
	}

	private static bool Eligible(Character c)
	{
		if (Object.op_Implicit((Object)(object)c) && !c.IsLocal && !c.isBot && Object.op_Implicit((Object)(object)((MonoBehaviourPun)c).photonView) && !((MonoBehaviourPun)c).photonView.IsMine)
		{
			return Present(((MonoBehaviourPun)c).photonView.Owner);
		}
		return false;
	}

	private void LateUpdate()
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		foreach (KeyValuePair<Character, GameObject> badge in badges)
		{
			Character key = badge.Key;
			GameObject value = badge.Value;
			if (Object.op_Implicit((Object)(object)key) && Object.op_Implicit((Object)(object)value))
			{
				bool flag = Object.op_Implicit((Object)(object)main) && Eligible(key) && key.refs != null && Object.op_Implicit((Object)(object)key.refs.head);
				value.SetActive(flag);
				if (flag)
				{
					value.transform.position = key.refs.head.transform.position + Vector3.up * 0.55f + ((Component)main).transform.right * 0.26f;
					value.transform.rotation = ((Component)main).transform.rotation;
					value.transform.localScale = Vector3.one;
					Vector3 lossyScale = value.transform.lossyScale;
					value.transform.localScale = new Vector3(0.22f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), 0.22f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), 1f);
				}
			}
		}
	}

	private void OnDisable()
	{
		Advertise(value: false);
		foreach (GameObject value in badges.Values)
		{
			if (Object.op_Implicit((Object)(object)value))
			{
				Object.Destroy((Object)(object)value);
			}
		}
		badges.Clear();
	}

	private void OnDestroy()
	{
		OnDisable();
		if (Object.op_Implicit((Object)(object)material))
		{
			Object.Destroy((Object)(object)material);
		}
		if (Object.op_Implicit((Object)(object)texture))
		{
			Object.Destroy((Object)(object)texture);
		}
		if (Object.op_Implicit((Object)(object)mesh))
		{
			Object.Destroy((Object)(object)mesh);
		}
	}
}
[BepInPlugin("local.statuelife", "StatueLife", "0.2.1")]
public sealed class Plugin : BaseUnityPlugin
{
	private sealed class FrozenBody
	{
		private readonly Rigidbody[] rigs;

		private readonly RigidbodyConstraints[] constraints;

		private readonly Vector3[] positions;

		private readonly Quaternion[] rotations;

		private readonly Animator animator;

		private readonly float speed;

		internal FrozenBody(Character c)
		{
			rigs = (from p in c.refs.ragdoll.partDict.Values
				select ((Component)p).GetComponent<Rigidbody>() into r
				where (Object)(object)r != (Object)null
				select r).Distinct().ToArray();
			constraints = rigs.Select((Rigidbody r) => r.constraints).ToArray();
			positions = rigs.Select((Rigidbody r) => r.position).ToArray();
			rotations = rigs.Select((Rigidbody r) => r.rotation).ToArray();
			animator = c.refs.animator;
			speed = (((Object)(object)animator == (Object)null) ? 1f : animator.speed);
			Hold();
		}

		internal void Hold()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < rigs.Length; i++)
			{
				if (!((Object)(object)rigs[i] == (Object)null))
				{
					rigs[i].constraints = (RigidbodyConstraints)126;
					rigs[i].position = positions[i];
					rigs[i].rotation = rotations[i];
					if (!rigs[i].isKinematic)
					{
						rigs[i].linearVelocity = Vector3.zero;
						rigs[i].angularVelocity = Vector3.zero;
					}
				}
			}
			if ((Object)(object)animator != (Object)null)
			{
				animator.speed = 0f;
			}
		}

		internal void Restore()
		{
			for (int i = 0; i < rigs.Length; i++)
			{
				if ((Object)(object)rigs[i] != (Object)null)
				{
					rigs[i].constraints = constraints[i];
				}
			}
			if ((Object)(object)animator != (Object)null)
			{
				animator.speed = speed;
			}
		}
	}

	internal static Plugin Instance;

	internal static volatile bool LocalFrozen;

	internal static bool Curing;

	internal static readonly HashSet<Character> GivingUp = new HashSet<Character>();

	private readonly Dictionary<Character, FrozenBody> bodies = new Dictionary<Character, FrozenBody>();

	private Harmony harmony;

	private readonly HashSet<int> shatteringViews = new HashSet<int>();

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		Instance = this;
		ModBadge.Attach((BaseUnityPlugin)(object)this);
		harmony = new Harmony("local.statuelife");
		try
		{
			harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"StatueLife 0.2.1 loaded (local player only). Friends do not need the mod. Y = shatter; blowgun = cure.");
		}
		catch (Exception ex)
		{
			harmony.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogError((object)("StatueLife could not install its hooks; disabled. " + ex));
			((Behaviour)this).enabled = false;
		}
	}

	internal static bool Frozen(Character c)
	{
		if ((Object)(object)c != (Object)null && c.IsLocal && ((MonoBehaviourPun)c).photonView.IsMine && !c.isBot && (Object)(object)c.data != (Object)null && !c.data.dead && c.data.shouldPetrify)
		{
			return !GivingUp.Contains(c);
		}
		return false;
	}

	private void Update()
	{
		Character localCharacter = Character.localCharacter;
		LocalFrozen = Frozen(localCharacter);
		if (LocalFrozen && Application.isFocused && Keyboard.current != null && ((ButtonControl)Keyboard.current.yKey).wasPressedThisFrame && !((Object)(object)GUIManager.instance == (Object)null) && !GUIManager.instance.windowBlockingInput && !GUIManager.instance.wheelActive)
		{
			ExecuteGiveUp(localCharacter);
		}
	}

	private void ExecuteGiveUp(Character c)
	{
		if (Frozen(c))
		{
			GivingUp.Add(c);
			Release(c);
			LocalFrozen = false;
			((MonoBehaviourPun)c).photonView.RPC("RPCA_Die", (RpcTarget)0, new object[0]);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Statue shattered by give-up: " + ((MonoBehaviourPun)c).photonView.ViewID));
		}
	}

	private void LateUpdate()
	{
		foreach (Character item in new List<Character>(bodies.Keys))
		{
			if (!Frozen(item))
			{
				Release(item);
			}
		}
		foreach (Character item2 in new List<Character>(GivingUp))
		{
			if ((Object)(object)item2 == (Object)null || ((Object)(object)item2.data != (Object)null && !item2.data.dead && !item2.data.shouldPetrify))
			{
				GivingUp.Remove(item2);
			}
		}
		Character[] array = Character.AllCharacters.ToArray();
		foreach (Character val in array)
		{
			if (Frozen(val))
			{
				if (!bodies.TryGetValue(val, out var value))
				{
					value = new FrozenBody(val);
					bodies.Add(val, value);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Living statue: " + ((MonoBehaviourPun)val).photonView.ViewID));
				}
				value.Hold();
			}
		}
	}

	internal void Release(Character c)
	{
		if (bodies.TryGetValue(c, out var value))
		{
			value.Restore();
			bodies.Remove(c);
		}
	}

	internal static void Cure(Character c)
	{
		if (Frozen(c) && ((MonoBehaviourPun)c).photonView.IsMine)
		{
			Curing = true;
			try
			{
				c.data.SetPetrify(0);
			}
			finally
			{
				Curing = false;
			}
			c.data.passOutValue = 0f;
			c.refs.afflictions.killedByDagger = false;
			AccessTools.Method(typeof(CharacterCustomization), "ClearPetrify", (Type[])null, (Type[])null).Invoke(c.refs.customization, null);
			Instance.Release(c);
			if (c.IsLocal)
			{
				LocalFrozen = false;
			}
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Blowgun cured statue: " + ((MonoBehaviourPun)c).photonView.ViewID));
		}
	}

	internal IEnumerator Shatter(PetrifiedScout scout)
	{
		if ((Object)(object)scout == (Object)null || !shatteringViews.Add(((MonoBehaviourPun)scout).photonView.ViewID))
		{
			yield break;
		}
		yield return null;
		if (!((Object)(object)scout == (Object)null))
		{
			int viewId = ((MonoBehaviourPun)scout).photonView.ViewID;
			((MonoBehaviourPun)scout).photonView.RPC("RPC_BreakPetrifiedScout", (RpcTarget)0, new object[0]);
			if (((MonoBehaviourPun)scout).photonView.IsMine || PhotonNetwork.IsMasterClient)
			{
				PhotonNetwork.Destroy(((Component)scout).gameObject);
			}
			shatteringViews.Remove(viewId);
		}
	}

	private void OnGUI()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		if (LocalFrozen)
		{
			GUI.Box(new Rect((float)Screen.width / 2f - 240f, (float)(Screen.height - 100), 480f, 64f), "PETRIFIED — You are still alive.\nA friend's blowgun cures you. Y = shatter and die.\nVoice chat is muted while petrified.");
		}
	}

	private void OnDestroy()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		foreach (FrozenBody value in bodies.Values)
		{
			value.Restore();
		}
		bodies.Clear();
		GivingUp.Clear();
		shatteringViews.Clear();
		LocalFrozen = false;
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}
}
[HarmonyPatch(typeof(Character), "HandleLife")]
internal static class LifePatch
{
	private static bool Prefix(Character __instance)
	{
		if (!Plugin.Frozen(__instance))
		{
			return true;
		}
		__instance.data.passOutValue = 1f;
		return false;
	}
}
[HarmonyPatch]
internal static class DeathPatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		try
		{
			string[] array = new string[7] { "Die", "DieInstantly", "DieInstantlyLocal", "RPCA_Die", "RPCA_SetDead", "PassOut", "RPCA_PassOut" };
			foreach (string name in array)
			{
				yield return AccessTools.Method(typeof(Character), name, (Type[])null, (Type[])null);
			}
		}
		finally
		{
		}
	}

	private static bool Prefix(Character __instance)
	{
		return !Plugin.Frozen(__instance);
	}
}
[HarmonyPatch(typeof(CharacterData), "SetPetrify")]
internal static class PermanentPatch
{
	private static bool Prefix(CharacterData __instance, int __0, ref bool __state)
	{
		Character component = ((Component)__instance).GetComponent<Character>();
		__state = (Object)(object)component != (Object)null && component.IsLocal && __instance.shouldPetrify;
		if (!Plugin.Curing && Plugin.Frozen(component))
		{
			return __0 >= 100;
		}
		return true;
	}

	private static void Postfix(CharacterData __instance, bool __state)
	{
		if (!__state || __instance.shouldPetrify)
		{
			return;
		}
		Character component = ((Component)__instance).GetComponent<Character>();
		if (!((Object)(object)component == (Object)null))
		{
			__instance.passOutValue = 0f;
			if ((Object)(object)component.refs.customization != (Object)null)
			{
				AccessTools.Field(typeof(CharacterCustomization), "petrifyStarted").SetValue(component.refs.customization, false);
			}
			Plugin.Instance.Release(component);
			if (component.IsLocal)
			{
				Plugin.LocalFrozen = false;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterInput), "Sample")]
internal static class InputPatch
{
	private static readonly FieldInfo[] Buttons = (from f in typeof(CharacterInput).GetFields(BindingFlags.Instance | BindingFlags.Public)
		where f.FieldType == typeof(bool) && f.Name != "pauseWasPressed" && f.Name != "itemSwitchBlocked"
		select f).ToArray();

	private static void Postfix(CharacterInput __instance)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		Character localCharacter = Character.localCharacter;
		if (Plugin.Frozen(localCharacter) && object.ReferenceEquals(localCharacter.input, __instance))
		{
			FieldInfo[] buttons = Buttons;
			foreach (FieldInfo fieldInfo in buttons)
			{
				fieldInfo.SetValue(__instance, false);
			}
			__instance.movementInput = Vector2.zero;
			__instance.scrollInput = 0f;
		}
	}
}
[HarmonyPatch]
internal static class MovePatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		try
		{
			string[] array = new string[5] { "CheckMovement", "CheckJump", "CheckSprint", "CheckGravity", "CheckStand" };
			foreach (string name in array)
			{
				yield return AccessTools.Method(typeof(Character), name, (Type[])null, (Type[])null);
			}
		}
		finally
		{
		}
	}

	private static void Postfix(Character __instance, ref bool __result)
	{
		if (Plugin.Frozen(__instance))
		{
			__result = false;
		}
	}
}
[HarmonyPatch]
internal static class SlotsPatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		try
		{
			string[] array = new string[4] { "SelectSlotWasPressed", "SelectSlotIsPressed", "HotbarKeyWasPressed", "HotbarKeyIsPressed" };
			foreach (string name in array)
			{
				yield return AccessTools.Method(typeof(CharacterInput), name, (Type[])null, (Type[])null);
			}
		}
		finally
		{
		}
	}

	private static void Postfix(CharacterInput __instance, ref bool __result)
	{
		Character localCharacter = Character.localCharacter;
		if (Plugin.Frozen(localCharacter) && object.ReferenceEquals(localCharacter.input, __instance))
		{
			__result = false;
		}
	}
}
[HarmonyPatch(typeof(CharacterData), "set_dead")]
internal static class DeadSetterPatch
{
	private static bool Prefix(CharacterData __instance, bool __0)
	{
		if (__0)
		{
			return !Plugin.Frozen(((Component)__instance).GetComponent<Character>());
		}
		return true;
	}
}
[HarmonyPatch(typeof(Action_RaycastDart), "RPC_DartImpact")]
internal static class DartPatch
{
	private static void Prefix(int __0, ref Character __state)
	{
		Character val = default(Character);
		if (Character.GetCharacterWithPhotonID(__0, ref val) && Plugin.Frozen(val) && ((MonoBehaviourPun)val).photonView.IsMine)
		{
			__state = val;
		}
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		MethodInfo original = AccessTools.Method(typeof(CharacterAfflictions), "AddAffliction", new Type[2]
		{
			typeof(Affliction),
			typeof(bool)
		}, (Type[])null);
		MethodInfo replacement = AccessTools.Method(typeof(DartPatch), "ApplyDartAffliction", (Type[])null, (Type[])null);
		int replaced = 0;
		foreach (CodeInstruction instruction in instructions)
		{
			if (CodeInstructionExtensions.Calls(instruction, original))
			{
				instruction.opcode = OpCodes.Call;
				instruction.operand = replacement;
				replaced++;
			}
			yield return instruction;
		}
		if (replaced != 1)
		{
			throw new InvalidOperationException("Unexpected blowgun implementation; refusing partial patch.");
		}
	}

	private static void ApplyDartAffliction(CharacterAfflictions target, Affliction affliction, bool fromRPC)
	{
		Character component = ((Component)target).GetComponent<Character>();
		if (!Plugin.Frozen(component))
		{
			target.AddAffliction(affliction, fromRPC);
		}
	}

	private static void Postfix(Character __state)
	{
		if ((Object)(object)__state != (Object)null)
		{
			Plugin.Cure(__state);
		}
	}
}
[HarmonyPatch(typeof(PetrifiedScout), "RPC_SpawnPetrifiedScout")]
internal static class ShatterPatch
{
	private static void Postfix(PetrifiedScout __instance, int __0)
	{
		Character val = default(Character);
		if (Character.GetCharacterWithPhotonID(__0, ref val) && val.IsLocal && Plugin.GivingUp.Contains(val))
		{
			((MonoBehaviour)Plugin.Instance).StartCoroutine(Plugin.Instance.Shatter(__instance));
		}
	}
}
[HarmonyPatch(typeof(CharacterVoiceHandler), "PushToTalk")]
internal static class TransmitPatch
{
	private static void Postfix(CharacterVoiceHandler __instance, Character ___m_character, Recorder ___m_Recorder, ref bool ___m_currentlyTransmitting)
	{
		if (Plugin.Frozen(___m_character))
		{
			__instance.transmitting = false;
			___m_currentlyTransmitting = false;
			if ((Object)(object)___m_Recorder != (Object)null)
			{
				___m_Recorder.TransmitEnabled = false;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterVoiceHandler), "OnAudioFilterRead")]
internal static class ReceivePatch
{
	private static void Postfix(float[] __0)
	{
		if (Plugin.LocalFrozen && __0 != null)
		{
			Array.Clear(__0, 0, __0.Length);
		}
	}
}