Decompiled source of DontYouDare v1.0.0

plugins/me.loaforc.dontyoudare.dll

Decompiled 4 months 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.Logging;
using DontYouDare.Util;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("me.loaforc.dontyoudare")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DontYouDare")]
[assembly: AssemblyTitle("me.loaforc.dontyoudare")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DontYouDare
{
	[BepInPlugin("me.loaforc.dontyoudare", "DontYouDare", "1.0.0")]
	public class DontYouDarePlugin : BaseUnityPlugin
	{
		public static DontYouDarePlugin Instance { get; private set; }

		internal ManualLogSource Logger { get; private set; }

		internal Harmony Harmony { get; set; }

		private void Awake()
		{
			Logger = Logger.CreateLogSource("me.loaforc.dontyoudare");
			Instance = this;
			Logger.LogInfo((object)"Running patches");
			Harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "me.loaforc.dontyoudare");
			Logger.LogInfo((object)"me.loaforc.dontyoudare:1.0.0 by loaforc has loaded :3");
		}
	}
	internal static class ShameHandler
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__PlayerPressed;

			public static HandleNamedMessageDelegate <1>__BroadcastPlayerPressed;
		}

		private const string I_PRESSED_CHANNEL = "loaforc.i_pressed_the_button";

		private const string THEY_PRESSED_CHANNEL = "loaforc.they_pressed_the_button";

		internal static void Init()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			object obj = <>O.<0>__PlayerPressed;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = PlayerPressed;
				<>O.<0>__PlayerPressed = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler("loaforc.they_pressed_the_button", (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			object obj2 = <>O.<1>__BroadcastPlayerPressed;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = BroadcastPlayerPressed;
				<>O.<1>__BroadcastPlayerPressed = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler("loaforc.i_pressed_the_button", (HandleNamedMessageDelegate)obj2);
		}

		internal static void ShameSelf()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			HUDManager.Instance.DisplayTip("Haha", "Don't press it next time.", true, false, "idot");
			ForceNetworkSerializeByMemcpy<PlayerReference> val = default(ForceNetworkSerializeByMemcpy<PlayerReference>);
			val..ctor((PlayerReference)GameNetworkManager.Instance.localPlayerController);
			FastBufferWriter val2 = default(FastBufferWriter);
			((FastBufferWriter)(ref val2))..ctor(1100, (Allocator)2, -1);
			FastBufferWriter val3 = val2;
			try
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe<ForceNetworkSerializeByMemcpy<PlayerReference>>(ref val, default(ForStructs));
				if (((NetworkBehaviour)StartOfRound.Instance).IsServer || ((NetworkBehaviour)StartOfRound.Instance).IsHost)
				{
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("loaforc.they_pressed_the_button", val2, (NetworkDelivery)3);
				}
				else
				{
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("loaforc.i_pressed_the_button", 0uL, val2, (NetworkDelivery)3);
				}
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val3)).Dispose();
			}
		}

		private static void ShameOther(PlayerControllerB player)
		{
			if (!((Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				HUDManager.Instance.DisplayTip("Haha", player.playerUsername + " thought they were being funny and tried to eject!", true, false, "idot");
			}
		}

		private static void BroadcastPlayerPressed(ulong _, FastBufferReader message)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			ForceNetworkSerializeByMemcpy<PlayerReference> val = default(ForceNetworkSerializeByMemcpy<PlayerReference>);
			val..ctor(default(PlayerReference));
			((FastBufferReader)(ref message)).ReadValueSafe<ForceNetworkSerializeByMemcpy<PlayerReference>>(ref val, default(ForStructs));
			FastBufferWriter val2 = default(FastBufferWriter);
			((FastBufferWriter)(ref val2))..ctor(1100, (Allocator)2, -1);
			((FastBufferWriter)(ref val2)).WriteValueSafe<ForceNetworkSerializeByMemcpy<PlayerReference>>(ref val, default(ForStructs));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("loaforc.they_pressed_the_button", val2, (NetworkDelivery)3);
		}

		private static void PlayerPressed(ulong _, FastBufferReader message)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			ForceNetworkSerializeByMemcpy<PlayerReference> val = default(ForceNetworkSerializeByMemcpy<PlayerReference>);
			val..ctor(default(PlayerReference));
			((FastBufferReader)(ref message)).ReadValueSafe<ForceNetworkSerializeByMemcpy<PlayerReference>>(ref val, default(ForStructs));
			val.Value.TryGet(out var player);
			ShameOther(player);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "me.loaforc.dontyoudare";

		public const string PLUGIN_NAME = "DontYouDare";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DontYouDare.Util
{
	public struct PlayerReference : INetworkSerializable, IEquatable<PlayerReference>
	{
		private ulong playerID;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<ulong>*)(&serializer))->SerializeValue<ulong>(ref playerID, default(ForPrimitives));
		}

		public static implicit operator PlayerReference(PlayerControllerB player)
		{
			PlayerReference result = default(PlayerReference);
			result.playerID = player.actualClientId;
			return result;
		}

		public bool TryGet(out PlayerControllerB player)
		{
			player = StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[playerID]];
			return true;
		}

		public bool Equals(PlayerReference other)
		{
			return playerID == other.playerID;
		}

		public override bool Equals(object obj)
		{
			if (obj is PlayerReference other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return playerID.GetHashCode();
		}
	}
}
namespace DontYouDare.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void RegisterNetworking()
		{
			ShameHandler.Init();
		}
	}
	[HarmonyPatch(typeof(VehicleController))]
	internal static class VehicleControllerPatch
	{
		[HarmonyPatch("SpringDriverSeatLocalClient")]
		[HarmonyPrefix]
		private static bool No()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			GameNetworkManager.Instance.localPlayerController.KillPlayer(default(Vector3), true, (CauseOfDeath)0, 0, default(Vector3));
			ShameHandler.ShameSelf();
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}