Decompiled source of PeakRolesMod v0.1.7

plugins/com.rmPablo.PeakRolesMod.dll

Decompiled 4 days ago
using System;
using System.Collections;
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 Photon.Pun;
using Photon.Voice.PUN;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.rmPablo.PeakRolesMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: AssemblyInformationalVersion("0.1.7")]
[assembly: AssemblyProduct("com.rmPablo.PeakRolesMod")]
[assembly: AssemblyTitle("PeakRolesMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.7.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;
		}
	}
}
public enum RoleType
{
	blind,
	deaf,
	mute
}
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 PeakRolesMod
{
	[HarmonyPatch(typeof(GUIManager))]
	internal class GUIManagerPatch
	{
		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void HandleRoleInput(GUIManager __instance)
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null)
			{
				return;
			}
			PhotonView component = ((Component)localCharacter).GetComponent<PhotonView>();
			if (!((Object)(object)component == (Object)null) && component.IsMine)
			{
				Role role = ((Component)localCharacter).GetComponent<Role>();
				if ((Object)(object)role == (Object)null)
				{
					role = ((Component)localCharacter).gameObject.AddComponent<Role>();
				}
				if (Input.GetKeyDown((KeyCode)288))
				{
					role.RemoveDebuffs();
					((Behaviour)role).enabled = false;
					__instance.SetHeroTitle("Blind", Singleton<MountainProgressHandler>.Instance.progressPoints[0].clip);
					role.BlindUser();
				}
				if (Input.GetKeyDown((KeyCode)289))
				{
					((Behaviour)role).enabled = false;
					role.RemoveDebuffs();
					__instance.SetHeroTitle("Deaf", Singleton<MountainProgressHandler>.Instance.progressPoints[0].clip);
					role.DeafUser();
				}
				if (Input.GetKeyDown((KeyCode)290))
				{
					((Behaviour)role).enabled = false;
					role.RemoveDebuffs();
					__instance.SetHeroTitle("Mute", Singleton<MountainProgressHandler>.Instance.progressPoints[0].clip);
					role.muteUser();
				}
				if (Input.GetKeyDown((KeyCode)287))
				{
					((Behaviour)role).enabled = false;
					role.RemoveDebuffs();
					__instance.SetHeroTitle("Normal", Singleton<MountainProgressHandler>.Instance.progressPoints[0].clip);
				}
			}
		}
	}
	[BepInPlugin("com.rmPablo.PeakRolesMod", "PeakRolesMod", "0.1.7")]
	public class Plugin : BaseUnityPlugin
	{
		private GameObject blackScreen;

		public const string Id = "com.rmPablo.PeakRolesMod";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PeakRolesMod";

		public static string Version => "0.1.7";

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			Harmony val = new Harmony("com.rmPablo1.peakrolesmod");
			val.PatchAll();
			Log.LogWarning((object)"Running harmony.patchall()");
		}

		private void Update()
		{
		}
	}
	public class Role : MonoBehaviour
	{
		public Recorder rec;

		public GameObject blackScreen;

		private static bool blinded;

		private Coroutine muteCoroutine;

		public string roleName { get; set; }

		public string description { get; set; }

		public RoleType roleType { get; set; }

		public Role(string roleName, string description, RoleType roleType)
		{
			this.roleName = roleName;
			this.description = description;
			this.roleType = roleType;
		}

		public void Start()
		{
			blinded = false;
		}

		public void BlindUser()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD");
			blackScreen = new GameObject("blackScreen");
			blackScreen.transform.SetParent(val.transform, false);
			((Graphic)blackScreen.AddComponent<Image>()).color = Color.black;
			blackScreen.transform.SetAsFirstSibling();
			RectTransform component = blackScreen.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(7200f, 7200f);
		}

		public void DeafUser()
		{
			if (muteCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(muteCoroutine);
			}
			muteCoroutine = ((MonoBehaviour)this).StartCoroutine(MuteCoroutine());
		}

		private IEnumerator MuteCoroutine()
		{
			AudioListener.volume = 0f;
			while (true)
			{
				yield return null;
				AudioListener.volume = 0f;
			}
		}

		public void Unmute()
		{
			if (muteCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(muteCoroutine);
				muteCoroutine = null;
			}
			AudioListener.volume = 1f;
		}

		public void muteUser()
		{
			rec = ((Component)Character.localCharacter).GetComponent<PhotonVoiceView>().RecorderInUse;
			rec.TransmitEnabled = false;
		}

		public void RemoveDebuffs()
		{
			((Component)Character.localCharacter).GetComponent<PhotonVoiceView>().RecorderInUse.TransmitEnabled = true;
			Role component = ((Component)Character.localCharacter).GetComponent<Role>();
			if ((Object)(object)component != (Object)null)
			{
				Unmute();
				Object.Destroy((Object)(object)component.blackScreen);
			}
		}
	}
}
namespace PeakRolesMod.Patches
{
	internal static class MainGame
	{
		internal static ManualLogSource Log { get; private set; }

		[HarmonyPatch(typeof(Character), "AddExtraStamina")]
		[HarmonyPrefix]
		private static bool FullStaminaPrefix(Character __instance, ref float add)
		{
			if (!__instance.view.IsMine)
			{
				return true;
			}
			__instance.data.extraStamina = 1f;
			GUIManager.instance.bar.ChangeBar();
			return false;
		}

		[HarmonyPatch(typeof(Player), "Awake")]
		[HarmonyPostfix]
		private static void PlayerAwake()
		{
			for (int i = 0; i < 100; i++)
			{
				Log.LogWarning((object)"PlayerAwake");
			}
		}

		[HarmonyPatch(typeof(Character), "OutOfStamina")]
		[HarmonyPostfix]
		private static void OutOfStaminaPatch(Character __instance, ref bool __result)
		{
			Log.LogWarning((object)"Stamina out!!!!!");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}